java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttLinkFactory

@Component public final class OttLinkFactory extends Object
Builds the magic link of a token. It points at the confirmation page (GET /login/ott/confirm), whose button posts the token, and never at an endpoint that consumes it, so a mail scanner that opens the link does not use it up. The host is the configured issuer of this server, never the Host header of the request that asked for the link, which an attacker controls: a link built from it could carry the token of somebody else to another host.
  • Field Details

    • TOKEN_PARAMETER

      public static final String TOKEN_PARAMETER
      Name of the query parameter that carries the token.
      See Also:
    • issuer

      private final String issuer
      Public base URL of this server, the issuer of the tokens.
  • Constructor Details

    • OttLinkFactory

      public OttLinkFactory(org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings settings)
      Creates the factory.
      Parameters:
      settings - settings of the authorization server, whose issuer (spring.security.oauth2.authorizationserver.issuer) is the base of the links.
      Throws:
      IllegalStateException - if no issuer is configured: a link built from the request would trust its Host header.
  • Method Details

    • confirmationLink

      public URI confirmationLink(String tokenValue)
      Builds the link of a token.
      Parameters:
      tokenValue - value of the token.
      Returns:
      the link to the confirmation page.