Skip to content

Make IDP response behaviour more similar to LDP handler? #722

Closed

Description

@jvherweg

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

  1. RubenVerborgh commented on May 5, 2021

    @RubenVerborgh
    Member

    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.

  2. jvherweg commented on May 21, 2021

    @jvherweg
    MemberAuthor

    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.

  3. jvherweg commented on Jun 1, 2021

    @jvherweg
    MemberAuthor

    Working on #749 made some of the issues here more clear.

    For each IDP HTTP handler we should have at least 3 components:

    • One for parsing the input data (so we can support both forms and json objects)
    • One for doing the relevant actions
    • One for handling the output

    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.

  4. jvherweg commented on Aug 18, 2021

    @jvherweg
    MemberAuthor

    Update: most of this has been done in #876 and #898.

    Remaining steps that should still be taken:

    • Have some kind of body parser that converts the input form data/json into an object accepted by the handlers. This would allow us to also accept JSON input
    • Split behaviour up into a few different classes instead of having everything in the IdentityProviderHttpHandler, Support content negotiation for IDP requests #898 already has some ideas.
    • Bonus: remove the empty error message and prefilled fields when doing a GET. Might actually not be that easy to do cleanly since the templates depend on them and come after generating the JSON response. One option would be to have the DynamicJsonToTemplateConverter (or its TemplateEngine) take a JSON object as input that it appends to the incoming parameters. This removes some of the flexibility though.
  5. jvherweg commented on Sep 8, 2021

    @jvherweg
    MemberAuthor

    Mostly done in #932. New issues should be made for new requirements when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions