Skip to content

Commit

Permalink
Add enabled and status mappers (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock authored Nov 25, 2024
1 parent f60e332 commit db164e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion META-INF/keycloak-scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
}
],
"policies": [],
"mappers": [],
"mappers": [
{
"name": "User Enabled Mapper",
"fileName": "enabled-mapper.js",
"description": "User Enabled Mapper"
},
{
"name": "User employeeStatus Enabled Mapper",
"fileName": "status-mapper.js",
"description": "User employeeStatus Enabled Mapper"
}
],
"saml-mappers": [
{
"name": "X500 displayName",
Expand Down
5 changes: 5 additions & 0 deletions enabled-mapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var enabled = true;
if (user.getFirstAttribute("nsAccountLock") == "TRUE" || user.getFirstAttribute("loginDisabled") == "TRUE") {
enabled = false;
}
enabled;
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>edu.osc</groupId>
<artifactId>osc-keycloak-scripts</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
7 changes: 7 additions & 0 deletions status-mapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var statusEnabled = true;
var allowed = /(REQAPPROVAL|ACTIVE|WEBONLY|RESTRICTED)/;
var employeeStatus = user.getFirstAttribute("employeeStatus");
if (employeeStatus && !allowed.test(employeeStatus)) {
statusEnabled = false;
}
statusEnabled;

0 comments on commit db164e8

Please sign in to comment.