Closed jollytoad closed 1 year ago
Here is an example of the UserWidget output btw...
The only changes I have to make to switch providers is to set the appropriate env vars, which is quite handy when working with Deno Deploy (my live site has no providers configured atm, it may do soon though).
I've always wanted to ensure that this module doesn't fall into the trap of doing too much and that its API surface is kept as small as possible. I'd prefer not to have these functions in the module for these reasons. However, you can still create your own module, which could be linked to in the README. I can see these functions having value in some edge cases.
Yeah, I totally understand. I'll let you know if I break them out into a dedicated module. I thought I should discuss the possibility first.
I've been experimenting with deno_kv_oauth to provide a sign in for my personal site, I've created a handful of functions to discover available providers, and to dynamically configure providers based on the environment vars that have been set...
https://github.com/jollytoad/home/blob/main/lib/oauth2_clients.ts
getOAuth2ClientNames
- Get a list of all supported OAuth2 client nameshasOAuth2ClientEnvVars
- Detect whether environment vars have been set for a given OAuth2 clientgetOAuth2ClientFn
- Get the create client function for an OAuth2 client given it's namegetOAuth2ClientScope
- Get the OAuth2 scope for a provider from environment varsWould you be interested in having some or all of these fns within deno_kv_auth itself? I'd be to raise a PR for this if so, and include some tests.
For an example of usage, see... https://github.com/jollytoad/home/blob/main/components/UserWidget.tsx This JSX component lists sign in links for providers where the env vars have been set, using
getOAuth2ClientNames
&hasOAuth2ClientEnvVars
, the sign in link includes the provider name in the path, and https://github.com/jollytoad/home/blob/main/routes/auth/_lib/oauth2_client.ts has a function used by the signin/callback handlers to extract the provider name and usegetOAuth2ClientFn
&getOAuth2ClientScope
. (All of this stuff is specific to my site though, so I wouldn't suggest incorporating these, I'm referencing them simply as an example of usage)