Skip to content

feat(auth): implement OIDC auth for frontend #7

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

Closed
wants to merge 17 commits into from

Conversation

jescalada
Copy link
Collaborator

@jescalada jescalada commented Feb 2, 2025

This is a preliminary PR for #1. It adds the OIDC login button to the login page (/login) and the internals for OIDC. Note that the MongoDB implementation is missing at the moment (since this will be refactored soon).

In order to get this to work, you'll have to modify the proxy.config.json in the project (assuming you're executing in dev). Look for the authentication entry, and fill it in with your own OIDC data. If you want to use my own config from below, let me know your email so I can register you in my Google client.

  "authentication": [
    {
      "type": "local",
      "enabled": false
    },
    {
      "type": "ActiveDirectory",
      "enabled": false,
      "adminGroup": "",
      "userGroup": "",
      "domain": "",
      "adConfig": {
        "url": "",
        "baseDN": "",
        "searchBase": ""
      }
    },
    {
      "type": "openidconnect",
      "enabled": true,
      "oidcConfig": {
        "issuer": "https://accounts.google.com",
        "clientID": "1009968223893-u92qq6itk7ej5008o4174gjubs5lhorg.apps.googleusercontent.com",
        "clientSecret": "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",
        "authorizationURL": "https://accounts.google.com/o/oauth2/auth",
        "tokenURL": "https://oauth2.googleapis.com/token",
        "userInfoURL": "https://openidconnect.googleapis.com/v1/userinfo",
        "callbackURL": "http://localhost:8080/api/auth/oidc/callback",
        "scope": "email profile"
      }
    }
  ],

Note: The new config will cause several unit tests to fail. To make those pass again, set the local authentication in the config to "enabled": false. I'll patch this up when implementing the multiple auth strategy (#6) system.

Changelog

  • Add OIDC login backend (endpoints, filesystem database functions) and frontend
    • Add trivial E2E test for OIDC
  • Add checks for easier development
  • Fix minor issues to complete OIDC auth flow

@jescalada jescalada self-assigned this Feb 2, 2025
@jescalada jescalada linked an issue Feb 2, 2025 that may be closed by this pull request
/**
* Generates a username from email address.
* This helps differentiate users within the specific OIDC provider.
* Note: This is incompatible with multiple providers. Ideally, users are identified by
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also if there is a local user with the same username


passport.deserializeUser(async (id, cb) => {
try {
const user = (await db.findUserByOIDC(id)) || (await db.findUser(id));
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this fallback to findUser necessary? If we are logging with OIDC shouldn't we only care about OIDC users?

@fabiovincenzi
Copy link
Collaborator

It generally looks really good, and I think the OIDC strategy works well, I see problems with the local authentications, I couldn't manage to login with the admin profile, but I'm not sure if this is related to this pr.

@jescalada
Copy link
Collaborator Author

It generally looks really good, and I think the OIDC strategy works well, I see problems with the local authentications, I couldn't manage to login with the admin profile, but I'm not sure if this is related to this pr.

I believe this is because in this PR, only one auth method can be active at a time. It's fixed in #24!

@jescalada jescalada changed the title Preliminary OIDC implementation feat(auth): implement OIDC auth for frontend Mar 10, 2025
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 21.59091% with 69 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@c67387c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/service/passport/oidc.js 13.46% 45 Missing ⚠️
src/service/routes/auth.js 27.77% 13 Missing ⚠️
src/db/file/users.js 12.50% 7 Missing ⚠️
src/service/passport/index.js 40.00% 3 Missing ⚠️
src/service/routes/users.js 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main       #7   +/-   ##
=======================================
  Coverage        ?   61.06%           
=======================================
  Files           ?       48           
  Lines           ?     1767           
  Branches        ?        0           
=======================================
  Hits            ?     1079           
  Misses          ?      688           
  Partials        ?        0           

☔ 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.

@jescalada
Copy link
Collaborator Author

Closing as upstream PR finos#936 got merged.

@jescalada jescalada closed this Mar 17, 2025
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.

Enable OIDC in passport
4 participants