Class DeviceClientAuthenticationConverter

java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.DeviceClientAuthenticationConverter
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationConverter

public class DeviceClientAuthenticationConverter extends Object implements org.springframework.security.web.authentication.AuthenticationConverter
Reads the identifier of a public client of the device flow, the only kind of client authentication that flow has for a device that cannot keep a secret: the client_id of the request to the device authorization endpoint and of the polling request to the token endpoint with the device code grant. Spring Authorization Server's public client authentication needs a PKCE code verifier, which the device flow does not have. A request that carries any other credential (an Authorization header, a client secret or a client assertion) is left to the converters of those credentials.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final List<String>
    Names of the parameters that carry a credential of a confidential client.
    private final org.springframework.security.web.util.matcher.RequestMatcher
    Matches the request for the codes, which names the client.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DeviceClientAuthenticationConverter(String deviceAuthorizationEndpoint)
    Creates the converter.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static boolean
    carriesCredential(jakarta.servlet.http.HttpServletRequest request)
    Tells whether the request carries the credential of a confidential client.
    org.springframework.security.core.Authentication
    convert(jakarta.servlet.http.HttpServletRequest request)
    Reads the client of a request.
    private static boolean
    isDeviceCodePoll(jakarta.servlet.http.HttpServletRequest request)
    Tells whether the request is a poll of the token endpoint with the device code grant.
    private boolean
    isDeviceRequest(jakarta.servlet.http.HttpServletRequest request)
    Tells whether the request is one of the device flow's: the request for the codes, or the poll with the device code grant.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CREDENTIAL_PARAMETERS

      private static final List<String> CREDENTIAL_PARAMETERS
      Names of the parameters that carry a credential of a confidential client.
    • deviceAuthorizationRequest

      private final org.springframework.security.web.util.matcher.RequestMatcher deviceAuthorizationRequest
      Matches the request for the codes, which names the client.
  • Constructor Details

    • DeviceClientAuthenticationConverter

      public DeviceClientAuthenticationConverter(String deviceAuthorizationEndpoint)
      Creates the converter.
      Parameters:
      deviceAuthorizationEndpoint - path of the device authorization endpoint.
  • Method Details

    • convert

      public org.springframework.security.core.Authentication convert(jakarta.servlet.http.HttpServletRequest request)
      Reads the client of a request.
      Specified by:
      convert in interface org.springframework.security.web.authentication.AuthenticationConverter
      Parameters:
      request - the request.
      Returns:
      the request to authenticate the public client, or null when the request is not one of the device flow's or carries a credential.
      Throws:
      org.springframework.security.oauth2.core.OAuth2AuthenticationException - invalid_request if the client is named more than once or not at all.
    • isDeviceRequest

      private boolean isDeviceRequest(jakarta.servlet.http.HttpServletRequest request)
      Tells whether the request is one of the device flow's: the request for the codes, or the poll with the device code grant.
      Parameters:
      request - the request.
      Returns:
      true for a device flow request that names a client.
    • isDeviceCodePoll

      private static boolean isDeviceCodePoll(jakarta.servlet.http.HttpServletRequest request)
      Tells whether the request is a poll of the token endpoint with the device code grant.
      Parameters:
      request - the request.
      Returns:
      true when it is.
    • carriesCredential

      private static boolean carriesCredential(jakarta.servlet.http.HttpServletRequest request)
      Tells whether the request carries the credential of a confidential client.
      Parameters:
      request - the request.
      Returns:
      true when it does.