Skip to content

Commit

Permalink
feat: Split up IDP HTML, routing, and handler behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Feb 11, 2022
1 parent 8f8e8e6 commit bc0eeb1
Show file tree
Hide file tree
Showing 45 changed files with 1,012 additions and 715 deletions.
4 changes: 1 addition & 3 deletions config/identity/handler/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
"comment": "Handles IDP handler behaviour.",
"@id": "urn:solid-server:default:IdentityProviderHttpHandler",
"@type": "IdentityProviderHttpHandler",
"args_baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
"args_idpPath": "/idp",
"args_providerFactory": { "@id": "urn:solid-server:default:IdentityProviderFactory" },
"args_converter": { "@id": "urn:solid-server:default:RepresentationConverter" },
"args_errorHandler": { "@id": "urn:solid-server:default:ErrorHandler" }
"args_handler": { "@id": "urn:solid-server:default:InteractionHandler" }
}
]
}
40 changes: 33 additions & 7 deletions config/identity/handler/interaction/routes.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"import": [
"files-scs:config/identity/handler/interaction/routes/existing-login.json",
"files-scs:config/identity/handler/interaction/routes/forgot-password.json",
"files-scs:config/identity/handler/interaction/routes/login.json",
"files-scs:config/identity/handler/interaction/routes/prompt.json",
"files-scs:config/identity/handler/interaction/routes/reset-password.json",
"files-scs:config/identity/handler/interaction/routes/session.json"
"files-scs:config/identity/handler/interaction/views/controls.json",
"files-scs:config/identity/handler/interaction/views/html.json"
],
"@graph": [
{
"@id": "urn:solid-server:default:IdentityProviderHttpHandler",
"IdentityProviderHttpHandler:_args_interactionRoutes": [
{ "@id": "urn:solid-server:auth:password:ForgotPasswordRoute" },
{ "@id": "urn:solid-server:auth:password:LoginRoute" },
{ "@id": "urn:solid-server:auth:password:ResetPasswordRoute" },
{ "@id": "urn:solid-server:auth:password:SessionRoute" }
"@id": "urn:solid-server:default:InteractionHandler",
"@type": "WaterfallHandler",
"handlers": [
{
"comment": "Returns the relevant HTML pages for the interactions when needed",
"@id": "urn:solid-server:auth:password:HtmlViewHandler"
},
{
"comment": "Adds controls and API version to JSON responses.",
"@id": "urn:solid-server:auth:password:ControlHandler",
"ControlHandler:_source" : {
"@id": "urn:solid-server:auth:password:RouteInteractionHandler",
"@type": "WaterfallHandler",
"handlers": [
{
"comment": [
"This handler is required to prevent Components.js issues with arrays.",
"This might be fixed in the next Components.js release after which this can be removed."
],
"@type": "UnsupportedAsyncHandler"
},
{ "@id": "urn:solid-server:auth:password:PromptRoute" },
{ "@id": "urn:solid-server:auth:password:LoginRoute" },
{ "@id": "urn:solid-server:auth:password:ExistingLoginRoute" },
{ "@id": "urn:solid-server:auth:password:ForgotPasswordRoute" },
{ "@id": "urn:solid-server:auth:password:ResetPasswordRoute" }
]
}
}
]
}
]
Expand Down
16 changes: 16 additions & 0 deletions config/identity/handler/interaction/routes/existing-login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"comment": "Handles the interaction that occurs when a logged in user wants to authenticate with a new app.",
"@id": "urn:solid-server:auth:password:ExistingLoginRoute",
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/consent/",
"source": {
"@type": "ExistingLoginHandler",
"interactionCompleter": { "@type": "BaseInteractionCompleter" }
}
}
]
}
26 changes: 7 additions & 19 deletions config/identity/handler/interaction/routes/forgot-password.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"comment": "Handles all functionality on the forgot password page",
"comment": "Handles the forgot password interaction",
"@id": "urn:solid-server:auth:password:ForgotPasswordRoute",
"@type": "BasicInteractionRoute",
"route": "^/forgotpassword/$",
"viewTemplates": {
"BasicInteractionRoute:_viewTemplates_key": "text/html",
"BasicInteractionRoute:_viewTemplates_value": "@css:templates/identity/email-password/forgot-password.html.ejs"
},
"responseTemplates": {
"BasicInteractionRoute:_responseTemplates_key": "text/html",
"BasicInteractionRoute:_responseTemplates_value": "@css:templates/identity/email-password/forgot-password-response.html.ejs"
},
"controls": {
"BasicInteractionRoute:_controls_key": "forgotPassword",
"BasicInteractionRoute:_controls_value": "/forgotpassword/"
},
"handler": {
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/forgotpassword/",
"source": {
"@type": "ForgotPasswordHandler",
"args_accountStore": { "@id": "urn:solid-server:auth:password:AccountStore" },
"args_baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
"args_idpPath": "/idp",
"args_templateEngine": {
"@type": "EjsTemplateEngine",
"template": "@css:templates/identity/email-password/reset-password-email.html.ejs"
},
"args_emailSender": { "@id": "urn:solid-server:default:EmailSender" }
"args_emailSender": { "@id": "urn:solid-server:default:EmailSender" },
"args_resetRoute": { "@id": "urn:solid-server:auth:password:ResetPasswordRoute" }
}
}
]
Expand Down
18 changes: 5 additions & 13 deletions config/identity/handler/interaction/routes/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"comment": "Handles all functionality on the Login Page",
"comment": "Handles the login interaction",
"@id": "urn:solid-server:auth:password:LoginRoute",
"@type": "BasicInteractionRoute",
"route": "^/login/$",
"prompt": "login",
"viewTemplates": {
"BasicInteractionRoute:_viewTemplates_key": "text/html",
"BasicInteractionRoute:_viewTemplates_value": "@css:templates/identity/email-password/login.html.ejs"
},
"controls": {
"BasicInteractionRoute:_controls_key": "login",
"BasicInteractionRoute:_controls_value": "/login/"
},
"handler": {
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/login/",
"source": {
"@type": "LoginHandler",
"accountStore": { "@id": "urn:solid-server:auth:password:AccountStore" },
"interactionCompleter": { "@type": "BaseInteractionCompleter" }
Expand Down
25 changes: 25 additions & 0 deletions config/identity/handler/interaction/routes/prompt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"comment": "Handles OIDC redirects containing a prompt, such as login or consent.",
"@id": "urn:solid-server:auth:password:PromptRoute",
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/",
"source": {
"@type": "PromptHandler",
"promptRoutes": [
{
"PromptHandler:_promptRoutes_key": "login",
"PromptHandler:_promptRoutes_value": { "@id": "urn:solid-server:auth:password:LoginRoute" }
},
{
"PromptHandler:_promptRoutes_key": "consent",
"PromptHandler:_promptRoutes_value": { "@id": "urn:solid-server:auth:password:ExistingLoginRoute" }
}
]
}
}
]
}
18 changes: 5 additions & 13 deletions config/identity/handler/interaction/routes/reset-password.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"comment": "Exports 2 handlers: one for viewing the page and one for doing the reset.",
"@graph": [
{
"comment": "Handles the reset password page submission",
"comment": "Handles the reset password interaction",
"@id": "urn:solid-server:auth:password:ResetPasswordRoute",
"@type": "BasicInteractionRoute",
"route": "^/resetpassword/$",
"viewTemplates": {
"BasicInteractionRoute:_viewTemplates_key": "text/html",
"BasicInteractionRoute:_viewTemplates_value": "@css:templates/identity/email-password/reset-password.html.ejs"
},
"responseTemplates": {
"BasicInteractionRoute:_responseTemplates_key": "text/html",
"BasicInteractionRoute:_responseTemplates_value": "@css:templates/identity/email-password/reset-password-response.html.ejs"
},
"handler": {
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/resetpassword/",
"source": {
"@type": "ResetPasswordHandler",
"accountStore": { "@id": "urn:solid-server:auth:password:AccountStore" }
}
Expand Down
20 changes: 0 additions & 20 deletions config/identity/handler/interaction/routes/session.json

This file was deleted.

19 changes: 19 additions & 0 deletions config/identity/handler/interaction/views/controls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:auth:password:ControlHandler",
"@type": "ControlHandler",
"controls": [
{
"ControlHandler:_controls_key": "login",
"ControlHandler:_controls_value": { "@id": "urn:solid-server:auth:password:LoginRoute" }
},
{
"ControlHandler:_controls_key": "forgotPassword",
"ControlHandler:_controls_value": { "@id": "urn:solid-server:auth:password:ForgotPasswordRoute" }
}
]
}
]
}
43 changes: 43 additions & 0 deletions config/identity/handler/interaction/views/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:auth:password:HtmlViewHandler",
"@type": "HtmlViewHandler",
"templateEngine": {
"comment": "Renders the specific page and embeds it into the main HTML body.",
"@type": "ChainedTemplateEngine",
"renderedName": "htmlBody",
"engines": [
{
"comment": "Will be called with specific templates to generate HTML snippets.",
"@type": "EjsTemplateEngine"
},
{
"comment": "Will embed the result of the first engine into the main HTML template.",
"@type": "EjsTemplateEngine",
"template": "@css:templates/main.html.ejs"
}
]
},
"templates": [
{
"HtmlViewHandler:_templates_key": "@css:templates/identity/email-password/login.html.ejs",
"HtmlViewHandler:_templates_value": { "@id": "urn:solid-server:auth:password:LoginRoute" }
},
{
"HtmlViewHandler:_templates_key": "@css:templates/identity/email-password/consent.html.ejs",
"HtmlViewHandler:_templates_value": { "@id": "urn:solid-server:auth:password:ExistingLoginRoute" }
},
{
"HtmlViewHandler:_templates_key": "@css:templates/identity/email-password/forgot-password.html.ejs",
"HtmlViewHandler:_templates_value": { "@id": "urn:solid-server:auth:password:ForgotPasswordRoute" }
},
{
"HtmlViewHandler:_templates_key": "@css:templates/identity/email-password/reset-password.html.ejs",
"HtmlViewHandler:_templates_value": { "@id": "urn:solid-server:auth:password:ResetPasswordRoute" }
}
]
}
]
}
30 changes: 27 additions & 3 deletions config/identity/registration/enabled.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,35 @@
],
"@graph": [
{
"comment": "Enable registration by adding a registration handler to the list of interaction routes.",
"@id": "urn:solid-server:default:IdentityProviderHttpHandler",
"IdentityProviderHttpHandler:_args_interactionRoutes": [
"@id": "urn:solid-server:auth:password:RouteInteractionHandler",
"WaterfallHandler:_handlers": [
{
"comment": [
"This handler is required to prevent Components.js issues with arrays.",
"This might be fixed in the next Components.js release after which this can be removed."
],
"@type": "UnsupportedAsyncHandler"
},
{ "@id": "urn:solid-server:auth:password:RegistrationRoute" }
]
},
{
"@id": "urn:solid-server:auth:password:ControlHandler",
"ControlHandler:_controls": [
{
"ControlHandler:_controls_key": "register",
"ControlHandler:_controls_value": { "@id": "urn:solid-server:auth:password:RegistrationRoute" }
}
]
},
{
"@id": "urn:solid-server:auth:password:HtmlViewHandler",
"HtmlViewHandler:_templates": [
{
"HtmlViewHandler:_templates_key": "@css:templates/identity/email-password/register.html.ejs",
"HtmlViewHandler:_templates_value": { "@id": "urn:solid-server:auth:password:RegistrationRoute" }
}
]
}
]
}
21 changes: 5 additions & 16 deletions config/identity/registration/route/registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^2.0.0/components/context.jsonld",
"@graph": [
{
"comment": "Handles all functionality on the register page",
"comment": "Handles the register interaction",
"@id": "urn:solid-server:auth:password:RegistrationRoute",
"@type": "BasicInteractionRoute",
"route": "^/register/$",
"viewTemplates": {
"BasicInteractionRoute:_viewTemplates_key": "text/html",
"BasicInteractionRoute:_viewTemplates_value": "@css:templates/identity/email-password/register.html.ejs"
},
"responseTemplates": {
"BasicInteractionRoute:_responseTemplates_key": "text/html",
"BasicInteractionRoute:_responseTemplates_value": "@css:templates/identity/email-password/register-response.html.ejs"
},
"controls": {
"BasicInteractionRoute:_controls_key": "register",
"BasicInteractionRoute:_controls_value": "/register/"
},
"handler": {
"@type": "RelativeInteractionRoute",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": "/idp/register/",
"source": {
"@type": "RegistrationHandler",
"registrationManager": {
"@type": "RegistrationManager",
Expand Down
Loading

0 comments on commit bc0eeb1

Please sign in to comment.