Skip to content

Proof of concept: Generic OAuth#162

Draft
RedFlames wants to merge 2 commits into0x0ade:mainfrom
RedFlames:generic-oauth-providers
Draft

Proof of concept: Generic OAuth#162
RedFlames wants to merge 2 commits into0x0ade:mainfrom
RedFlames:generic-oauth-providers

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 :) Moved that bit to #167

@RedFlames RedFlames removed the Client label Dec 21, 2024
@RedFlames RedFlames removed this from the server-next milestone Aug 26, 2025
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.

2 participants