Skip to content

Commit 677c334

Browse files
authored
Add support for none authentication method (#26)
1 parent e4e4a37 commit 677c334

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,16 @@ request is coming from the same client that initiated the authorization request.
124124

125125
This additional step helps to prevent attackers from intercepting the authorization code and using it to
126126
obtain an access token. PKCE is recommended for all public clients, such as single-page or mobile
127-
applications, where the client secret cannot be securely stored. oauth2c supports PKCE as an optional
128-
parameter when using the authorization code grant type.
127+
applications, where the client secret cannot be securely stored.
129128

130129
``` sh
131130
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
132-
--client-id cauktionbud6q8ftlqq0 \
133-
--client-secret HCwQ5uuUWBRHd04ivjX5Kl0Rz8zxMOekeLtqzki0GPc \
131+
--client-id db5e375e7b634095b24bbb683fcb955b \
134132
--response-types code \
135133
--response-mode query \
136134
--grant-type authorization_code \
137-
--auth-method client_secret_basic \
138-
--scopes openid,email,offline_access \
135+
--auth-method none \
136+
--scopes openid,email \
139137
--pkce
140138
```
141139

@@ -342,6 +340,23 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
342340

343341
[Learn more about tls client auth](https://cloudentity.com/developers/basics/oauth-client-authentication/oauth-mtls-client-authentication/)
344342

343+
#### None with PKCE
344+
345+
Public clients, such as mobile apps, are unable to authenticate themselves to the authorization server in the same way that confidential clients can because they do not have a client secret. To protect themselves from having their authorization codes intercepted and used by attackers, public clients can use PKCE (Proof Key for Code Exchange) during the authorization process. PKCE provides an additional layer of security by ensuring that the authorization code can only be exchanged for a token by the same client that initially requested it. This helps prevent unauthorized access to the token.
346+
347+
``` sh
348+
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
349+
--client-id db5e375e7b634095b24bbb683fcb955b \
350+
--response-types code \
351+
--response-mode query \
352+
--grant-type authorization_code \
353+
--auth-method none \
354+
--scopes openid,email \
355+
--pkce
356+
```
357+
358+
[Lean more about none with PKCE](https://cloudentity.com/developers/basics/oauth-client-authentication/client-auth-set-to-none-with-pkce/)
359+
345360
## License
346361

347362
`oauth2c` is released under the [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0).

internal/oauth2/oauth2.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
PrivateKeyJwtAuthMethod string = "private_key_jwt"
4242
SelfSignedTLSAuthMethod string = "self_signed_tls_client_auth"
4343
TLSClientAuthMethod string = "tls_client_auth"
44+
NoneAuthMethod string = "none"
4445
)
4546

4647
// client assertion types
@@ -276,6 +277,8 @@ func RequestToken(
276277
}
277278

278279
switch cconfig.AuthMethod {
280+
case NoneAuthMethod:
281+
request.Form.Set("client_id", cconfig.ClientID)
279282
case ClientSecretPostAuthMethod:
280283
request.Form.Set("client_id", cconfig.ClientID)
281284
request.Form.Set("client_secret", cconfig.ClientSecret)

0 commit comments

Comments
 (0)