Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,17 @@ OSMT optionally supports role-based access, with these roles:
Role-based access is disabled by default for the Angular UI and Spring REST API. Use these steps to enable roles.

#### Configuration in OSMT Code
Angular UI: In [`auth-roles.ts`](ui/src/app/auth/auth-roles.ts) file, configure these values:
By default, OSMT is configured with roles enabled. If you want to disable roles in OSMT, apply these changes:

In Angular UI: In [`auth-roles.ts`](ui/src/app/auth/auth-roles.ts) file, configure these values:
```
export const ENABLE_ROLES = true
export const ENABLE_ROLES = false
```

Spring REST API: In [`application.properties`](api/src/main/resources/config/application.properties) file, configure these values:
In Spring REST API: In [`application.properties`](api/src/main/resources/config/application.properties) file, configure these values:
```
# Roles settings
app.enableRoles=true
osmt.security.role.admin=ROLE_Osmt_Admin
osmt.security.role.curator=ROLE_Osmt_Curator
osmt.security.role.view=ROLE_Osmt_View
osmt.security.scope.read=SCOPE_osmt.read
app.enableRoles=false
```
* NOTE: if app.enableRoles=false, all authenticated endpoints will be accessible by any authenticated user.
* You can use these role values, or you can provide your own based on your own authorization tooling. For Okta, you will need to use the uppercase `ROLE_` prefix on your role.
Expand Down
10 changes: 5 additions & 5 deletions api/src/main/resources/config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ app.allowPublicLists=true
log4j2.formatMsgNoLookups=true

# Roles settings
app.enableRoles=false
#osmt.security.role.admin=ROLE_Osmt_Admin
#osmt.security.role.curator=ROLE_Osmt_Curator
#osmt.security.role.view=ROLE_Osmt_View
#osmt.security.scope.read=SCOPE_osmt.read
app.enableRoles=true
osmt.security.role.admin=ROLE_Osmt_Admin
osmt.security.role.curator=ROLE_Osmt_Curator
osmt.security.role.view=ROLE_Osmt_View
osmt.security.scope.read=SCOPE_osmt.read
2 changes: 1 addition & 1 deletion ui/src/app/auth/auth-roles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const OSMT_ADMIN = "ROLE_Osmt_Admin"
export const OSMT_CURATOR = "ROLE_Osmt_Curator"

export const ENABLE_ROLES = false
export const ENABLE_ROLES = true

export enum ButtonAction {
SkillUpdate,
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/auth/auth.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ describe("AuthGuard", () => {
expect(authGuard.canActivate(routeMock, stateMock)).toEqual(false)
})

it("should return true even without appropriate roles because ENABLE_ROLES is false for OS OSMT UI", () => {
it("should return false because ENABLE_ROLES is set to true for OS OSMT UI", () => {
// Arrange
AuthServiceData.hasRoleFlag = false
// Act and Assert
expect(authGuard.canActivate(routeMock, stateMock)).toEqual(true)
expect(authGuard.canActivate(routeMock, stateMock)).toEqual(false)
})

it("should return true with undefined route.data.roles", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe("ManageCollectionComponent", () => {

// Assert
expect(actions).toBeTruthy()
expect(actions.length).toEqual(5)
expect(actions.length).toEqual(6)

let action = actions[0]
expect(action.label).toEqual("Add RSDs to This Collection")
Expand Down Expand Up @@ -321,6 +321,7 @@ describe("ManageCollectionComponent", () => {
})

it("delete collection should not be visible", () => {
const spy = spyOnProperty(Auth, "ENABLE_ROLES").and.returnValue(false)
const actions = component.actionDefinitions()
const action = actions[5]
expect(action).toBeUndefined()
Expand Down