diff --git a/config/identity/handler/interaction/handlers/forgot-password.json b/config/identity/handler/interaction/handlers/forgot-password.json index 3517d7d9c..38286fbdb 100644 --- a/config/identity/handler/interaction/handlers/forgot-password.json +++ b/config/identity/handler/interaction/handlers/forgot-password.json @@ -5,7 +5,7 @@ "comment": "Handles all functionality on the forgot password page", "@id": "urn:solid-server:auth:password:ForgotPasswordInteractionHandler", "@type": "IdpRouteController", - "pathName": "^/idp/interaction/[-_A-Za-z0-9]+/forgotpassword/?$", + "pathName": "^/idp/forgotpassword/?$", "postHandler": { "@type": "ForgotPasswordHandler", "args_messageRenderHandler": { "@id": "urn:solid-server:auth:password:EmailSentRenderHandler" }, diff --git a/config/identity/handler/interaction/handlers/initial.json b/config/identity/handler/interaction/handlers/initial.json index 45734ebbf..f66422410 100644 --- a/config/identity/handler/interaction/handlers/initial.json +++ b/config/identity/handler/interaction/handlers/initial.json @@ -6,7 +6,7 @@ "@id": "urn:solid-server:auth:password:InitialInteractionHandler", "@type": "RouterHandler", "allowedMethods": [ "GET" ], - "allowedPathNames": [ "^/idp/interaction/[-_A-Za-z0-9]+/?$" ], + "allowedPathNames": [ "^/idp/?$" ], "handler": { "@type": "InitialInteractionHandler", "renderHandlerMap": [ diff --git a/config/identity/handler/interaction/handlers/login.json b/config/identity/handler/interaction/handlers/login.json index 4551f5406..e9245b7c5 100644 --- a/config/identity/handler/interaction/handlers/login.json +++ b/config/identity/handler/interaction/handlers/login.json @@ -5,7 +5,7 @@ "comment": "Handles all functionality on the Login Page", "@id": "urn:solid-server:auth:password:LoginInteractionHandler", "@type": "IdpRouteController", - "pathName": "^/idp/interaction/[-_A-Za-z0-9]+/login/?$", + "pathName": "^/idp/login/?$", "postHandler": { "@type": "LoginHandler", "args_accountStore": { "@id": "urn:solid-server:auth:password:AccountStore" }, diff --git a/config/identity/handler/interaction/handlers/registration.json b/config/identity/handler/interaction/handlers/registration.json index efc20d8a7..718d0f7b1 100644 --- a/config/identity/handler/interaction/handlers/registration.json +++ b/config/identity/handler/interaction/handlers/registration.json @@ -5,7 +5,7 @@ "comment": "Handles all functionality on the register page", "@id": "urn:solid-server:auth:password:RegistrationInteractionHandler", "@type": "IdpRouteController", - "pathName": "^/idp/interaction/[-_A-Za-z0-9]+/register/?$", + "pathName": "^/idp/register/?$", "postHandler": { "@type": "RegistrationHandler", "args_ownershipValidator": { diff --git a/config/identity/handler/interaction/handlers/session.json b/config/identity/handler/interaction/handlers/session.json index 76c708895..57066c13f 100644 --- a/config/identity/handler/interaction/handlers/session.json +++ b/config/identity/handler/interaction/handlers/session.json @@ -6,7 +6,7 @@ "@id": "urn:solid-server:auth:password:SessionInteractionHandler", "@type": "RouterHandler", "allowedMethods": [ "POST" ], - "allowedPathNames": [ "^/idp/interaction/[-_A-Za-z0-9]+/confirm/?$" ], + "allowedPathNames": [ "^/idp/confirm/?$" ], "handler": { "@type": "SessionHttpHandler", "interactionCompleter": { "@id": "urn:solid-server:auth:password:InteractionCompleter" } diff --git a/src/identity/interaction/email-password/AccountInteractionPolicy.ts b/src/identity/interaction/email-password/AccountInteractionPolicy.ts index c0abc9e6e..d80acb419 100644 --- a/src/identity/interaction/email-password/AccountInteractionPolicy.ts +++ b/src/identity/interaction/email-password/AccountInteractionPolicy.ts @@ -1,12 +1,12 @@ import type { KoaContextWithOIDC } from 'oidc-provider'; import { interactionPolicy } from 'oidc-provider'; -import urljoin from 'url-join'; +import { ensureTrailingSlash } from '../../../util/PathUtil'; import type { InteractionPolicy, } from '../InteractionPolicy'; /** - * Interaction policy that maps URLs to `${idpPath}/interaction/${context uid}`. + * Interaction policy that redirects to `idpPath`. * Uses the `select_account` interaction policy. */ export class AccountInteractionPolicy implements InteractionPolicy { @@ -24,14 +24,10 @@ export class AccountInteractionPolicy implements InteractionPolicy { }); interactions.add(selectAccount, 0); this.policy = interactions; - this.url = this.createUrlFunction(idpPath); - } - /** - * Helper function to create the function that will be put in `url`. - * Needs to be done like this since the `this` reference is lost when passing this value along. - */ - private createUrlFunction(idpPath: string): (ctx: KoaContextWithOIDC) => string { - return (ctx: KoaContextWithOIDC): string => urljoin(idpPath, 'interaction', ctx.oidc.uid); + // When oidc-provider cannot fulfill the authorization request for any of the possible reasons + // (missing user session, requested ACR not fulfilled, prompt requested, ...) + // it will resolve the interactions.url helper function and redirect the User-Agent to that url. + this.url = (): string => ensureTrailingSlash(idpPath); } } diff --git a/templates/idp/email-password-interaction/confirm.ejs b/templates/idp/email-password-interaction/confirm.ejs index 809f1ab7f..4d8a30188 100644 --- a/templates/idp/email-password-interaction/confirm.ejs +++ b/templates/idp/email-password-interaction/confirm.ejs @@ -12,7 +12,7 @@