Skip to content

Commit e2121ea

Browse files
authored
Function Resource Auth (#408)
* [WIP] Function resource auth Signed-off-by: Tihomir Surdilovic <[email protected]> * update to auth schema Signed-off-by: Tihomir Surdilovic <[email protected]> * update to schema Signed-off-by: Tihomir Surdilovic <[email protected]> * update to schema Signed-off-by: Tihomir Surdilovic <[email protected]> * update to schema Signed-off-by: Tihomir Surdilovic <[email protected]> * update to schema Signed-off-by: Tihomir Surdilovic <[email protected]> * another update Signed-off-by: Tihomir Surdilovic <[email protected]> * update Signed-off-by: Tihomir Surdilovic <[email protected]> * update Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * fix unambiguous info Signed-off-by: Tihomir Surdilovic <[email protected]> * update auth schema per comments Signed-off-by: Tihomir Surdilovic <[email protected]> * added suggestions Signed-off-by: Tihomir Surdilovic <[email protected]> * finished spec doc info Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent b9af6cb commit e2121ea

File tree

5 files changed

+336
-16
lines changed

5 files changed

+336
-16
lines changed

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ _Status description:_
3535
| ✔️| Added support for Secrets and Constants | [spec doc](../specification.md) |
3636
| ✔️| Changed default value of execution timeout `interrupt` property. This is a non-backwards compatible changes. | [spec doc](../specification.md) |
3737
| ✔️| Updated workflow timeouts | [spec doc](../specification.md) |
38+
| ✔️| Added Workflow Auth definitions | [spec doc](../specification.md) |
3839
| 🚩 | Workflow invocation bindings | |
3940
| 🚩 | CE Subscriptions & Discovery | |
4041
| 🚩 | Error types | [issue](https://github.com/serverlessworkflow/specification/issues/200) |

schema/auth.json

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
{
2+
"$id": "https://serverlessworkflow.io/schemas/0.7/auth.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"description": "Serverless Workflow specification - auth schema",
5+
"type": "object",
6+
"auth": {
7+
"oneOf": [
8+
{
9+
"type": "string",
10+
"format": "uri",
11+
"description": "URI to a resource containing auth definitions (json or yaml)"
12+
},
13+
{
14+
"type": "array",
15+
"description": "Workflow auth definitions",
16+
"items": {
17+
"type": "object",
18+
"$ref": "#/definitions/authdef"
19+
},
20+
"additionalItems": false,
21+
"minItems": 1
22+
}
23+
]
24+
},
25+
"required": [
26+
"auth"
27+
],
28+
"definitions": {
29+
"authdef": {
30+
"type": "object",
31+
"properties": {
32+
"name": {
33+
"type": "string",
34+
"description": "Unique auth definition name",
35+
"minLength": 1
36+
},
37+
"scheme": {
38+
"type": "string",
39+
"description": "Defines the auth type",
40+
"enum": [
41+
"basic",
42+
"bearer",
43+
"oauth2"
44+
],
45+
"default": "basic"
46+
},
47+
"properties": {
48+
"oneOf": [
49+
{
50+
"type": "string",
51+
"description": "Expression referencing a workflow secret that contains all needed auth info"
52+
},
53+
{
54+
"title": "Basic Auth Info",
55+
"$ref": "#/definitions/basicpropsdef"
56+
},
57+
{
58+
"title": "Bearer Auth Info State",
59+
"$ref": "#/definitions/beareripropsdef"
60+
},
61+
{
62+
"title": "OAuth2 Info",
63+
"$ref": "#/definitions/oauth2propsdef"
64+
}
65+
]
66+
}
67+
},
68+
"required": [
69+
"name",
70+
"properties"
71+
]
72+
},
73+
"basicpropsdef": {
74+
"oneOf": [
75+
{
76+
"type": "string",
77+
"description": "Expression referencing a workflow secret that contains all needed basic auth info"
78+
},
79+
{
80+
"type": "object",
81+
"description": "Basic auth information",
82+
"properties": {
83+
"username": {
84+
"type": "string",
85+
"description": "String or a workflow expression. Contains the user name",
86+
"minLength": 1
87+
},
88+
"password": {
89+
"type": "string",
90+
"description": "String or a workflow expression. Contains the user password",
91+
"minLength": 1
92+
},
93+
"metadata": {
94+
"$ref": "common.json#/definitions/metadata"
95+
}
96+
},
97+
"required": [
98+
"username",
99+
"password"
100+
],
101+
"additionalProperties": false
102+
}
103+
]
104+
},
105+
"beareripropsdef": {
106+
"oneOf": [
107+
{
108+
"type": "string",
109+
"description": "Expression referencing a workflow secret that contains all needed bearer auth info"
110+
},
111+
{
112+
"type": "object",
113+
"description": "Bearer auth information",
114+
"properties": {
115+
"token": {
116+
"type": "string",
117+
"description": "String or a workflow expression. Contains the token",
118+
"minLength": 1
119+
},
120+
"metadata": {
121+
"$ref": "common.json#/definitions/metadata"
122+
}
123+
},
124+
"required": [
125+
"token"
126+
],
127+
"additionalProperties": false
128+
}
129+
]
130+
},
131+
"oauth2propsdef": {
132+
"oneOf": [
133+
{
134+
"type": "string",
135+
"description": "Expression referencing a workflow secret that contains all needed OAuth2 auth info"
136+
},
137+
{
138+
"type": "object",
139+
"description": "OAuth2 information",
140+
"properties": {
141+
"authority": {
142+
"type": "string",
143+
"description": "String or a workflow expression. Contains the authority information",
144+
"minLength": 1
145+
},
146+
"grantType": {
147+
"type": "string",
148+
"description": "Defines the grant type",
149+
"enum": [
150+
"password",
151+
"clientCredentials",
152+
"tokenExchange"
153+
],
154+
"additionalItems": false
155+
},
156+
"clientId": {
157+
"type": "string",
158+
"description": "String or a workflow expression. Contains the client identifier",
159+
"minLength": 1
160+
},
161+
"clientSecret": {
162+
"type": "string",
163+
"description": "Workflow secret or a workflow expression. Contains the client secret",
164+
"minLength": 1
165+
},
166+
"scopes": {
167+
"type": "array",
168+
"description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes",
169+
"items": {
170+
"type": "string"
171+
},
172+
"minItems": 1,
173+
"additionalItems": false
174+
},
175+
"username": {
176+
"type": "string",
177+
"description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'",
178+
"minLength": 1
179+
},
180+
"password": {
181+
"type": "string",
182+
"description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'",
183+
"minLength": 1
184+
},
185+
"audiences": {
186+
"type": "array",
187+
"description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences",
188+
"items": {
189+
"type": "string"
190+
},
191+
"minItems": 1,
192+
"additionalItems": false
193+
},
194+
"subjectToken": {
195+
"type": "string",
196+
"description": "String or a workflow expression. Contains the subject token",
197+
"minLength": 1
198+
},
199+
"requestedSubject": {
200+
"type": "string",
201+
"description": "String or a workflow expression. Contains the requested subject",
202+
"minLength": 1
203+
},
204+
"requestedIssuer": {
205+
"type": "string",
206+
"description": "String or a workflow expression. Contains the requested issuer",
207+
"minLength": 1
208+
},
209+
"metadata": {
210+
"$ref": "common.json#/definitions/metadata"
211+
}
212+
},
213+
"required": ["grantType", "clientId"]
214+
}
215+
]
216+
}
217+
}
218+
}

schema/functions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
"expression"
5050
],
5151
"default": "rest"
52+
},
53+
"authRef": {
54+
"type": "string",
55+
"description": "References an auth definition name to be used to access to resource defined in the operation parameter",
56+
"minLength": 1
57+
},
58+
"metadata": {
59+
"$ref": "common.json#/definitions/metadata"
5260
}
5361
},
5462
"additionalProperties": false,

schema/workflow.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
"retries": {
118118
"$ref": "retries.json#/retries"
119119
},
120+
"auth": {
121+
"$ref": "auth.json#/auth"
122+
},
120123
"states": {
121124
"type": "array",
122125
"description": "State definitions",

0 commit comments

Comments
 (0)