Skip to content

feat(auth): add role mapping for JWT auth claims #977

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

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f2c1182
feat(auth): add NotAuthorized and NotFound pages
jescalada Feb 4, 2025
256523f
feat(auth): add AuthProvider and PrivateRoute wrapper
jescalada Feb 4, 2025
516ed7f
chore(auth): rename userLoggedIn endpoint
jescalada Feb 4, 2025
47e95d4
chore(auth): refactor routes to use PrivateRoute guard
jescalada Feb 4, 2025
893e0b1
fix(auth): temporary fix for username edit redirect
jescalada Feb 7, 2025
d049463
fix(auth): access user admin status correctly
jescalada Feb 7, 2025
db04af6
chore(auth): refactor /admin routes into /dashboard
jescalada Feb 11, 2025
9736801
chore(auth): rename Admin files into Dashboard
jescalada Feb 11, 2025
e7ec1f0
test(auth): Add default login redirect E2E test
jescalada Feb 11, 2025
3702acd
fix(auth): fix redirect on local login
jescalada Feb 11, 2025
f2560ab
fix(auth): improve error handling on repos page
jescalada Feb 11, 2025
24ca06f
test(auth): fix failing test (login before accessing page)
jescalada Feb 11, 2025
2146bc0
test(auth): fix login command and simplify login flow
jescalada Feb 11, 2025
884f0a6
feat(auth): refactor and improve existing auth methods
jescalada Feb 16, 2025
ce6023b
feat(auth): configure passport with all enabled auth methods
jescalada Feb 16, 2025
68fa115
test(auth): fix tests for multiple auth methods
jescalada Feb 16, 2025
0a74501
Merge branch 'oidc-implementation' into enable-multiple-auth-methods
jescalada Feb 21, 2025
627c0ea
fix(auth): refactor how auth strategies are loaded into API route mid…
jescalada Feb 21, 2025
534beeb
feat(auth): add JWT strategy and fix
jescalada Mar 1, 2025
8b1a173
feat(auth): add dynamicAuthHandler middleware
jescalada Mar 1, 2025
6265bbd
feat(auth): update JWT auth middleware
jescalada Mar 8, 2025
5202f7e
feat(auth): add jwk-to-pem library for jwt validation
jescalada Mar 8, 2025
e8d0878
feat(auth): convert envs to proxy.config.json entries (jwt)
jescalada Mar 8, 2025
c5b45b2
feat(auth): add missing proxy.config.json auth methods
jescalada Mar 8, 2025
b0c500c
fix(auth): fix undefined errors
jescalada Mar 8, 2025
1446fcd
fix(auth): fix mislabeled auth method
jescalada Mar 8, 2025
85b3fed
feat(auth): set jwtAuthHandler middleware for /push, /repo and /user …
jescalada Mar 8, 2025
3410c29
chore(auth): fix linter errors
jescalada Mar 8, 2025
2d680ad
chore(auth): fix linting errors
jescalada Mar 8, 2025
423f53b
Merge remote-tracking branch 'origin/main' into add-oidc-auth-to-api-…
jescalada Apr 2, 2025
b0e5844
Merge branch 'main' into add-oidc-auth-to-api-through-jwt
jescalada Apr 2, 2025
e259081
fix: add CI debug line and fix config typo
jescalada Apr 2, 2025
04c3878
fix: fix createDefaultAdmin bug and add debug lines for CI
jescalada Apr 4, 2025
3605d73
fix: remove debug lines
jescalada Apr 4, 2025
1e5d361
chore: allow OFL-1.1 license
jescalada Apr 4, 2025
634640f
fix: add line breaks to jwt auth error messages
jescalada Apr 7, 2025
edf4f7d
refactor(auth): convert jwt auth to API-only (remove jwt passport str…
jescalada Apr 10, 2025
cb3d110
fix(auth): remove jwt data from config and disable by default
jescalada Apr 13, 2025
fdaeb6b
feat(auth): add role mapping and assignment on jwt claims
jescalada Apr 13, 2025
5e1440e
test(auth): add test for getJwks helper
jescalada Apr 13, 2025
24cba4d
chore(auth): move jwt util functions into own file for testing
jescalada Apr 13, 2025
dad5beb
test(auth): add test for validateJwt helper function
jescalada Apr 13, 2025
407cb85
test(auth): add test for assignRoles helper function
jescalada Apr 13, 2025
420be8d
test(auth): add tests for jwtAuthHandler
jescalada Apr 13, 2025
5bdcd69
chore: add missing jwtConfig parameter (optional)
jescalada Apr 16, 2025
8decdea
Merge remote-tracking branch 'origin/main' into jwt-claims-role-mapping
jescalada Apr 16, 2025
aee4b4f
fix: fix failing tests
jescalada Apr 16, 2025
583616a
fix: remove unneeded oidc config params and values
jescalada Apr 16, 2025
f31bc6d
fix: fix linter and test issues
jescalada Apr 16, 2025
412b209
fix: e2e test fail due to route refactor (admin -> dashboard)
jescalada Apr 16, 2025
336e51d
fix: e2e test fail (login required)
jescalada Apr 16, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
with:
comment-summary-in-pr: always
fail-on-severity: high
allow-licenses: MIT, MIT-0, Apache-2.0, BSD-3-Clause, BSD-3-Clause-Clear, ISC, BSD-2-Clause, Unlicense, CC0-1.0, 0BSD, X11, MPL-2.0, MPL-1.0, MPL-1.1, MPL-2.0, Zlib
allow-licenses: MIT, MIT-0, Apache-2.0, BSD-3-Clause, BSD-3-Clause-Clear, ISC, BSD-2-Clause, Unlicense, CC0-1.0, 0BSD, X11, MPL-2.0, MPL-1.0, MPL-1.1, MPL-2.0, OFL-1.1, Zlib
fail-on-scopes: development, runtime
allow-dependencies-licenses: 'pkg:npm/caniuse-lite'
7 changes: 7 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
}
}
},
"apiAuthentication": {
"description": "List of authentication sources for API endpoints. May be empty, in which case all endpoints are public.",
"type": "array",
"items": {
"$ref": "#/definitions/authentication"
}
},
"tls": {
"description": "TLS configuration for secure connections",
"type": "object",
Expand Down
4 changes: 3 additions & 1 deletion cypress/e2e/autoApproved.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import moment from 'moment';

describe('Auto-Approved Push Test', () => {
beforeEach(() => {
cy.login('admin', 'admin');

cy.intercept('GET', '/api/v1/push/123', {
statusCode: 200,
body: {
Expand Down Expand Up @@ -45,7 +47,7 @@ describe('Auto-Approved Push Test', () => {
});

it('should display auto-approved message and verify tooltip contains the expected timestamp', () => {
cy.visit('/admin/push/123');
cy.visit('/dashboard/push/123');

cy.wait('@getPush');

Expand Down
12 changes: 12 additions & 0 deletions cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe('Login page', () => {
cy.get('[data-test="login"]').should('exist');
});

it('should redirect to repo list on valid login', () => {
cy.intercept('GET', '**/api/auth/me').as('getUser');

cy.get('[data-test="username"]').type('admin');
cy.get('[data-test="password"]').type('admin');
cy.get('[data-test="login"]').click();

cy.wait('@getUser');

cy.url().should('include', '/dashboard/repo');
})

describe('OIDC login button', () => {
it('should exist', () => {
cy.get('[data-test="oidc-login"]').should('exist');
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/repo.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
describe('Repo', () => {
beforeEach(() => {
cy.visit('/admin/repo');
cy.login('admin', 'admin');

cy.visit('/dashboard/repo');

// prevent failures on 404 request and uncaught promises
cy.on('uncaught:exception', () => false);
Expand All @@ -18,7 +20,7 @@ describe('Repo', () => {

cy
// find the entry for finos/test-repo
.get('a[href="/admin/repo/test-repo"]')
.get('a[href="/dashboard/repo/test-repo"]')
// take it's parent row
.closest('tr')
// find the nearby span containing Code we can click to open the tooltip
Expand Down
6 changes: 5 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
Cypress.Commands.add('login', (username, password) => {
cy.session([username, password], () => {
cy.visit('/login');
cy.intercept('GET', '**/api/auth/me').as('getUser');

cy.get('[data-test=username]').type(username);
cy.get('[data-test=password]').type(password);
cy.get('[data-test=login]').click();
cy.url().should('contain', '/admin/profile');

cy.wait('@getUser');
cy.url().should('include', '/dashboard/repo');
});
});
191 changes: 175 additions & 16 deletions package-lock.json

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

Loading
Loading