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

Proof of concept: Generic OAuth #162

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RedFlames
Copy link
Collaborator

@RedFlames RedFlames commented Nov 6, 2024

Still a bunch of things I'd have to clean up, but this is more like what I had in mind for supporting arbitrary OAuth2 providers

  1. Generate a random string for the OAuth2 "state" parameter, prefix it with the provider key (config name, e.g. "discord") and suffix with RSA signature of the random string (just a lil hack so that the state strings don't need to be tracked anywhere......)
  2. Allow OAuth2 providers configured like so:
OAuthProviders:
  discord:
    OAuthPathAuthorize: https://discord.com/oauth2/authorize
    OAuthPathToken: https://discord.com/api/oauth2/token
    OAuthScope: identify
    OAuthClientID: xxx
    OAuthClientSecret: xxx
    ServiceUserAPI: https://discord.com/api/users/@me
    ServiceUserJsonPathUid: $.id
    ServiceUserJsonPathName: $.['global_name','username']
    ServiceUserJsonPathPfp: $.avatar
    ServiceUserAvatarURL: https://cdn.discordapp.com/avatars/{0}/{1}.png?size=64
    ServiceUserAvatarDefaultURL: https://cdn.discordapp.com/embed/avatars/0.png

(YAML is absolute lunacy with how it doesn't serialize those JSONPaths as strings......)
3. Advantages: When requesting ServiceUserAPI which we don't know what exactly it returns, just try to parse it with config-provided JSONPaths 🙂
https://www.newtonsoft.com/json/help/html/QueryJsonSelectToken.htm
https://goessner.net/articles/JsonPath/

PS: Don't mind the change in client EmojiComponent...... I was lazy with my unstaged changes :)

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.

1 participant