Skip to content

Commit 258d04a

Browse files
authored
Merge pull request #643 from cdavernas/resource-and-invocation-auth
Resource and invocation authentication definition
2 parents c0e38bb + 90eb5a9 commit 258d04a

File tree

2 files changed

+79
-10
lines changed

2 files changed

+79
-10
lines changed

schema/functions.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,32 @@
5454
"default": "rest"
5555
},
5656
"authRef": {
57-
"type": "string",
58-
"description": "References an auth definition name to be used to access to resource defined in the operation parameter",
59-
"minLength": 1
57+
"oneOf": [
58+
{
59+
"type": "string",
60+
"description": "References the auth definition to be used to invoke the operation",
61+
"minLength": 1
62+
},
63+
{
64+
"type": "object",
65+
"description": "Configures both the auth definition used to retrieve the operation's resource and the auth definition used to invoke said operation",
66+
"properties":{
67+
"resource":{
68+
"type": "string",
69+
"description": "References an auth definition to be used to access the resource defined in the operation parameter",
70+
"minLength": 1
71+
},
72+
"invocation":{
73+
"type": "string",
74+
"description": "References an auth definition to be used to invoke the operation"
75+
}
76+
},
77+
"additionalProperties": false,
78+
"required": [
79+
"resource"
80+
]
81+
}
82+
]
6083
},
6184
"metadata": {
6285
"$ref": "common.json#/definitions/metadata"

specification.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,7 @@ If we have the following function definition:
19861986
```
19871987

19881988
The `authRef` property is used to reference an authentication definition in
1989-
the `auth` property and should be applied to access the `https://secure.resources.com/myapi.json`
1990-
OpenApi definition file.
1989+
the `auth` property and should be applied when invoking the `helloWorld` function. An [AuthRef](#AuthRef-Definition) object can alternatively be used to configure the authentication definition to use when accessing the function's resource and/or when invoking the function.
19911990

19921991
The `functions` property can be either an in-line [function](#Function-Definition) definition array, or an URI reference to
19931992
a resource containing an array of [functions](#Function-Definition) definition.
@@ -3248,7 +3247,7 @@ Depending on the function `type`, the `operation` property can be:
32483247
Defining custom function types is possible, for more information on that refer to the [Defining custom function types](#defining-custom-function-types) section.
32493248

32503249
The `authRef` property references a name of a defined workflow [auth definition](#Auth-Definition).
3251-
It is used to provide authentication info to access the resource defined in the `operation` property.
3250+
It is used to provide authentication info to access the resource defined in the `operation` property and/or to invoke the function.
32523251

32533252
The [`metadata`](#Workflow-Metadata) property allows users to define custom information to function definitions.
32543253
This allows you for example to define functions that describe of a command executions on a Docker image:
@@ -3266,6 +3265,55 @@ Note that using metadata for cases such as above heavily reduces the portability
32663265
Function definitions themselves do not define data input parameters. Parameters can be
32673266
defined via the `parameters` property in [function definitions](#FunctionRef-Definition) inside [actions](#Action-Definition).
32683267

3268+
###### AuthRef Definition
3269+
3270+
| Parameter | Description | Type | Required |
3271+
| --- | --- | --- | --- |
3272+
| resource | References an auth definition to be used to access the resource defined in the operation parameter | string | yes |
3273+
| invocation | References an auth definition to be used to invoke the operation | string | no |
3274+
3275+
The `authRef` property references a name of a defined workflow [auth definition](#Auth-Definition). It can be a string or an object.
3276+
3277+
If it's a string, the referenced [auth definition](#Auth-Definition) is used solely for the function's invocation.
3278+
3279+
If it's an object, it is possible to specify an [auth definition](#Auth-Definition) to use for the function's resource retrieval (as defined by the `operation` property) and another for its invocation.
3280+
3281+
Example of a function definition configured to use an [auth definition](#Auth-Definition) called "My Basic Auth" upon invocation:
3282+
3283+
```yaml
3284+
functions:
3285+
- name: SecuredFunctionInvocation
3286+
operation: https://test.com/swagger.json#HelloWorld
3287+
authRef: My Basic Auth
3288+
```
3289+
3290+
Example of a function definition configured to use an [auth definition](#Auth-Definition) called "My Basic Auth" to retrieve the resource defined by the `operation` property, and an [auth definition](#Auth-Definition) called "My OIDC Auth" upon invocation:
3291+
3292+
```yaml
3293+
functions:
3294+
- name: SecuredFunctionInvocation
3295+
operation: https://test.com/swagger.json#HelloWorld
3296+
authRef:
3297+
resource: My Basic Auth
3298+
invocation: My OIDC Auth
3299+
```
3300+
3301+
Note that if multiple functions share the same `operation` path (*which is the first component of the operation value, located before the first '#' character*), and if one of them defines an [auth definition](#Auth-Definition) for resource access, then it should always be used to access said resource.
3302+
In other words, when retrieving the resource of the function "MySecuredFunction2" defined in the following example, the "My Api Key Auth" [auth definition](#Auth-Definition) should be used, because the "MySecuredFunction1" has defined it for resource access.
3303+
This is done to avoid unnecessary repetitions of [auth definition](#Auth-Definition) configuration when using the same resource for multiple defined functions.
3304+
3305+
```yaml
3306+
functions:
3307+
- name: MySecuredFunction1
3308+
operation: https://secure.resources.com/myapi.json#helloWorld
3309+
authRef:
3310+
resource: My ApiKey Auth
3311+
- name: MySecuredFunction2
3312+
operation: https://secure.resources.com/myapi.json#holaMundo
3313+
```
3314+
3315+
It's worth noting that if an [auth definition](#Auth-Definition) has been defined for an OpenAPI function which's resource declare an authentication mechanism, the later should be used instead, thus ignoring entirely the [auth definition](#Auth-Definition).
3316+
32693317
##### Event Definition
32703318

32713319
| Parameter | Description | Type | Required |
@@ -3483,10 +3531,8 @@ If `false`, both Event payload and context attributes should be accessible.
34833531

34843532
##### Auth Definition
34853533

3486-
Auth definitions can be used to define authentication information that should be applied
3487-
to resources defined in the operation property of [function definitions](#Function-Definition).
3488-
It is not used as authentication information for the function invocation, but just to access
3489-
the resource containing the function invocation information.
3534+
Auth definitions can be used to define authentication information that should be applied to [function definitions](#Function-Definition).
3535+
It can be used for both the retrieval of the function's resource (as defined by the `operation` property) and for the function's invocation.
34903536

34913537
| Parameter | Description | Type | Required |
34923538
| --- | --- | --- | --- |

0 commit comments

Comments
 (0)