Skip to content

Commit 5996d20

Browse files
committed
Recreate RP if its redirect URI is different.
Fixes #54.
1 parent 75ea720 commit 5996d20

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

flow-typed/lib-defs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare module 'auth-header' {
55
declare module '@solid/oidc-rp' {
66
declare export default class RelyingParty {
77
provider: { url: string },
8+
registration: { redirect_uris: Array<String> },
89
static from(data: Object): Promise<RelyingParty>,
910
static register(
1011
issuer: string,

src/webid-oidc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,15 @@ export async function getRegisteredRp(
7171
idp: string,
7272
options: loginOptions
7373
): Promise<RelyingParty> {
74+
// To reuse a possible previous RP,
75+
// it be for the same IDP and redirect URI
7476
let rp = await getStoredRp(options.storage)
75-
if (!rp || rp.provider.url !== idp) {
77+
if (
78+
!rp ||
79+
rp.provider.url !== idp ||
80+
!rp.registration.redirect_uris.includes(options.callbackUri)
81+
) {
82+
// Register a new RP
7683
rp = await registerRp(idp, options)
7784
await storeRp(options.storage, idp, rp)
7885
}

0 commit comments

Comments
 (0)