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
FieldsModifier and TypeFieldDescriptionNames of the parameters that carry a credential of a confidential client.private final org.springframework.security.web.util.matcher.RequestMatcherMatches the request for the codes, which names the client. -
Constructor Summary
ConstructorsConstructorDescriptionDeviceClientAuthenticationConverter(String deviceAuthorizationEndpoint) Creates the converter. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancarriesCredential(jakarta.servlet.http.HttpServletRequest request) Tells whether the request carries the credential of a confidential client.org.springframework.security.core.Authenticationconvert(jakarta.servlet.http.HttpServletRequest request) Reads the client of a request.private static booleanisDeviceCodePoll(jakarta.servlet.http.HttpServletRequest request) Tells whether the request is a poll of the token endpoint with the device code grant.private booleanisDeviceRequest(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.
-
Field Details
-
CREDENTIAL_PARAMETERS
Names of the parameters that carry a credential of a confidential client. -
deviceAuthorizationRequest
private final org.springframework.security.web.util.matcher.RequestMatcher deviceAuthorizationRequestMatches the request for the codes, which names the client.
-
-
Constructor Details
-
DeviceClientAuthenticationConverter
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:
convertin interfaceorg.springframework.security.web.authentication.AuthenticationConverter- Parameters:
request- the request.- Returns:
- the request to authenticate the public client, or
nullwhen the request is not one of the device flow's or carries a credential. - Throws:
org.springframework.security.oauth2.core.OAuth2AuthenticationException-invalid_requestif 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:
truefor 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:
truewhen 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:
truewhen it does.
-