Client Authentication Set to None and With Use of PKCE
Description of client authentication set to none and with the use of PKCE.
None Client Authentication with PKCE
Client authentication set to none and with the use of Proof Key of Code Exchange (PKCE) was created as a secure substitute for the OAuth implicit flow, where the client receives access tokens as the result of authorization.
Security Recommendation
Any public client should use the client authentication method set to none and utilize the proof key of code exchange (PKCE).
Public clients, like mobile applications or JavaScript-based applications, by their design, cannot store client secrets securely. For such clients, even encrypting the client secret inside the application's code is not a reliable way of protecting secrets as the application can be decompiled and the client secret can be extracted while it is decrypted in the memory of the application.
To know more about the implicit grant flow and the threats that come with it, read the following documents:
RFC6749, section 10.16 - it explains the potential misuse of access tokens to impersonate the resource owner in implicit flow.
OAuth 2.0 Security Best Current Practice, section 2.1.2 - it provides security best practices and recommendations for the implicit grant.
Prerequisites to Using None Client Authentication and PKCE
How None and PKCE Works
The client creates a secret named
code_verifier.A
code_verifiersecret is a high-entropy cryptographic random string with a minimum length of 43 characters and a maximum length of 128 characters.The client transforms
code_verifierusing itst_mtransform method. Thet_mmethod is a method used for transformingcode_verifier. It can beS256orplainaccording to the PKCE RFC 7636, section 4.2.In
plainthe transformation looks as follows:code_challenge = code_verifier
In
S256the transformation looks as follows:code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))
The
plaintransform method is not recommended and should only be used by clients that are unable to support theS256method. It is available only for compatibility with existing deployments and for constrained environments.The
S256method is Mandatory To Implement (MTI) for clients that are capable of using it.Result:
t(code_verifier)(also calledcode_challange) version ofcode_verifieris created.Note
t(code_verifier)is a transformed version of thecode_verifierfrom the first step of the process. It is sent as a part of the authorization request along with the transformation method.The client requests authorization from the authorization server using the authorize endpoint and provides both
t(code_verifier)and thet_mfrom the previous steps in the request.The authorization server responds with requested authorization and records both
t(code_verifier)andt_mparameters.The client makes a request for an access token to the authorization server's token endpoint and includes the
code_challangeandcode_challenge_methodform parameters.See the following request example (extra line breaks are added for display purposes):
curl --request -F "grant_type=client_credentials" -F "code_challenge=yRm6bQ0TxlBdZXwHzxg.eCT.ik6OL3Ggbf0gIybj6Txz03A4gQtowMrVJ_ oqq62falqYZs6Wqdchl1y5wtUmWwANUqRjtt4qaVrNZe5.~oig2HW0K5FF8KaPdzwk7Xz-" -F "code_challenge_method=xSc4hLkNSQE053N7KaZUBc6g97t4bKgsYzfOsk3m9e0" POST \ --url <https://localhost:8443/{tid}/{aid}/oauth2/token> \ --header 'accept: application/x-www-form-urlencoded'The authorization server transforms the provided
code_verifiersecret using thet_mmethod provided earlier and checks if the resultingcode_challengeis the same as thet(code_verifier)transformed secret from the request to theauthorizeendpoint.Result: The client is authenticated using the client authentication method set to none and with the use of PKCE.