Skip to content

Commit 52924df

Browse files
committed
- feat(Sdk): Added a new Metadata property to both WorkflowDefinition and TaskDefinition, addressing serverlessworkflow/specification#996
- feat(Sdk): Added a `Certificate`, `Digest` and `OIDC` authentication schemes, and updated the OAuth2AuthenticationSchemeDefinition, addressing serverlessworkflow/specification#973 Signed-off-by: Charles d'Avernas <[email protected]>
1 parent d5196bd commit 52924df

20 files changed

+454
-37
lines changed

src/ServerlessWorkflow.Sdk.Builders/WorkflowDefinitionBuilder.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public virtual IWorkflowDefinitionBuilder Do(string name, Action<IGenericTaskDef
241241
public virtual WorkflowDefinition Build()
242242
{
243243
if (string.IsNullOrWhiteSpace(this.Name)) throw new NullReferenceException("The workflow name must be set");
244+
if (string.IsNullOrWhiteSpace(this.Version)) throw new NullReferenceException("The workflow version must be set");
244245
if (this.Tasks == null || this.Tasks.Count < 1) throw new NullReferenceException("The workflow must define at least one task");
245246
return new()
246247
{
@@ -249,7 +250,7 @@ public virtual WorkflowDefinition Build()
249250
Dsl = DslVersion.V010,
250251
Namespace = string.IsNullOrWhiteSpace(this.Namespace) ? WorkflowDefinitionMetadata.DefaultNamespace : this.Namespace,
251252
Name = this.Name,
252-
Version = string.IsNullOrWhiteSpace(this.Version) ? "latest" : this.Version,
253+
Version = this.Version,
253254
Title = this.Title,
254255
Summary = this.Summary,
255256
Tags = this.Tags

src/ServerlessWorkflow.Sdk/AuthenticationScheme.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,21 @@ public static class AuthenticationScheme
2828
/// </summary>
2929
public const string Bearer = "Bearer";
3030
/// <summary>
31-
/// Gets the 'OAuth2' authentication scheme
31+
/// Gets the 'Certificate' authentication scheme
32+
/// </summary>
33+
public const string Certificate = "Certificate";
34+
/// <summary>
35+
/// Gets the 'Digest' authentication scheme
36+
/// </summary>
37+
public const string Digest = "Digest";
38+
/// <summary>
39+
/// Gets the 'OAUTH2' authentication scheme
3240
/// </summary>
3341
public const string OAuth2 = "OAuth2";
42+
/// <summary>
43+
/// Gets the 'OpenIDConnect' authentication scheme
44+
/// </summary>
45+
public const string OpenIDConnect = "OpenIDConnect";
3446

3547
/// <summary>
3648
/// Gets a new <see cref="IEnumerable{T}"/> containing the authentication schemes supported by default
@@ -40,7 +52,10 @@ public static IEnumerable<string> AsEnumerable()
4052
{
4153
yield return Basic;
4254
yield return Bearer;
55+
yield return Certificate;
56+
yield return Digest;
4357
yield return OAuth2;
58+
yield return OpenIDConnect;
4459
}
4560

4661
}

src/ServerlessWorkflow.Sdk/HttpOutputFormat.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,15 @@ public static class HttpOutputFormat
3434
/// </summary>
3535
public const string Response = "response";
3636

37-
}
37+
/// <summary>
38+
/// Gets a new <see cref="IEnumerable{T}"/> containing all supported values
39+
/// </summary>
40+
/// <returns>A new <see cref="IEnumerable{T}"/> containing all supported values</returns>
41+
public static IEnumerable<string> AsEnumerable()
42+
{
43+
yield return Raw;
44+
yield return Content;
45+
yield return Response;
46+
}
47+
48+
}

src/ServerlessWorkflow.Sdk/Models/Authentication/BearerAuthenticationSchemeDefinition.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ServerlessWorkflow.Sdk.Models.Authentication;
1818
/// </summary>
1919
[DataContract]
2020
public record BearerAuthenticationSchemeDefinition
21-
: AuthenticationSchemeDefinition
21+
: AuthenticationSchemeDefinition
2222
{
2323

2424
/// <inheritdoc/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models.Authentication;
15+
16+
/// <summary>
17+
/// Represents the definition of a certificate authentication scheme
18+
/// </summary>
19+
[DataContract]
20+
public record CertificateAuthenticationSchemeDefinition
21+
: AuthenticationSchemeDefinition
22+
{
23+
24+
/// <inheritdoc/>
25+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
26+
public override string Scheme => AuthenticationScheme.Certificate;
27+
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models.Authentication;
15+
16+
/// <summary>
17+
/// Represents the definition of a digest authentication scheme
18+
/// </summary>
19+
[DataContract]
20+
public record DigestAuthenticationSchemeDefinition
21+
: AuthenticationSchemeDefinition
22+
{
23+
24+
/// <inheritdoc/>
25+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
26+
public override string Scheme => AuthenticationScheme.Digest;
27+
28+
/// <summary>
29+
/// Gets/sets the username used for authentication
30+
/// </summary>
31+
[DataMember(Name = "username", Order = 1), JsonPropertyName("username"), JsonPropertyOrder(1), YamlMember(Alias = "username", Order = 1)]
32+
public required virtual string Username { get; set; }
33+
34+
/// <summary>
35+
/// Gets/sets the password used for authentication
36+
/// </summary>
37+
[DataMember(Name = "password", Order = 2), JsonPropertyName("password"), JsonPropertyOrder(2), YamlMember(Alias = "password", Order = 2)]
38+
public required virtual string Password { get; set; }
39+
40+
}

src/ServerlessWorkflow.Sdk/Models/Authentication/OAuth2AuthenticationClientDefinition.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,27 @@ public record OAuth2AuthenticationClientDefinition
2121
{
2222

2323
/// <summary>
24-
/// Gets/sets the OAUTH2 `client_id` to use
24+
/// Gets/sets the OAUTH2 `client_id` to use. Required if 'Authentication' has NOT been set to 'none'.
2525
/// </summary>
26-
[Required]
2726
[DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)]
28-
public required virtual string Id { get; set; }
27+
public virtual string? Id { get; set; }
2928

3029
/// <summary>
3130
/// Gets/sets the OAUTH2 `client_secret` to use, if any
3231
/// </summary>
3332
[DataMember(Name = "secret", Order = 2), JsonPropertyName("secret"), JsonPropertyOrder(2), YamlMember(Alias = "secret", Order = 2)]
3433
public virtual string? Secret { get; set; }
3534

36-
}
35+
/// <summary>
36+
/// Gets/sets a JWT containing a signed assertion with your application credentials
37+
/// </summary>
38+
[DataMember(Name = "assertion", Order = 3), JsonPropertyName("assertion"), JsonPropertyOrder(3), YamlMember(Alias = "assertion", Order = 3)]
39+
public virtual string? Assertion { get; set; }
40+
41+
/// <summary>
42+
/// Gets/sets the authentication method to use to authenticate the client. Defaults to 'client_secret_post'. See <see cref="OAuth2ClientAuthenticationMethod"/>
43+
/// </summary>
44+
[DataMember(Name = "authentication", Order = 4), JsonPropertyName("authentication"), JsonPropertyOrder(4), YamlMember(Alias = "authentication", Order = 4)]
45+
public virtual string? Authentication { get; set; }
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models.Authentication;
15+
16+
/// <summary>
17+
/// Represents the configuration of OAUTH2 endpoints
18+
/// </summary>
19+
[DataContract]
20+
public record OAuth2AuthenticationEndpointsDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets the relative path to the token endpoint. Defaults to `/oauth2/token`
25+
/// </summary>
26+
[Required]
27+
[DataMember(Name = "authority", Order = 1), JsonPropertyName("authority"), JsonPropertyOrder(1), YamlMember(Alias = "authority", Order = 1)]
28+
public virtual Uri Token { get; set; } = new("/oauth2/token");
29+
30+
/// <summary>
31+
/// Gets/sets the relative path to the revocation endpoint. Defaults to `/oauth2/revoke`
32+
/// </summary>
33+
[Required]
34+
[DataMember(Name = "revocation", Order = 2), JsonPropertyName("revocation"), JsonPropertyOrder(2), YamlMember(Alias = "revocation", Order = 2)]
35+
public virtual Uri Revocation { get; set; } = new("/oauth2/revoke");
36+
37+
/// <summary>
38+
/// Gets/sets the relative path to the introspection endpoint. Defaults to `/oauth2/introspect`
39+
/// </summary>
40+
[Required]
41+
[DataMember(Name = "introspection", Order = 3), JsonPropertyName("introspection"), JsonPropertyOrder(3), YamlMember(Alias = "introspection", Order = 3)]
42+
public virtual Uri Introspection { get; set; } = new("/oauth2/introspect");
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models.Authentication;
15+
16+
/// <summary>
17+
/// Represents the configuration of an OAUTH2 authentication request
18+
/// </summary>
19+
[DataContract]
20+
public record OAuth2AuthenticationRequestDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets the encoding of the authentication request. Defaults to 'application/x-www-form-urlencoded'. See <see cref="OAuth2RequestEncoding"/>
25+
/// </summary>
26+
public virtual string Encoding { get; set; } = OAuth2RequestEncoding.FormUrl;
27+
28+
}

src/ServerlessWorkflow.Sdk/Models/Authentication/OAuth2AuthenticationSchemeDefinition.cs

+29-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace ServerlessWorkflow.Sdk.Models.Authentication;
1515

1616
/// <summary>
17-
/// Represents the definition of an Open ID Connect authentication scheme
17+
/// Represents the definition of an OAUTH2 authentication scheme
1818
/// </summary>
1919
[DataContract]
2020
public record OAuth2AuthenticationSchemeDefinition
@@ -32,52 +32,70 @@ public record OAuth2AuthenticationSchemeDefinition
3232
public required virtual Uri Authority { get; set; }
3333

3434
/// <summary>
35-
/// Gets/sets the grant type to use
35+
/// Gets/sets the configuration of the OAUTH2 endpoints to use
3636
/// </summary>
37-
[DataMember(Name = "grant", Order = 2), JsonPropertyName("grant"), JsonPropertyOrder(2), YamlMember(Alias = "grant", Order = 2)]
37+
[DataMember(Name = "endpoints", Order = 2), JsonPropertyName("endpoints"), JsonPropertyOrder(2), YamlMember(Alias = "endpoints", Order = 2)]
38+
public virtual OAuth2AuthenticationEndpointsDefinition Endpoints { get; set; } = new();
39+
40+
/// <summary>
41+
/// Gets/sets the grant type to use. See <see cref="OAuth2GrantType"/>
42+
/// </summary>
43+
[DataMember(Name = "grant", Order = 3), JsonPropertyName("grant"), JsonPropertyOrder(3), YamlMember(Alias = "grant", Order = 3)]
3844
public required virtual string Grant { get; set; }
3945

4046
/// <summary>
4147
/// Gets/sets the definition of the client to use
4248
/// </summary>
43-
[DataMember(Name = "client", Order = 3), JsonPropertyName("client"), JsonPropertyOrder(3), YamlMember(Alias = "client", Order = 3)]
44-
public required virtual OAuth2AuthenticationClientDefinition Client { get; set; }
49+
[DataMember(Name = "client", Order = 4), JsonPropertyName("client"), JsonPropertyOrder(4), YamlMember(Alias = "client", Order = 4)]
50+
public virtual OAuth2AuthenticationClientDefinition? Client { get; set; }
51+
52+
/// <summary>
53+
/// Gets/sets the configuration of the authentication request to perform
54+
/// </summary>
55+
[DataMember(Name = "request", Order = 5), JsonPropertyName("request"), JsonPropertyOrder(5), YamlMember(Alias = "request", Order = 5)]
56+
public virtual OAuth2AuthenticationRequestDefinition Request { get; set; } = new();
57+
58+
/// <summary>
59+
/// Gets/sets a list, if any, that contains valid issuers that will be used to check against the issuer of generated tokens
60+
/// </summary>
61+
[DataMember(Name = "issuers", Order = 6), JsonPropertyName("issuers"), JsonPropertyOrder(6), YamlMember(Alias = "issuers", Order = 6)]
62+
public virtual EquatableList<string>? Issuers { get; set; }
4563

4664
/// <summary>
4765
/// Gets/sets the scopes, if any, to request the token for
4866
/// </summary>
49-
[DataMember(Name = "scopes", Order = 4), JsonPropertyName("scopes"), JsonPropertyOrder(4), YamlMember(Alias = "scopes", Order = 4)]
67+
[DataMember(Name = "scopes", Order = 7), JsonPropertyName("scopes"), JsonPropertyOrder(7), YamlMember(Alias = "scopes", Order = 7)]
5068
public virtual EquatableList<string>? Scopes { get; set; }
5169

5270
/// <summary>
5371
/// Gets/sets the audiences, if any, to request the token for
5472
/// </summary>
55-
[DataMember(Name = "audiences", Order = 5), JsonPropertyName("audiences"), JsonPropertyOrder(5), YamlMember(Alias = "audiences", Order = 5)]
73+
[DataMember(Name = "audiences", Order = 8), JsonPropertyName("audiences"), JsonPropertyOrder(8), YamlMember(Alias = "audiences", Order = 8)]
5674
public virtual EquatableList<string>? Audiences { get; set; }
5775

5876
/// <summary>
5977
/// Gets/sets the username to use. Used only if <see cref="Grant"/> is <see cref="OAuth2GrantType.Password"/>
6078
/// </summary>
61-
[DataMember(Name = "username", Order = 6), JsonPropertyName("username"), JsonPropertyOrder(6), YamlMember(Alias = "username", Order = 6)]
79+
[DataMember(Name = "username", Order = 9), JsonPropertyName("username"), JsonPropertyOrder(9), YamlMember(Alias = "username", Order = 9)]
6280
public virtual string? Username { get; set; }
6381

6482
/// <summary>
6583
/// Gets/sets the password to use. Used only if <see cref="Grant"/> is <see cref="OAuth2GrantType.Password"/>
6684
/// </summary>
67-
[DataMember(Name = "password", Order = 7), JsonPropertyName("password"), JsonPropertyOrder(7), YamlMember(Alias = "password", Order = 7)]
85+
[DataMember(Name = "password", Order = 10), JsonPropertyName("password"), JsonPropertyOrder(10), YamlMember(Alias = "password", Order = 10)]
6886
public virtual string? Password { get; set; }
6987

7088
/// <summary>
7189
/// Gets/sets the security token that represents the identity of the party on behalf of whom the request is being made. Used only if <see cref="Grant"/> is <see cref="OAuth2GrantType.TokenExchange"/>, in which case it is required
7290
/// </summary>
73-
[DataMember(Name = "subject", Order = 8), JsonPropertyName("subject"), JsonPropertyOrder(8), YamlMember(Alias = "subject", Order = 8)]
91+
[DataMember(Name = "subject", Order = 11), JsonPropertyName("subject"), JsonPropertyOrder(11), YamlMember(Alias = "subject", Order = 11)]
7492
public virtual OAuth2TokenDefinition? Subject { get; set; }
7593

7694
/// <summary>
7795
/// Gets/sets the security token that represents the identity of the acting party. Typically, this will be the party that is authorized to use the requested security token and act on behalf of the subject.
7896
/// Used only if <see cref="Grant"/> is <see cref="OAuth2GrantType.TokenExchange"/>, in which case it is required
7997
/// </summary>
80-
[DataMember(Name = "actor", Order = 9), JsonPropertyName("actor"), JsonPropertyOrder(9), YamlMember(Alias = "actor", Order = 9)]
98+
[DataMember(Name = "actor", Order = 12), JsonPropertyName("actor"), JsonPropertyOrder(12), YamlMember(Alias = "actor", Order = 12)]
8199
public virtual OAuth2TokenDefinition? Actor { get; set; }
82100

83101
}

0 commit comments

Comments
 (0)