OIDC with Discord not working properly #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
first at all thanks for your work.
While trying to port/rewrite one of my apps from yew to leptos i need to get single sign on with discord working again, but i encountered some problems:
end_session_endpoint&prompt=noneI'm glad to help and contribute any further (and may even reach out to and if its possible to provide CORS headers) if someone guides me where to further investigate what part is not going into the correct direction.
Cheers, and thanks in advance!
Hi Marcel, first of all, thanks for reaching out. I've looked into the Discord Developer Docs and as far as I can tell, Discord only supports the
authorization codeflow with aclient idandclient secret. A public client should NEVER have such an secret in there. But what you could do is setting up your own OIDC Server (for example, Rauthy, Keycloak, GoAuthentik) and add Discord as Single Sign On provider. With that setup you would be able to add yourclient idandclient secretto your own OIDC Backend and enable it there. 😄Hit me if I am wrong, but I think Discord is not designed for public clients. I think that's also the reason why discord has no
end_session_endpoint. :)btw; I think Discord is violating the RFC of OIDC. It should always contain the
end_session_endpoint, based on the rfc.I guess you are wrong in this point.
See here: https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-authorization-url-example -> there is no need for any client secret to be provided (and this way its perfectly fine working, i got returned the exchange code, but then nothing further seems to happen).
And https://discord.com/developers/docs/topics/oauth2#implicit-grant is working also totally fine with https://github.com/ctron/yew-oauth2 (but i havent tried Authorization Code Grant with that one.), so i guess discord is fine for authentication purposes for public clients.
Oh! You are right, indeed Discord is also suitable for public clients. I'll take a deeper look into it and test stuff out (later). But still confusing why Discord has no
end_session_endpoint. But that's something I need to figure out/maybe rethink about the current code structure.Would be general better to destroy the session beforehand and then optionally use the
end_session_endpoint, but that's something I need to rebuild. :DI'll also add a builder pattern for the
AuthParameters, to be more flexible. I hope the current state is not too bad, I'll try my best to fix it. :)For the
CORSstuff, there are somereqwestendpoints (I think two or three), where you could add the https://splittydev.github.io/spotify-rs/reqwest/header/enum.AccessControlAllowOrigin.html. This would of course be awesome if it's possible to add it through theAuthParameters. :DBut I can also add it, it's not such a big deal. :3
That is nothing that can be done on client side, as this header must be provided from server side 😄
Discord (https://discord.com/.well-known/openid-configuration):

Some other (https://dev-qcuxgjrapycf5ib4.us.auth0.com/.well-known/openid-configuration):

I guess best would be to mention this somewhere in the docs, that the auth provider must be able to serve the openid-configuration (via https) with CORS headers set (access-control-allow-origin: *, but i'm not 100% sure if this is sufficent).
I found some further read about OIDC/OAuth2 about implicit grant vs authorization code and may Discord uses some mix / legacy state, who knows 🤷
https://developer.okta.com/blog/2018/05/24/what-is-the-oauth2-implicit-grant-type
https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead
jfyi; I was a little bit busy but I'll take some time in the next days to solve the issues. :)