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

Merged
merged 25 commits into from
Jun 29, 2025
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
27cfb07
chore: update package.json scripts
jescalada Jun 13, 2025
e77aec2
Merge remote-tracking branch 'origin/main' into jwt-claims-role-mapping
jescalada Jun 13, 2025
b808b61
chore: improve oidc error handling
jescalada Jun 13, 2025
dccb6c4
chore: improve /repo error handling
jescalada Jun 13, 2025
7b8df5f
test: add extra unit test for invalid login
jescalada Jun 15, 2025
3d420a2
docs: add authentication doc page
jescalada Jun 15, 2025
31cba39
docs: fix broken links
jescalada Jun 15, 2025
25f0065
fix: make error handling more descriptive and catch JWT config error
jescalada Jun 15, 2025
65617cd
Merge branch 'main' into jwt-claims-role-mapping
JamieSlome Jun 16, 2025
699f31f
Merge branch 'main' into jwt-claims-role-mapping
JamieSlome Jun 17, 2025
9f554b7
Merge branch 'main' into jwt-claims-role-mapping
jescalada Jun 18, 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