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

chore: change User.authProvider to User.jwtIssuer #1749

Merged
merged 5 commits into from
Feb 23, 2024
Merged

Conversation

bryanoltman
Copy link
Contributor

Description

Because JWT issuers can vary between Azure tenants, we're recording the full issuer instead of simply that it was Microsoft.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (cccd03b) to head (496d32a).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1749   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          165       165           
  Lines         5137      5136    -1     
=========================================
- Hits          5137      5136    -1     
Flag Coverage Δ
shorebird_cli 100.00% <100.00%> (ø)
shorebird_code_push_client 100.00% <ø> (ø)
shorebird_code_push_protocol 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@eseidel eseidel left a comment

Choose a reason for hiding this comment

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

My only concern is that this has moved from testing "startsWith" to testing "contains" which may not be what you want. I'm not sure you want to use regexp here (since you dont' seem to ever used the captured value?).

packages/shorebird_cli/lib/src/auth/auth.dart Outdated Show resolved Hide resolved
packages/shorebird_cli/lib/src/auth/auth.dart Outdated Show resolved Hide resolved
const user = User(
id: 42,
email: email,
jwtIssuer: googleJwtIssuer,
Copy link
Contributor

Choose a reason for hiding this comment

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

We're probably going to end up with these being enums and just getting the .toJson value out of them as a url for the db, rather than using strings inside our models. 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's required that the iss value needs to be a well-formed URL (see https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1).

if (payload.iss.startsWith('https://login.microsoftonline.com')) {
return MicrosoftAuthProvider();
} else if (payload.iss == 'https://accounts.google.com') {
if (googleJwtIssuerRegexp.hasMatch(payload.iss)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having this thing do the iss -> auth provider, you might consider having a middle step which is iss string -> enum -> auth-provider. Then the string -> enum/object could hide all the regexp goop. 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regex goop removed, although I'm not sure that removing it addresses this comment.

I think our VC convo got cut short as you were explaining this, but I'm not sure I understand how adding an intermediate step would make this cleaner.

@bryanoltman bryanoltman merged commit 67a06e7 into main Feb 23, 2024
12 checks passed
@bryanoltman bryanoltman deleted the bo/jwt-issuer branch February 23, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants