Skip to content
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

auth-node: refactor OAuth scope management #24743

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented May 13, 2024

Hey, I just made a Pull Request!

This standardizes scope management across OAuth providers, and also aims to fix a couple of issues, especially providers that persist scopes. The overall goal of this is to be able to completely remove the need for bespoke auth APIs in the frontend, in particular for sign-in.

One issue that's been fixed is refreshing with scope persistence. In the current implementation the persisted scopes will always be used, which can break this client flow where a session is refreshed with requested scopes.

An issue that I'll be aiming to fix in followup usages of this is that many auth providers pass the scope option to the passport strategy. That only works if no scopes are requested by the client, because they are not merged. This aims to fix that by properly merging together required, additional, requested and granted scopes.

Will do updates for each provider in followups, so that we can get some eyes/testing of each individual update.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@Rugvip Rugvip requested review from a team as code owners May 13, 2024 11:38
@Rugvip Rugvip requested review from freben and vinzscam May 13, 2024 11:38
@github-actions github-actions bot added the auth label May 13, 2024
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/plugin-auth-node plugins/auth-node patch v0.4.13-next.1

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@@ -68,7 +66,7 @@ describe('authModuleOktaProvider', () => {
expect(startUrl.pathname).toBe('/oauth2/v1/authorize');
expect(Object.fromEntries(startUrl.searchParams)).toEqual({
response_type: 'code',
scope: combinedScopes,
scope: additionalScopes,
Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior change here just highlights that passing scope to the strategy is broken and currently breaks in the same way if any scopes requested from the client. Followup fix will reintroduce the default scopes that we lose if we configure additional scopes here.

Copy link
Member

@freben freben left a comment

Choose a reason for hiding this comment

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

Lookin' awesome

@Rugvip Rugvip added merge-after-release This is a bit too scary to merge until after the next release and removed merge-after-release This is a bit too scary to merge until after the next release labels May 13, 2024
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

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.

None yet

2 participants