Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth group -> Aerie role mapping #64

Merged
merged 27 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e084b81
make `DEFAULT_ROLE` env var a string array
skovati Jan 29, 2024
df860b4
add new `AUTH_GROUP_ROLE_MAPPINGS` env var
skovati Jan 29, 2024
c8cf5d1
Change `GroupRoleMapping` type to be a dynamically keyed obj
skovati Jan 30, 2024
7c37e4e
add group -> role validation function
skovati Jan 30, 2024
7083c84
Add helper function to get default role for auth group
skovati Jan 30, 2024
859f820
add helper functions to map auth groups to default / allowed roles
skovati Jan 31, 2024
4b7071d
extract LDAP groups from CAM response, map to roles
skovati Jan 31, 2024
343f0f8
rename function for clarity
skovati Feb 5, 2024
cf10fb8
refactor for clarity
skovati Feb 5, 2024
c244f22
add tests
skovati Feb 5, 2024
b0cf88a
fix lint error
skovati Feb 5, 2024
7411107
fix destructuring names
skovati Feb 5, 2024
83d1863
add format check to CI
skovati Feb 12, 2024
811ffe7
update gateway to node 20
skovati Feb 12, 2024
2db02f8
run prettier
skovati Feb 12, 2024
7ff9063
refactor `mapGroupsToRoles` for clarity
skovati Feb 12, 2024
9449a39
Extract SSO token and use `loginSSO` in CAM user / pass flow
skovati Feb 12, 2024
b84334a
make failed group mapping JSON parse a fatal error
skovati Feb 12, 2024
46d0e81
Conditionally update roles in DB with auth group mapping roles
skovati Feb 12, 2024
420d739
fail login if `allowed_roles` is empty
skovati Feb 12, 2024
1e9c609
run prettier
skovati Feb 12, 2024
1d9009f
update SSO auth env var docs
skovati Feb 12, 2024
ad4dfe3
add `getGroupsWithMappings` docs
skovati Feb 12, 2024
160ff88
only upsert roles on first session login
skovati Feb 14, 2024
784989e
check JWT validity when determining if session is new
skovati Feb 14, 2024
69060b5
wrap role updates in transaction
skovati Feb 16, 2024
89f9ada
Change upsert conditional logic
skovati Feb 16, 2024
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16.13.0'
node-version-file: '.nvmrc'
cache: npm
- name: Install Dev Dependencies and Build
run: |
npm install
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ jobs:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16.13.0'
node-version-file: '.nvmrc'
cache: npm
- name: Install Dev Dependencies and Build
run: |
npm install
npm run build
- name: Lint
run: |
npm run lint
- name: Check formatting
run: |
npm run format:check
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
pull_request:
branches:
- develop
- dev-[0-9]+.[0-9]+.[0-9]+
push:
branches:
- develop
tags:
- v*
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Dependencies
run: npm ci
- name: Test
run: npm run test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
5 changes: 4 additions & 1 deletion docs/ENVIRONMENT.md
Mythicaeda marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ This document provides detailed information about environment variables for the
| --------------------------- | ---------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------- |
| `ALLOWED_ROLES` | Allowed roles when authentication is enabled. | `array` | ["user", "viewer"] |
| `ALLOWED_ROLES_NO_AUTH` | Allowed roles when authentication is disabled. | `array` | ["aerie_admin", "user", "viewer"] |
| `AUTH_GROUP_ROLE_MAPPINGS` | JSON object that maps auth provider groups to Aerie roles. See [SSO authentication docs][SSO authn] | `JSON` | {} |
| `AUTH_TYPE` | Mode of authentication. Set to `cam` to enable CAM authentication. | `string` | none |
| `AUTH_URL` | URL of Auth provider's REST API. Used if the given `AUTH_TYPE` is not set to `none`. | `string` | https://atb-ocio-12b.jpl.nasa.gov:8443/cam-api |
| `AUTH_UI_URL` | URL of Auth provider's login UI. Returned to the UI if SSO token is invalid, so user is redirected | `string` | https://atb-ocio-12b.jpl.nasa.gov:8443/cam-ui |
| `AUTH_SSO_TOKEN_NAME` | The name of the SSO tokens the Gateway should parse cookies for. Likely found in auth provider docs. | `array` | ["iPlanetDirectoryPro"] |
| `DEFAULT_ROLE` | Default role when authentication is enabled. | `array` | user |
| `DEFAULT_ROLE` | Default roles when authentication is enabled. See [SSO authorization docs][SSO authz] for details. | `array` | ["user"] |
| `DEFAULT_ROLE_NO_AUTH` | Default role when authentication is disabled. | `array` | aerie_admin |
| `GQL_API_URL` | URL of GraphQL API for the GraphQL Playground. | `string` | http://localhost:8080/v1/graphql |
| `GQL_API_WS_URL` | URL of GraphQL WebSocket API for the GraphQL Playground. | `string` | ws://localhost:8080/v1/graphql |
Expand All @@ -29,3 +30,5 @@ This document provides detailed information about environment variables for the
| `RATE_LIMITER_LOGIN_MAX` | Max requests allowed every 15 minutes to login endpoints | `number` | 1000 |

[algorithms]: https://github.com/auth0/node-jsonwebtoken#algorithms-supported
[SSO authn]: https://nasa-ammos.github.io/aerie-docs/deployment/advanced-authentication
[SSO authz]: https://nasa-ammos.github.io/aerie-docs/deployment/advanced-permissions
Loading
Loading