Skip to content

feat(auth): Add JWT auth for API routes #967

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 24 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
32537ee
Merge branch 'enable-multiple-auth-methods' into add-oidc-auth-to-api…
jescalada May 29, 2025
ec75f33
chore: set default empty config
jescalada May 29, 2025
048446f
chore: clean up auth methods
jescalada May 29, 2025
a287ab7
Merge branch 'main' into add-oidc-auth-to-api-through-jwt
JamieSlome May 29, 2025
6912ba1
Merge branch 'main' into add-oidc-auth-to-api-through-jwt
JamieSlome May 29, 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
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');
});
});
201 changes: 185 additions & 16 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@
"history": "5.3.0",
"isomorphic-git": "^1.27.1",
"jsonschema": "^1.4.1",
"jwk-to-pem": "^2.0.7",
"load-plugin": "^6.0.0",
"lodash": "^4.17.21",
"lusca": "^1.7.0",
"moment": "^2.29.4",
"mongodb": "^5.0.0",
"nodemailer": "^6.6.1",
"openid-client": "^6.2.0",
"openid-client": "^6.3.1",
"parse-diff": "^0.11.1",
"passport": "^0.7.0",
"passport-activedirectory": "^1.0.4",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"perfect-scrollbar": "^1.5.5",
"prop-types": "15.8.1",
Expand Down
Loading
Loading