Skip to content

Commit 441c129

Browse files
authored
Merge pull request #26 from willstranton/master
Add documentation for all module config directives
2 parents 82fe1f9 + 27df9c8 commit 441c129

File tree

1 file changed

+106
-17
lines changed

1 file changed

+106
-17
lines changed

README.md

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,120 @@ User Info endpoint.
88

99
## Configuration
1010

11-
TODO
11+
The following module directives are set under an NGINX `location` block.
1212

13-
`OpenIDCProvider`
14-
Configures the OpenID Connect Provider settings.
13+
### OpenIDCProvider
1514

16-
`OpenIDCClient`
17-
Configures the OpenID Connect Client settings.
15+
`OpenIDCProvider (file|string|url) <provider-config-json> [session=<session-cookie-name>];`
1816

19-
`OpenIDCClaim`
20-
Populates configuration variables based on available claims.
17+
Configures the OpenID Connect Provider config. The `provider-config-json` can be provided as a local `file`, a `string` containing the JSON object, or a `url` to the JSON config. Identity providers supporting discovery will have this JSON config available under the path `/.well-known/openid-configuration`.
2118

22-
`OpenIDCCryptoPassphrase`
23-
Set the passphrase used for encryption of cache, cookies, state etc.
19+
Example:
2420

25-
`OpenIDCCache`
26-
Configures a (default or named) cache backend.
21+
```
22+
# 3 different ways to provide the config:
23+
OpenIDCProvider file /etc/nginx/conf.d/provider.json;
24+
OpenIDCProvider string '{"issuer":"https://keycloak.example.com", ...}';
25+
OpenIDCProvider url https://accounts.google.com/.well-known/openid-configuration;
26+
```
2727

28-
`OpenIDCSession`
29-
Configures the session type and options, e.g. cache/cookie, session duration, etc.
28+
### OpenIDCClient
3029

31-
`OpenIDCConfig`
32-
Configures global setting such as redirect URI, etc.
30+
`OpenIDCClient (string|json|file) <client-config> [ssl_verify=on|off];`
3331

34-
```nginx
35-
```
32+
Configures the OpenID Connect Client settings. The `client-config` can be provided as a `string` that is form-encoded (eg. `key1=value1&key2=value2`), a `json` string, or a local `file` containing a JSON object. The keys that are required to be set in the config are:
33+
34+
* `client_id` - the client identifier
35+
* `client_secret` - the client password for authentication
36+
* `scope` - request that specific sets of information be made available as Claim Values. Multiple scope values are space-delimited. OpenID Connect requests MUST contain the `openid` scope value.
37+
* `token_endpoint_auth_method` - how the client should authenticate. Supported values are: `none`, `client_secret_basic`, `client_secret_post`, `client_secret_jwt`, `private_key_jwt`, `client_cert`, `basic`.
38+
39+
Example:
40+
```
41+
# 3 different ways to provide the client settings:
42+
OpenIDCClient string client_id=myapp&client_secret=3GrV8... ssl_verify=off;
43+
OpenIDCClient json '{"client_id": "myapp", "client_secret": "3GrV8...", ...}' ssl_verify=off;
44+
OpenIDCClient file /etc/nginx/conf.d/client.json ssl_verify=off;
45+
```
46+
47+
### OpenIDCClaim
48+
49+
`OpenIDCClaim <claim-name> $<variable-name>;`
50+
51+
Populates configuration variables based on available claims from the [ID token](https://openid.net/specs/openid-connect-core-1_0.html#IDToken). Refer to your provider's documentation for the available fields/claims available. Each line of `OpenIDCClaim` maps one claim to one variable (i.e. to map 3 variables, you will need 3 config lines).
52+
53+
Example:
54+
```
55+
# Mapping three different claims:
56+
OpenIDCClaim iss $pfc_claim_iss;
57+
OpenIDCClaim sub $pfc_claim_sub;
58+
OpenIDCClaim aud $pfc_claim_aud;
59+
```
60+
61+
### OpenIDCCryptoPassphrase
62+
63+
`OpenIDCCryptoPassphrase <passphrase>;`
64+
65+
Set the passphrase used for encryption of cache, cookies, state etc. Optional - if a passphrase isn't set, a random passphrase will be generated each time the NGINX server is started.
66+
67+
Example:
68+
```
69+
OpenIDCCryptoPassphrase fde1afb7063f;
70+
```
71+
72+
### OpenIDCCache
73+
74+
`OpenIDCCache <shm|file|redis|memcache> [form-encoded-options];`
75+
76+
Configures a (default or named) cache backend. Optional - defaults to `shm`. Form-encoded options include:
77+
78+
* `key_hash_algo` - a supported OpenSSL digest algorithm. Defaults to `sha256`.
79+
* `passphrase_hash_algo` - a supported OpenSSL digest algorithm. Defaults to `sha256`.
80+
* `encrypt` - whether to encrypt or not. Set to `true` to encrypt.
81+
82+
Example:
83+
```
84+
OpenIDCCache shm key_hash_algo=sha256&passphrase_hash_algo=sha256&encrypt=false;
85+
```
86+
87+
### OpenIDCSession
88+
89+
`OpenIDCSession <cookie|cache> [form-encoded-options];`
90+
91+
Configures the session type and options, e.g. cache/cookie, session duration, etc. Optional, defaults to `cookie`. Form-encoded options include:
92+
93+
* `cookie.name` - defaults to `openidc_session`
94+
* `cookie.path` - defaults to `/`
95+
* `max_duration` - defaults to 28800 seconds (8 hours)
96+
* `inactivity_timeout` - defaults to 300 seconds (5 minutes)
97+
98+
Example:
99+
```
100+
OpenIDCSession cookie cookie.name=openidc_session&cookie.path=/&max_duration=28800&inactivity_timeout=300;
101+
```
102+
103+
### OpenIDCConfig
104+
105+
`OpenIDCConfig <form-encoded-options>;`
106+
107+
Configures global setting such as redirect URI, etc. Options include:
108+
109+
* `handler_path` - defaults to `/openid-connect`
110+
* `redirect_uri` - the uri to redirect to after authenticating on the identity provider. Defaults to `$handler_path` + `/redirect_uri`
111+
* `state.cookie.name.prefix` - defaults to `openidc_state_`
112+
* `state.cookie.timeout` - defaults to 300 seconds (5 minutes)
113+
* `state.cookie.max` - defaults to 6
114+
* `state.cookie.delete.oldest` - defaults to false
115+
* `unauth_action` - Defines the action to be taken when an unauthenticated request is made. Defaults to `auth`. Available values:
116+
* `auth` - user is redirected to the OpenID Connect Provider or Discovery page.
117+
* `pass` - unauthenticated request will pass but claims will still be passed when a user happens to be authenticated already
118+
* `401` - HTTP 401 Unauthorized is returned
119+
* `410` - HTTP 410 Gone is returned
120+
121+
Example:
122+
```
123+
OpenIDCConfig handler_path=/openid-connect&redirect_uri=/redirect_uri;
124+
```
36125

37126
## Samples
38127

0 commit comments

Comments
 (0)