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

refactor: move as discovery to normalize providers #11170

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ThangHuuVu
Copy link
Member

@ThangHuuVu ThangHuuVu commented Jun 16, 2024

☕️ Reasoning

Addressing some TODOs in authorization-url and providers:

  • OAuthConfigInternal['authorization'] now returns a URL and AuthorizationServer if the provider type is oidc.
  • At the normalize step, throw early if c.authorization is empty for OAuth 2 providers

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Copy link

vercel bot commented Jun 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 3:09pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jun 17, 2024 3:09pm
proxy ⬜️ Ignored (Inspect) Visit Preview Jun 17, 2024 3:09pm

Copy link

codecov bot commented Jun 16, 2024

Codecov Report

Attention: Patch coverage is 63.12500% with 59 lines in your changes missing coverage. Please review.

Project coverage is 40.14%. Comparing base (d38fdef) to head (b7dae31).

Files Patch % Lines
packages/core/src/lib/utils/providers.ts 60.86% 36 Missing ⚠️
...s/core/src/lib/actions/signin/authorization-url.ts 11.11% 8 Missing ⚠️
packages/core/src/providers/oauth.ts 0.00% 8 Missing ⚠️
packages/core/src/lib/init.ts 89.18% 4 Missing ⚠️
packages/core/src/types.ts 0.00% 2 Missing ⚠️
...ages/core/src/lib/actions/callback/handle-login.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11170      +/-   ##
==========================================
+ Coverage   40.10%   40.14%   +0.04%     
==========================================
  Files         178      178              
  Lines       28527    28589      +62     
  Branches     1240     1248       +8     
==========================================
+ Hits        11440    11478      +38     
- Misses      17087    17111      +24     

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

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

Nice, thanks! Left a comment, Wil try to re-review more thoroughly later.

if (c.issuer) {
const issuer = new URL(c.issuer)
try {
const discoveryResponse = await o.discoveryRequest(issuer)
Copy link
Member

Choose a reason for hiding this comment

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

we can cache this in the module scope to potentially hit it less

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what do you mean by "module scope" but I implemented the caching mechanism with the cookies. My worry is that this could be considered bloat :/

Copy link
Member Author

Choose a reason for hiding this comment

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

another solution is to make authorization become a lazy function for oidc providers. Technically, it's not much different with the original code, just move the discovery function call to providers, and parseProviders won't need to be async either. This is the first solution I've thought of.

packages/core/src/lib/utils/providers.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants