Skip to content

fix: allow for auth with activedirectory again #1061

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 3 commits into
base: main
Choose a base branch
from

Conversation

06kellyjac
Copy link
Contributor

@06kellyjac 06kellyjac commented Jun 25, 2025

Draft because my commit signing seems to be playing up but should otherwise be ready for review.
After actually posting the PR commit signatures look fine.


Main change - allow for auth with activedirectory again

Current /login is forced to use local auth.
This change resolves this regression in a backwards compatible manner while still supporting alternative auth like OIDC.

Auth methods compatible with /login are filtered out from the git-proxy config, if there isn't one /login is essentially disabled to avoid throwing.
If there is multiple methods it'll prioritize the first.
In the future we can support multiple user & password login methods simultaneously with relevant TODOs added.

other fixes:

  • fix: make loadFromGit non-interactive
  • test: move valid url missing git repo test under our control

Current /login is forced to use local auth.
This change resolves this regression in a backwards compatible manner
while still supporting alternative auth like OIDC.

Auth methods compatible with /login are filtered out from the git-proxy
config, if there isn't one /login is essentially disabled to avoid
throwing.
If there is multiple methods it'll prioritize the first.
In the future we can support multiple user & password login methods
simultaneously with relevant TODOs added.
loadFromGit should be sufficiently authenticated and if it isn't it's
not expected to get interactive input. Inform git not to wait for
interactive action.
This also resolves an issue in the tests where "should throw error
if repository is valid URL but not a git repository" test times out
waiting for a username.
If we want to ensure this git repository isn't created it should be
pointed at the FINOS org, the parent of this repo currently.
In theory test-org (an org that currently exists) could add a repo
called test-project.
Copy link

netlify bot commented Jun 25, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit accf223
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/685c14f3b6600900080ffef8

@github-actions github-actions bot added the fix label Jun 25, 2025
@06kellyjac
Copy link
Contributor Author

cc: @jescalada to double check this doesn't impact OIDC & also may be relevant to #1024

@06kellyjac 06kellyjac marked this pull request as ready for review June 25, 2025 15:27
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.60%. Comparing base (d13686d) to head (accf223).

Files with missing lines Patch % Lines
src/service/routes/auth.js 76.92% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1061      +/-   ##
==========================================
+ Coverage   69.51%   69.60%   +0.09%     
==========================================
  Files          54       54              
  Lines        2227     2244      +17     
  Branches      248      248              
==========================================
+ Hits         1548     1562      +14     
- Misses        648      651       +3     
  Partials       31       31              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +53 to +61
(req, res, next) => {
const authType = getLoginStrategy();
if (authType === null) {
res.status(403).send('Username and Password based Login is not enabled at this time').end();
return;
}
console.log('going to auth with', authType);
return passport.authenticate(authType)(req, res, next);
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a callback/middleware to ensure getLoginStrategy and more importantly getAuthMethods gets the correct proxy config after it's read the user's configuration.

In reality by the time this particular JS file is evaluated the file is already read but this is the more robust method

res.status(403).send('Username and Password based Login is not enabled at this time').end();
return;
}
console.log('going to auth with', authType);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could remove this log, was mostly there for testing

Comment on lines +55 to +57
if (authType === null) {
res.status(403).send('Username and Password based Login is not enabled at this time').end();
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should account for cases where only OIDC auth is enabled without just calling into passport and throwing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant