Skip to content

Commit c85c1b4

Browse files
authored
Merge pull request #908 from neuroglia-io/fix-authentication-policy-reference
Changes the way authentication policies can be referenced
2 parents ffcf80b + d285bec commit c85c1b4

File tree

4 files changed

+109
-76
lines changed

4 files changed

+109
-76
lines changed

dsl-reference.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ do:
192192
method: post
193193
endpoint:
194194
uri: https://fake.smtp.service.com/email/send
195-
authentication: petStoreOAuth2
195+
authentication:
196+
use: petStoreOAuth2
196197
body:
197198
198199
to: ${ .order.client.email }
@@ -438,14 +439,24 @@ document:
438439
namespace: test
439440
name: do-example
440441
version: '0.1.0'
442+
use:
443+
authentications:
444+
fake-booking-agency-oauth2:
445+
oauth2:
446+
authority: https://fake-booking-agency.com
447+
grant: client_credentials
448+
client:
449+
id: serverless-workflow-runtime
450+
secret: secret0123456789
441451
do:
442452
- bookHotel:
443453
call: http
444454
with:
445455
method: post
446456
endpoint:
447457
uri: https://fake-booking-agency.com/hotels/book
448-
authentication: fake-booking-agency-oauth2
458+
authentication:
459+
use: fake-booking-agency-oauth2
449460
body:
450461
name: Four Seasons
451462
city: Antwerp
@@ -456,7 +467,8 @@ do:
456467
method: post
457468
endpoint:
458469
uri: https://fake-booking-agency.com/flights/book
459-
authentication: fake-booking-agency-oauth2
470+
authentication:
471+
use: fake-booking-agency-oauth2
460472
body:
461473
departure:
462474
date: '01/01/26'
@@ -1083,6 +1095,7 @@ Defines the mechanism used to authenticate users and workflows attempting to acc
10831095

10841096
| Property | Type | Required | Description |
10851097
|----------|:----:|:--------:|-------------|
1098+
| use | `string` | `no` | The name of the top-level authentication definition to use. Cannot be used by authentication definitions defined at top level. |
10861099
| basic | [`basicAuthentication`](#basic-authentication) | `no` | The `basic` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
10871100
| bearer | [`bearerAuthentication`](#bearer-authentication) | `no` | The `bearer` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
10881101
| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.<br>Required if no other property has been set, otherwise ignored. |
@@ -1102,15 +1115,17 @@ use:
11021115
- usernamePasswordSecret
11031116
authentication:
11041117
sampleBasicFromSecret:
1105-
basic: usernamePasswordSecret
1118+
basic:
1119+
use: usernamePasswordSecret
11061120
do:
11071121
- sampleTask:
11081122
call: http
11091123
with:
11101124
method: get
11111125
endpoint:
11121126
uri: https://secured.fake.com/sample
1113-
authentication: sampleBasicFromSecret
1127+
authentication:
1128+
use: sampleBasicFromSecret
11141129
```
11151130

11161131
#### Basic Authentication
@@ -1133,19 +1148,20 @@ document:
11331148
name: basic-authentication-example
11341149
version: '0.1.0'
11351150
use:
1136-
authentication:
1151+
authentications:
11371152
sampleBasic:
11381153
basic:
11391154
username: admin
1140-
password: 123
1155+
password: password123
11411156
do:
11421157
- sampleTask:
11431158
call: http
11441159
with:
11451160
method: get
11461161
endpoint:
11471162
uri: https://secured.fake.com/sample
1148-
authentication: sampleBasic
1163+
authentication:
1164+
use: sampleBasic
11491165
```
11501166

11511167
#### Bearer Authentication

dsl.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ When the evaluation of an expression fails, runtimes **must** raise an error wit
204204
|:-----|:----:|:------------|
205205
| context | `map` | The task's context data. |
206206
| input | `any` | The task's filtered input. |
207+
| secrets | `map` | A key/value map of the workflow secrets.<br>To avoid unintentional bleeding, secrets can only be used in the `input.from` runtime expression. |
207208
| task | [`taskDescriptor`](#task-descriptor) | Describes the current task. |
208209
| workflow | [`workflowDescritor`](#workflow-descriptor) | Describes the current workflow. |
209210

examples/use-authentication.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ do:
1515
method: get
1616
endpoint:
1717
uri: https://petstore.swagger.io/v2/pet/{petId}
18-
authentication: petStoreAuth
18+
authentication:
19+
use: petStoreAuth

schema/workflow.yaml

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,8 @@ $defs:
181181
type: object
182182
description: The payload to call the AsyncAPI operation with, if any.
183183
authentication:
184+
$ref: '#/$defs/referenceableAuthenticationPolicy'
184185
description: The authentication policy, if any, to use when calling the AsyncAPI operation.
185-
oneOf:
186-
- $ref: '#/$defs/authenticationPolicy'
187-
- type: string
188186
required: [ document, operationRef ]
189187
additionalProperties: false
190188
description: Defines the AsyncAPI call to perform.
@@ -220,10 +218,8 @@ $defs:
220218
max: 65535
221219
description: The port number of the GRPC service to call.
222220
authentication:
221+
$ref: '#/$defs/referenceableAuthenticationPolicy'
223222
description: The endpoint's authentication policy, if any.
224-
oneOf:
225-
- $ref: '#/$defs/authenticationPolicy'
226-
- type: string
227223
required: [ name, host ]
228224
method:
229225
type: string
@@ -293,10 +289,8 @@ $defs:
293289
additionalProperties: true
294290
description: A name/value mapping of the parameters of the OpenAPI operation to call.
295291
authentication:
292+
$ref: '#/$defs/referenceableAuthenticationPolicy'
296293
description: The authentication policy, if any, to use when calling the OpenAPI operation.
297-
oneOf:
298-
- $ref: '#/$defs/authenticationPolicy'
299-
- type: string
300294
output:
301295
type: string
302296
enum: [ raw, content, response ]
@@ -631,79 +625,104 @@ $defs:
631625
enum: [ continue, exit, end ]
632626
default: continue
633627
- type: string
628+
referenceableAuthenticationPolicy:
629+
type: object
630+
oneOf:
631+
- title: AuthenticationPolicyReference
632+
properties:
633+
use:
634+
type: string
635+
minLength: 1
636+
description: The name of the authentication policy to use
637+
required: [use]
638+
- $ref: '#/$defs/authenticationPolicy'
639+
secretBasedAuthenticationPolicy:
640+
type: object
641+
properties:
642+
use:
643+
type: string
644+
minLength: 1
645+
description: The name of the authentication policy to use
646+
required: [use]
634647
authenticationPolicy:
635648
type: object
636649
oneOf:
637650
- title: BasicAuthenticationPolicy
638651
properties:
639652
basic:
640653
type: object
641-
properties:
642-
username:
643-
type: string
644-
description: The username to use.
645-
password:
646-
type: string
647-
description: The password to use.
648-
required: [ username, password ]
654+
oneOf:
655+
- properties:
656+
username:
657+
type: string
658+
description: The username to use.
659+
password:
660+
type: string
661+
description: The password to use.
662+
required: [ username, password ]
663+
- $ref: '#/$defs/secretBasedAuthenticationPolicy'
649664
required: [ basic ]
650665
description: Use basic authentication.
651666
- title: BearerAuthenticationPolicy
652667
properties:
653668
bearer:
654669
type: object
655-
properties:
656-
token:
657-
type: string
658-
description: The bearer token to use.
659-
required: [ token ]
670+
oneOf:
671+
- properties:
672+
token:
673+
type: string
674+
description: The bearer token to use.
675+
required: [ token ]
676+
- $ref: '#/$defs/secretBasedAuthenticationPolicy'
660677
required: [ bearer ]
661678
description: Use bearer authentication.
662679
- title: OAuth2AuthenticationPolicy
663680
properties:
664681
oauth2:
665682
type: object
666-
properties:
667-
authority:
668-
type: string
669-
format: uri
670-
description: The URI that references the OAuth2 authority to use.
671-
grant:
672-
type: string
673-
description: The grant type to use.
674-
client:
675-
type: object
676-
properties:
677-
id:
683+
oneOf:
684+
- properties:
685+
authority:
678686
type: string
679-
description: The client id to use.
680-
secret:
687+
format: uri
688+
description: The URI that references the OAuth2 authority to use.
689+
grant:
681690
type: string
682-
description: The client secret to use, if any.
683-
required: [ id ]
684-
scopes:
685-
type: array
686-
items:
687-
type: string
688-
description: The scopes, if any, to request the token for.
689-
audiences:
690-
type: array
691-
items:
692-
type: string
693-
description: The audiences, if any, to request the token for.
694-
username:
695-
type: string
696-
description: The username to use. Used only if the grant type is Password.
697-
password:
698-
type: string
699-
description: The password to use. Used only if the grant type is Password.
700-
subject:
701-
$ref: '#/$defs/oauth2Token'
702-
description: The security token that represents the identity of the party on behalf of whom the request is being made.
703-
actor:
704-
$ref: '#/$defs/oauth2Token'
705-
description: The security token that represents the identity of the acting party.
706-
required: [ authority, grant, client ]
691+
description: The grant type to use.
692+
client:
693+
type: object
694+
properties:
695+
id:
696+
type: string
697+
description: The client id to use.
698+
secret:
699+
type: string
700+
description: The client secret to use, if any.
701+
required: [ id ]
702+
scopes:
703+
type: array
704+
items:
705+
type: string
706+
description: The scopes, if any, to request the token for.
707+
audiences:
708+
type: array
709+
items:
710+
type: string
711+
description: The audiences, if any, to request the token for.
712+
username:
713+
type: string
714+
description: The username to use. Used only if the grant type is Password.
715+
password:
716+
type: string
717+
description: The password to use. Used only if the grant type is Password.
718+
subject:
719+
$ref: '#/$defs/oauth2Token'
720+
description: The security token that represents the identity of the party on behalf of whom the request is being made.
721+
actor:
722+
$ref: '#/$defs/oauth2Token'
723+
description: The security token that represents the identity of the acting party.
724+
required: [ authority, grant, client ]
725+
- $ref: '#/$defs/secretBasedAuthenticationPolicy'
707726
required: [ oauth2 ]
708727
description: Use OAUTH2 authentication.
709728
description: Defines an authentication policy.
@@ -766,10 +785,8 @@ $defs:
766785
format: uri-template
767786
description: The endpoint's URI.
768787
authentication:
788+
$ref: '#/$defs/referenceableAuthenticationPolicy'
769789
description: The authentication policy to use.
770-
oneOf:
771-
- $ref: '#/$defs/authenticationPolicy'
772-
- type: string
773790
required: [ uri ]
774791
eventConsumptionStrategy:
775792
type: object
@@ -869,10 +886,8 @@ $defs:
869886
format: uri
870887
description: The endpoint's URI.
871888
authentication:
889+
$ref: '#/$defs/referenceableAuthenticationPolicy'
872890
description: The authentication policy to use.
873-
oneOf:
874-
- $ref: '#/$defs/authenticationPolicy'
875-
- type: string
876891
name:
877892
type: string
878893
description: The external resource's name, if any.

0 commit comments

Comments
 (0)