Skip to content

Commit 5a83e70

Browse files
authored
Update readme (#17)
1 parent 66d788e commit 5a83e70

File tree

1 file changed

+109
-45
lines changed

1 file changed

+109
-45
lines changed

README.md

Lines changed: 109 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,55 @@
55
[![release](https://img.shields.io/github/release-pre/cloudentity/oauth2c.svg)](https://github.com/cloudentity/oauth2c/releases)
66
[![downloads](https://img.shields.io/github/downloads/cloudentity/oauth2c/total)](https://github.com/cloudentity/oauth2c/releases)
77

8-
User-friendly command-line client for OAuth2
8+
`oauth2c` is a command-line tool for authenticating with OAuth2 providers. It supports all modern OAuth2 grant types and client authentication methods, allowing users to easily authenticate and access an OAuth2 provider's API.
99

1010
![demo](https://user-images.githubusercontent.com/909896/176916616-36d803ef-832a-4bd8-ba8d-f6689e31ed22.gif)
1111

12+
## Features
13+
14+
* Supports all modern OAuth 2.0 grant types: authorization code, implicit, password, client credentials, refresh token, jwt bearer
15+
* Supports all client authentication methods: client secrets, private keys, client assertions, mtls
1216

1317
## Installation
1418

19+
To install `oauth2c`, simply run the following command:
20+
1521
``` sh
1622
curl -sSfL https://raw.githubusercontent.com/cloudentity/oauth2c/master/install.sh | \
1723
sudo sh -s -- -b /usr/local/bin latest
1824
```
1925

20-
Binaries are also available on the [releases page].
26+
Alternatively, you can download a pre-built binary from the [releases page].
2127

2228
[releases page]: https://github.com/cloudentity/oauth2c/releases
2329

2430
## Usage
2531

32+
To use `oauth2c`, simply run the following command and follow the prompts:
33+
2634
``` sh
27-
$ oauth2c -h
28-
User-friendly command-line for OAuth2
29-
30-
Usage:
31-
oauthc [issuer url or json config file] [flags]
32-
33-
Flags:
34-
--assertion string claims for jwt bearer assertion (standard claims such as iss, aud, iat, exp, jti are automatically generated)
35-
--auth-method string token endpoint authentication method
36-
--client-id string client identifier
37-
--client-secret string client secret
38-
--grant-type string grant type
39-
-h, --help help for oauthc
40-
--insecure allow insecure connections
41-
--no-pkce disable proof key for code exchange (PKCE)
42-
--password string resource owner password credentials grant flow password
43-
--pkce enable proof key for code exchange (PKCE)
44-
--refresh-token string refresh token
45-
--response-mode string response mode
46-
--response-types strings response type
47-
--scopes strings requested scopes
48-
--signing-key string path or url to signing key in jwks format
49-
--tls-cert string path to tls cert pem file
50-
--tls-key string path to tls key pem file
51-
--tls-root-ca string path to tls root ca pem file
52-
--username string resource owner password credentials grant flow username
35+
oauth2c [issuer url] [flags]
5336
```
5437

55-
> To make browser flows work add `http://localhost:9876/callback` redirect URL to your client.
38+
You will be asked to provide the necessary information, such as the grant type, client authentication method, and any other relevant details.
39+
40+
Once authenticated, you will be able to use the access token to access the OAuth2 provider's API.
41+
42+
> **Note**: To make browser flows work add `http://localhost:9876/callback` as a redirect URL to your client.
43+
44+
For more information on the available options and arguments for each grant type, run `oauth2c --help`.
45+
46+
## Examples
5647

57-
## Grant types
48+
Here are a few examples of using oauth2c with different grant types and client authentication methods:
5849

59-
### Authorization code
50+
### Grant types
51+
52+
#### Authorization code
53+
54+
This grant type involves a two-step process where the user first grants permission to access their data, and
55+
then the client exchanges the authorization code for an access token. This grant type is typically used
56+
in server-side applications.
6057

6158
``` sh
6259
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -70,7 +67,19 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
7067
--no-pkce
7168
```
7269

73-
### Authorization code + PKCE
70+
#### Authorization code + PKCE
71+
72+
The Proof Key for Code Exchange (PKCE) is an extension to the OAuth2 authorization code grant flow that
73+
provides additional security when authenticating with an OAuth2 provider. In the PKCE flow, the client
74+
generates a code verifier and a code challenge, which are then sent to the OAuth2 provider during
75+
the authorization request. The provider returns an authorization code, which the client then exchanges for
76+
an access token along with the code verifier. The provider verifies the code verifier to ensure that the
77+
request is coming from the same client that initiated the authorization request.
78+
79+
This additional step helps to prevent attackers from intercepting the authorization code and using it to
80+
obtain an access token. PKCE is recommended for all public clients, such as single-page or mobile
81+
applications, where the client secret cannot be securely stored. oauth2c supports PKCE as an optional
82+
parameter when using the authorization code grant type.
7483

7584
``` sh
7685
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -84,7 +93,13 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
8493
--pkce
8594
```
8695

87-
### Implicit
96+
#### Implicit
97+
98+
This grant type is similar to the authorization code grant, but the access token is returned directly to
99+
the client without an intermediate authorization code. This grant type is typically used in single-page or
100+
mobile applications.
101+
102+
> **Note**: The implicit flow is not recommended for use in modern OAuth2 applications. It does not provide a secure method for obtaining new access tokens. Instead, it is recommended to use the authorization code flow with PKCE (Proof Key for Code Exchange) for added security.
88103
89104
``` sh
90105
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -95,7 +110,13 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
95110
--scopes openid,email,offline_access
96111
```
97112

98-
### Hybrid
113+
#### Hybrid
114+
115+
To use the OAuth2 hybrid flow to obtain an authorization code and an ID token, the client first sends an authorization request to the OAuth2 provider. The request should include the client's ID, the desired response types.
116+
117+
The OAuth2 provider will then return an authorization code and an ID token to the client, either in the response body or as fragment parameters in the redirect URL, depending on the response mode specified in the request. The client can then use the authorization code to obtain an access token by sending a token request to the OAuth2 provider.
118+
119+
The ID token can be used to verify the identity of the authenticated user, as it contains information such as the user's name and email address. The ID token is typically signed by the OAuth2 provider, so the client can verify its authenticity using the provider's public key.
99120

100121
``` sh
101122
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -109,8 +130,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
109130
--no-pkce
110131
```
111132

133+
#### Client credentials
112134

113-
### Client credentials
135+
This grant type involves the client providing its own credentials (i.e. client ID and client secret) to
136+
the OAuth2 server, which then returns an access token. This grant type is typically used for
137+
server-to-server communication, where the client is a trusted server rather than a user.
114138

115139
``` sh
116140
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -122,9 +146,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
122146
```
123147

124148

125-
### Refresh token
149+
#### Refresh token
126150

127-
> For this flow request refresh token using `offline_access` scope first.
151+
This grant type involves the client providing a refresh token to the OAuth2 server, which then returns
152+
a new access token. This grant type is used to obtain new access tokens when the original access
153+
token has expired.
128154

129155
``` sh
130156
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -135,7 +161,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
135161
--refresh-token 1X1IvWR8p5rgKnH2YNmHGd4pZp8Dq-85xzUQuJejT_g.O_DS8Y4eiTS5jZ47_eBv3VbwP4zQUyxjNVW93AyU82k
136162
```
137163

138-
### Resource Owner Password Credentials Flow
164+
#### Password
165+
166+
This grant type involves the client providing the user's username and password to the OAuth2 server, which
167+
then returns an access token. This grant type should only be used in secure environments, as it involves
168+
sending the user's credentials to the OAuth2 server.
139169

140170
``` sh
141171
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -146,7 +176,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
146176
--scopes openid
147177
```
148178

149-
### JWT Bearer
179+
#### JWT Bearer
180+
181+
This grant type involves the client providing a JSON Web Token (JWT) to the OAuth2 server, which then returns
182+
an access token. This grant type is typically used when the client is a trusted third-party, such as a JWT
183+
issuer.
150184

151185
``` sh
152186
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -159,9 +193,13 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
159193
--assertion '{"sub":"[email protected]"}'
160194
```
161195

162-
## Auth methods
196+
### Auth methods
163197

164-
### Client Secret Basic
198+
#### Client Secret Basic
199+
200+
This client authentication method involves the client sending its client ID and client secret as part of the
201+
HTTP Basic authentication header in the request to the OAuth2 server. This method is simple and widely
202+
supported, but it is less secure than other methods because the client secret is sent in the clear.
165203

166204
``` sh
167205
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -172,7 +210,12 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
172210
--scopes introspect_tokens,revoke_tokens
173211
```
174212

175-
### Client Secret Post
213+
#### Client Secret Post
214+
215+
This client authentication method involves the client sending its client ID and client secret as part of
216+
the request body in the request to the OAuth2 server. This method provides more security than the
217+
basic authentication method, but it requires the request to be sent via HTTPS to prevent the client secret
218+
from being intercepted.
176219

177220
``` sh
178221
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -183,7 +226,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
183226
--scopes introspect_tokens,revoke_tokens
184227
```
185228

186-
### Client Secret JWT
229+
#### Client Secret JWT
230+
231+
This client authentication method involves the client signing a JSON Web Token (JWT) using its client secret,
232+
and then sending the JWT to the OAuth2 server. This method provides a higher level of security than the
233+
basic or post methods, as the client secret is never sent in the clear.
187234

188235
``` sh
189236
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -194,7 +241,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
194241
--scopes introspect_tokens,revoke_tokens
195242
```
196243

197-
### Private Key JWT
244+
#### Private Key JWT
245+
246+
This client authentication method involves the client signing a JSON Web Token (JWT) using its private key,
247+
and then sending the JWT to the OAuth2 server. This method provides a higher level of security than the
248+
JWT methods using a client secret, as the private key is never shared with the OAuth2 server.
198249

199250
``` sh
200251
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -205,7 +256,12 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
205256
--scopes introspect_tokens,revoke_tokens
206257
```
207258

208-
### TLS Client Auth
259+
#### TLS Client Auth
260+
261+
This client authentication method involves the client providing its own certificate as part of the TLS
262+
handshake when connecting to the OAuth2 server. This method provides a high level of security, as the
263+
client's identity is verified using a trusted certificate authority. However, it requires the OAuth2
264+
server to support TLS client authentication, which may not be supported by all OAuth2 providers.
209265

210266
``` sh
211267
oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
@@ -216,3 +272,11 @@ oauth2c https://oauth2c.us.authz.cloudentity.io/oauth2c/demo \
216272
--auth-method tls_client_auth \
217273
--scopes introspect_tokens,revoke_tokens
218274
```
275+
276+
## License
277+
278+
`oauth2c` is released under the [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0).
279+
280+
## Contributing
281+
282+
We welcome contributions! If you have an idea for a new feature or have found a bug, please open an issue on GitHub.

0 commit comments

Comments
 (0)