Repository navigation
Description
I have not fully worked this out yet, but it's something I started to think about when looking into how the render handlers work now in the IDP part for #721. I'm not even sure we actually want this yet.
Examples of current paths of a request in the IDP:
GET login: IdentityProviderHttpHandler -> IdpRouteController -> RenderEjsHandler
POST login: IdentityProviderHttpHandler -> IdpRouteController -> LoginHandler -> InteractionCompleter -> oidc library
What we could do instead:
GET: have RenderEjsHandler return a string/stream
POST: have LoginHandler return an object with the necessary information
Both of the above would then go back to the IdentityProviderHttpHandler which would then call its ResponseWriter with the result. Based on the result a different writer would be called: the default response writer for html, a specific oidc response writer which acts like the InteractionCompleter did above.
Another option for the GET would be to have the IdpRouteController return the parameters that are necessary for rendering the template and have a TemplateResponseWriter.
Advantages
This would reduce the complexity of the InteractionHttpHandler classes (such as LoginHandler): they would no longer have to be aware of the InteractionCompleter (constructor param) or the HttpResponse (handle param). If the form data gets passed somewhere inbetween they would also not have to be aware of the HttpRequest and could just take a Dict as input.
It would also direct all the response data to the same place (the IdentityProviderHttpHandler response writer), which might make debugging easier.
Disadvantages
RouterHandler would no longer be an HttpHandler since it returns output instead of completely handling the request/response, which might make the interface a bit weirder.
The returned values are more diverse than in the LDP case: both html strings (or template params) and objects for the interaction completer. This might make the typings of what gets returned quite vague.
Conclusion
I'm not really sure if this would be an improvement or not. It's just that I have a feeling something can be simplified in this process but I can't put my finger yet on what.
Activity
RubenVerborgh commentedon May 5, 2021
Also needs to be seen in the context of making the IDP part a machine-accessible API (think conneg etc.).
And at that point, the HTML code can maybe even be moved out into an app.
jvherweg commentedon May 21, 2021
Related: currently the interaction handlers also do the data parsing. This should be something like the body parser of LDP. That would allow us to more easily accept different input formats besides form data.
jvherweg commentedon Jun 1, 2021
Working on #749 made some of the issues here more clear.
For each IDP HTTP handler we should have at least 3 components:
One of the questions there is if for components 1 and 3 we want 1 component that can be re-used by all handlers, or if we need a different one for each of them. Since these components all expect different form data, the only way they could have the same parser would be if the parser returned a
Dict<string>object. The advantage is that this would be a single class, but the disdvantage is that there is no typing support there and the handlers still would have to do a lot of validation work on the input. E.g., the login handler still needs to check that the email address is present and a string, the registration handler still has to check that password and confirmPassword have the same values, etc.Similar for the output, several of these classes return a
Dict<string>that can be used to fill in an HTML template, but that way there are no typing checks again. There we also have some classes that don't need to render values, but instead need to call the oidc library to complete the login procedure.jvherweg commentedon Aug 18, 2021
Update: most of this has been done in #876 and #898.
Remaining steps that should still be taken:
DynamicJsonToTemplateConverter(or itsTemplateEngine) take a JSON object as input that it appends to the incoming parameters. This removes some of the flexibility though.jvherweg commentedon Sep 8, 2021
Mostly done in #932. New issues should be made for new requirements when needed.