Git Product home page Git Product logo

sapl-demos's Introduction

Build Status

SAPL Demo Projects

** Attention ** The build of the sapl-demo-ethereum module may fail if this web service of web3labs.com is unreachable. In this case copy the file ' sapl-demo-ethereum/src/main/solc/releases.json to ~/.web3j/solc.

This project contains some demo modules demonstrating the usage of the SAPL engine. A good point to start exploring SAPL is by running and experimenting with modifying these demo projects.

If you are interested in how SAPL would be used in an application, you should take a look at sapl-demo-mvc-app and sapl-demo-webflux.

If you want to get familiar with using a PDP directly, start with sapl-demo-embedded.

After that pick a demo that matches your interest.

  • sapl-demo-webflux: Demonstrates how to hook a SAPL PEP into method security with Spring Security and Webflux.

  • sapl-demo-webflux-filterchain: Demonstrates how to hook a SAPL PEP into the Spring Security reactive filter chain in Webflux.

  • sapl-demo-mvc-app: A full stack Spring MVC application secured with SAPL. Demonstrates non-reactive declarative Policy Enforcement Points via annotations.

  • sapl-demo-filterchain: Demonstrates how to hook a SAPL PEP into the Spring Security filter chain for non-reactive environments.

  • sapl-demo-embedded: Manually instantiating a SAPL Policy Decision Point (PDP) and basic PDP interaction. Reading policies from bundled resources or monitoring a file system.

  • sapl-demo-remote: Connect to a dedicated SAPL PDP Server.

  • sapl-demo-extension: Write a custom Policy Information Point (PIP) and function library to extend SAPL with custom attributes and functions.

  • sapl-demo-jwt: A resource server secured with OAuth 2.0, JSON Web Tokens (JWT) and SAPL, with a matching OAuth authorization server and client application.

  • sapl-demo-web-editor: Demonstrates the Vaadin-based SAPL policy editor component.

  • sapl-demo-playground: An integrated policy testing and learning application. Also see https://playground.sapl.io/ for a deployed version ready to use.

  • sapl-demo-testing: Demonstrates how to test SAPL policies with unit tests, including test code coverage reports.

  • sapl-demo-mqtt-pip: Demonstrates how to evaluate MQTT messages with a Policy Information Point.

sapl-demos's People

Contributors

adroefke avatar ancouli avatar benediktheinrich avatar danielicious avatar danieltschmidt avatar dbfuh avatar dependabot[bot] avatar dmavrudis avatar fsiegrist avatar heutelbeck avatar joe-baudisch avatar julianwalkerfp avatar marclbaur avatar mariusmueller90 avatar mschulz-fuh avatar mschweyen avatar nils4444 avatar nipahu avatar nniikkoollaaii avatar praktikant42 avatar rooschoo avatar sonsabo avatar wolfmatth avatar zweihaxen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sapl-demos's Issues

[sapl-demo-playground] Switching between examples isn't correctly updating the not visible tab

When you're showing the "AuthorizationSubscription"-Tab and switching from Example "Basic" to "Spring Security" the Policy Editor and the AuthorizationSubscription-Editor are getting instantly updated correctly from the server side.

Code here ff .

But when clicking the previous not visible "Mocks"-Tab, it's still showing the "old" mock definition from the previous example. Only after clicking inside the sapl-editor-for-vaadin component "json-editor" the content is beeing updated.

You can recreate this behaviour on https://playground.sapl.io

ERROR[Type mismatch. Can only access arrays by index, got: Value[undefined]]

@heutelbeck, First of all thanks for the awesome library. Cab you please quickly help me with this.

I am getting the error
ERROR[Type mismatch. Can only access arrays by index, got: Value[undefined]]

My Sapl file is

import filter.*

set "KubernetesResourceKindController"

first-applicable

for "KubernetesResourceKindController" in action.java.instanceof..simpleName

policy "create Kubernetes kind only if user has access to organisation and workspace"
permit action.java.name == "createKubernetesResourceKind"
where
subject.name == action.arguments[1].<krk.accessToOrganisation>;

And this is my Spring boot Controller code snipped

@PostMapping("")
@IsDevopsOrAbove
@PreEnforce
fun createKubernetesResourceKind(
@RequestHeader("organisationId") organisationId: String,
@RequestHeader("workspaceId") workspaceId: String,
@requestbody createKubernetesResourceKindRequest: CreateKubernetesResourceKindRequest,
): ResponseEntity {
val result = kubernetesResourceKindService.createKubernetesResourceKind(

My PIP file looks like this

@service
@PolicyInformationPoint(name = "krk", description = "retrives info related to KRK")
class OrganisationPIP {

@Autowired
lateinit var workspaceService: WorkspaceService

@Autowired
lateinit var userService: UserService


@Attribute(name = "accessToOrganisation")
fun getAccessOfUserToOrganisation(@Array organisationId: Val, variables: Map<String, JsonNode>): Flux<Val> {
    println("Called getAccessOfUserToOrganisation")
    return Flux.just(Val.of(Utils.objectMapper.convertValue(mapOf("abc" to "bca"), JsonNode::class.java)))
}

}

Policy umformulieren

In sapl-demo-pip die u. a. Policy umschreiben mit einer regex, so dass Zugriff auf alle Resourcen unterhalb "/css/" gewährt wird

aktuell:
policy "permit_css"
permit
action == "GET"
where
resource == "/css/saplDemoMain.css";

[sapl-demo-playground] Playground does not react on the first three changed char's

After page load the sapl-editor-for-vaadin components "sapl-editor" & "json-editor" are not emitting a DocumentChangedEvent for the first three changes.

Because of this the playground is not removing the result of the previous run if for example a single semicolon in the policy is removed, making the policy invalid.

During debugging via a Console.log statement here https://github.com/heutelbeck/sapl-server/blob/main/sapl-editor-for-vaadin/src/main/resources/META-INF/frontend/json-editor.js#L96
I could observe, that the javascript onDocumentChanged method is called on every change. But it's somehow not forwarding this correctly to vaadin.

You can recreate this behaviour on https://playground.sapl.io

Adding my first SAPL to a Spring Boot 2.6.4 projects results in class not found

Hello -

We are just starting to explore using SAPL and I have a simple Spring Boot 2.6.4 application using Gradle and have included SAPL like:

  // SAPL BOM
    implementation(platform("io.sapl:sapl-bom:2.0.1"))
    implementation 'io.sapl:sapl-spring-security'
    implementation 'io.sapl:sapl-spring-pdp-embedded'

However when I add my first SAPL file to the resources folder, I get the following stack trace:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.sapl.prp.PrpUpdateEventSource]: Factory method 'prpUpdateSource' threw exception; nested exception is java.lang.NoSuchFieldError: EOF_TOKEN
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 98 common frames omitted
Caused by: java.lang.NoSuchFieldError: EOF_TOKEN
	at org.eclipse.xtext.parser.antlr.Lexer.nextToken(Lexer.java:60)
	at org.antlr.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:143)
	at org.antlr.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:137)

and it appears that the version of antlr that is included is missing a reference to:
Token.EOF_TOKEN; in the Lexar class.

It doesn't appear that you've added anything special here:
https://github.com/heutelbeck/sapl-demos/blob/master/sapl-demo-mvc-app/pom.xml

Perhaps something with the latest Spring Boot?
Thanks

Mapper fertigstellen

Soll Requests an den PDP auf subject, action, resource, environment mappen. Beispiel von Dominic:
@requarhandler("/xxx/{v1}/{v2}")

Result getSome(@pathparam v1, @pathparam v2, QueryParam(name="sort") String sort) { }

@action(name="some:thingToDo")

(subject, {name = "some:thingToDo", pathParams = { "v1" : ???, "v2": ???}, queryParams = {"sort" = "asc"}}}

How to write SAPL rules?

On the springboot, when a user accesses /books/list, I need to filter books data according to the data_scope range data of the currently logged in user and the category value of books. Please ask how to do this. Please give some collective examples. Thank you very much!

USER:

user | dept | data_scope
admin | 1 | [,]
Tom | 1 | [1,2,3]
Sim | 2 | [1,2]
Kat | 3 | null

BOOKS:

id | name | category
1 | book1 | 1
2 | book2 | 1
3 | Book3 | 2
4 | book4 | 3
5 | book5 | 4
6 | book6 | 5

when user admin to access the api /books/list, can visible all data,return the data:

id | name | category
1 | book1 | 1
2 | book2 | 1
3 | Book3 | 2
4 | book4 | 3
5 | book5 | 4
6 | book6 | 5

when user Tom to access the api /books/list, books.category in user.data_scope, return the data:
id | name | category
1 | book1 | 1
2 | book2 | 1
3 | Book3 | 2
4 | book4 | 3

when user Sim to access the api /books/list, books.category in user.data_scope, return the data:
id | name | category
1 | book1 | 1
2 | book2 | 1
3 | Book3 | 2

when user Kat to access the api /books/list, user.data_scope is null, return the exception:
“access denied,missing permissions”

How to implement the above requirements in MVC and oauth2 environment? Please give some practical examples. Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.