Skip to content

Commit 1827680

Browse files
authored
Merge pull request serverlessworkflow#973 from neuroglia-io/feat-oidc-authentication
Refactor OAuth2 and add OIDC authentication policy
2 parents 63c35fd + b025520 commit 1827680

File tree

4 files changed

+296
-65
lines changed

4 files changed

+296
-65
lines changed

dsl-reference.md

+102-9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [Certificate](#certificate-authentication)
3838
- [Digest](#digest-authentication)
3939
- [OAUTH2](#oauth2-authentication)
40+
- [OpenIdConnect](#openidconnect-authentication)
4041
+ [Extension](#extension)
4142
+ [Error](#error)
4243
- [Standard Error Types](#standard-error-types)
@@ -148,7 +149,7 @@ use:
148149
petStoreOAuth2:
149150
oauth2:
150151
authority: https://petstore.swagger.io/.well-known/openid-configuration
151-
grant: client-credentials
152+
grant: client_credentials
152153
client:
153154
id: workflow-runtime
154155
secret: "**********"
@@ -1111,6 +1112,7 @@ Defines the mechanism used to authenticate users and workflows attempting to acc
11111112
| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
11121113
| digest | [`digestAuthentication`](#digest-authentication) | `no` | The `digest` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
11131114
| oauth2 | [`oauth2`](#oauth2-authentication) | `no` | The `oauth2` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
1115+
| oidc | [`oidc`](#openidconnect-authentication) | `no` | The `oidc` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
11141116

11151117
##### Examples
11161118

@@ -1209,19 +1211,59 @@ do:
12091211

12101212
#### Digest Authentication
12111213

1214+
Defines the fundamentals of a 'digest' authentication.
1215+
1216+
##### Properties
1217+
1218+
| Property | Type | Required | Description |
1219+
|----------|:----:|:--------:|-------------|
1220+
| username | `string` | `yes` | The username to use. |
1221+
| password | `string` | `yes` | The password to use. |
1222+
1223+
##### Examples
1224+
1225+
```yaml
1226+
document:
1227+
dsl: '1.0.0-alpha1'
1228+
namespace: test
1229+
name: digest-authentication-example
1230+
version: '0.1.0'
1231+
use:
1232+
authentications:
1233+
sampleDigest:
1234+
digest:
1235+
username: admin
1236+
password: password123
1237+
do:
1238+
- sampleTask:
1239+
call: http
1240+
with:
1241+
method: get
1242+
endpoint:
1243+
uri: https://secured.fake.com/sample
1244+
authentication:
1245+
use: sampleDigest
1246+
```
12121247

12131248
#### OAUTH2 Authentication
12141249

1215-
Defines the fundamentals of an 'oauth2' authentication
1250+
Defines the fundamentals of an 'oauth2' authentication.
12161251

12171252
##### Properties
12181253

1219-
| Property | Type | Required | Description |
1220-
|----------|:----:|:--------:|-------------|
1221-
| authority | [`uri-template`](#uri-template) | `yes` | The URI that references the OAuth2 authority to use. |
1222-
| grant | `string` | `yes` | The grant type to use. |
1223-
| client.id | `string` | `yes` | The client id to use. |
1254+
| Name | Type | Required | Description |
1255+
|:-----|:----:|:--------:|:------------|
1256+
| authority | `uri-template` | `yes` | The URI that references the authority to use when making OAuth2 calls. |
1257+
| endpoints.token | `uri-template` | `no` | The relative path to the endpoint for OAuth2 token requests.<br>Defaults to `/oauth2/token`. |
1258+
| endpoints.revocation | `uri-template` | `no` | The relative path to the endpoint used to invalidate tokens.<br>Defaults to `/oauth2/revoke`. |
1259+
| endpoints.introspection | `uri-template` | `no` | The relative path to the endpoint used to validate and obtain information about a token, typically to check its validity and associated metadata.<br>Defaults to `/oauth2/introspect`. |
1260+
| grant | `string` | `yes` | The grant type to use.<br>Supported values are `authorization_code`, `client_credentials`, `password`, `refresh_token` and `urn:ietf:params:oauth:grant-type:token-exchange`. |
1261+
| client.id | `string` | `no` | The client id to use.<br>Required if the `client.authentication` method has **not** been set to `none`. |
12241262
| client.secret | `string` | `no` | The client secret to use, if any. |
1263+
| client.assertion | `string` | `no` | A JWT containing a signed assertion with your application credentials.<br>Required when `client.authentication` has been set to `private_key_jwt`. |
1264+
| client.authentication | `string` | `no` | The client authentication method to use.<br>Supported values are `client_secret_basic`, `client_secret_post`, `client_secret_jwt`, `private_key_jwt` or `none`.<br>Defaults to `client_secret_post`. |
1265+
| request.encoding | `string` | `no` | The encoding of the token request.<br>Supported values are `application/x-www-form-urlencoded` and `application/json`.<br>Defaults to application/x-www-form-urlencoded. |
1266+
| issuers | `uri-template[]` | `no` | A list that contains that contains valid issuers that will be used to check against the issuer of generated tokens. |
12251267
| scopes | `string[]` | `no` | The scopes, if any, to request the token for. |
12261268
| audiences | `string[]` | `no` | The audiences, if any, to request the token for. |
12271269
| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. |
@@ -1246,8 +1288,10 @@ do:
12461288
uri: https://secured.fake.com/sample
12471289
authentication:
12481290
oauth2:
1249-
authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration
1250-
grant: client-credentials
1291+
authority: http://keycloak/realms/fake-authority
1292+
endpoints:
1293+
token: /oauth2/token
1294+
grant: client_credentials
12511295
client:
12521296
id: workflow-runtime
12531297
secret: "**********"
@@ -1266,6 +1310,55 @@ Represents the definition of an OAUTH2 token
12661310
| token | `string` | `yes` | The security token to use to use. |
12671311
| type | `string` | `yes` | The type of security token to use. |
12681312

1313+
#### OpenIdConnect Authentication
1314+
1315+
Defines the fundamentals of an 'oidc' authentication.
1316+
1317+
##### Properties
1318+
1319+
| Name | Type | Required | Description |
1320+
|:-----|:----:|:--------:|:------------|
1321+
| authority | `uri-template` | `yes` | The URI that references the authority to use when making OpenIdConnect calls. |
1322+
| grant | `string` | `yes` | The grant type to use.<br>Supported values are `authorization_code`, `client_credentials`, `password`, `refresh_token` and `urn:ietf:params:oauth:grant-type:token-exchange`. |
1323+
| client.id | `string` | `no` | The client id to use.<br>Required if the `client.authentication` method has **not** been set to `none`. |
1324+
| client.secret | `string` | `no` | The client secret to use, if any. |
1325+
| client.assertion | `string` | `no` | A JWT containing a signed assertion with your application credentials.<br>Required when `client.authentication` has been set to `private_key_jwt`. |
1326+
| client.authentication | `string` | `no` | The client authentication method to use.<br>Supported values are `client_secret_basic`, `client_secret_post`, `client_secret_jwt`, `private_key_jwt` or `none`.<br>Defaults to `client_secret_post`. |
1327+
| request.encoding | `string` | `no` | The encoding of the token request.<br>Supported values are `application/x-www-form-urlencoded` and `application/json`.<br>Defaults to application/x-www-form-urlencoded. |
1328+
| issuers | `uri-template[]` | `no` | A list that contains that contains valid issuers that will be used to check against the issuer of generated tokens. |
1329+
| scopes | `string[]` | `no` | The scopes, if any, to request the token for. |
1330+
| audiences | `string[]` | `no` | The audiences, if any, to request the token for. |
1331+
| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. |
1332+
| password | `string` | `no` | The password to use. Used only if the grant type is `Password`. |
1333+
| subject | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the party on behalf of whom the request is being made. |
1334+
| actor | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the acting party. |
1335+
1336+
##### Examples
1337+
1338+
```yaml
1339+
document:
1340+
dsl: '1.0.0-alpha1'
1341+
namespace: test
1342+
name: oidc-authentication-example
1343+
version: '0.1.0'
1344+
do:
1345+
- sampleTask:
1346+
call: http
1347+
with:
1348+
method: get
1349+
endpoint:
1350+
uri: https://secured.fake.com/sample
1351+
authentication:
1352+
oidc:
1353+
authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration
1354+
grant: client_credentials
1355+
client:
1356+
id: workflow-runtime
1357+
secret: "**********"
1358+
scopes: [ api ]
1359+
audiences: [ runtime ]
1360+
```
1361+
12691362
### Extension
12701363

12711364
Holds the definition for extending functionality, providing configuration options for how an extension extends and interacts with other components.

examples/oauth2.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
document:
2+
dsl: 1.0.0-alpha1
3+
namespace: examples
4+
name: oauth2-authentication
5+
version: 1.0.0-alpha1
6+
do:
7+
- getPet:
8+
call: http
9+
with:
10+
method: get
11+
endpoint:
12+
uri: https://petstore.swagger.io/v2/pet/{petId}
13+
authentication:
14+
oauth2:
15+
authority: http://keycloak/realms/fake-authority
16+
endpoints: #optional
17+
token: /auth/token #defaults to /oauth2/token
18+
introspection: /auth/introspect #defaults to /oauth2/introspect
19+
grant: client_credentials
20+
client:
21+
id: workflow-runtime-id
22+
secret: workflow-runtime-secret

examples/oidc.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
document:
2+
dsl: 1.0.0-alpha1
3+
namespace: examples
4+
name: oidc-authentication
5+
version: 1.0.0-alpha1
6+
do:
7+
- getPet:
8+
call: http
9+
with:
10+
method: get
11+
endpoint:
12+
uri: https://petstore.swagger.io/v2/pet/{petId}
13+
authentication:
14+
oidc:
15+
authority: http://keycloak/realms/fake-authority #endpoints are resolved using the OIDC configuration located at '/.well-known/openid-configuration'
16+
grant: client_credentials
17+
client:
18+
id: workflow-runtime-id
19+
secret: workflow-runtime-secret

0 commit comments

Comments
 (0)