Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Jun 3, 2024
0 parents commit 3eb1b1d
Show file tree
Hide file tree
Showing 18 changed files with 732 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
gradle
.gradle
build/
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Zero Access
===

Library to check user roles in AnyLogic models.

High-level flow:

- User is logged in via OIDC
- AnyLogic model is started from a web page
- OIDC ID token is set as a model input parameter
- Zero Access library is used to check the user role in order to display or hide GUI elements

## Usage in AnyLogic

Download jarfile from https://github.com/Zenmo/zero-access/releases and add to dependencies.

Then use the `hasRole` function to check if the user has a specific role.

```jshelllanguage
import static com.zenmo.zeroaccess.ZeroAccessKt.hasRole;
if (hasRole("admin", idToken)) {
// show GUI element
}
```

## Obtain an ID token

How to easily obtain an ID token to run a model locally?

If you have an account at Zenmo: https://zenmo.com/my-tokens/

## Building

```
./gradlew shadowJar
```
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import org.jetbrains.kotlin.config.JvmTarget

plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
kotlin("jvm") version "1.9.23"
}

group = "com.zenmo"
version = "0.1"

repositories {
mavenCentral()
}

dependencies {
testImplementation(kotlin("test"))

implementation("com.nimbusds:nimbus-jose-jwt:9.39.2")
implementation("com.google.crypto.tink:tink:1.13.0")

testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.9.23")
}

tasks.test {
// useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Fri May 31 12:21:40 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 3eb1b1d

Please sign in to comment.