openid / AppAuth-JS

JavaScript client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
Apache License 2.0
975 stars 162 forks source link

Invalid well-known URL generated when issuer has trailing Slash #217

Open BeryJu opened 1 year ago

BeryJu commented 1 year ago

Expected Behavior

(Originating from https://github.com/netbirdio/netbird/issues/452)

authentik (goauthentik.io) has an issuer with a trailing slash, which causes issues with this function https://github.com/openid/AppAuth-JS/blob/cf6bb68dfe630c5d5f415bdcc76ea2581f041d8f/src/authorization_service_configuration.ts#L73,

as it'll generate a URL like https://id.beryju.org/application/o/netbird//.well-known/openid-configuration (notice the double slash)

[REQUIRED] Describe expected behavior

The function should check if the issuer has a trailing slash and not append an extra one. I'm not sure if there are any native JavaScript ways to merge URL paths

Describe the problem

[REQUIRED] Actual Behavior

Because of the double-slash, the request fails

[REQUIRED] Steps to reproduce the behavior

Use this Library with any OpenID Connect provider that uses trailing slashes in their issue (for example authentik)

[REQUIRED] Environment