Skip to content

Commit 7b20d45

Browse files
committed
fix(Sdk): Fixed the IOAuth2AthenticationBuilder and implementation to reflect latest changes made to the OAuth2AuthenticationProperties
1 parent 47d5675 commit 7b20d45

File tree

6 files changed

+110
-71
lines changed

6 files changed

+110
-71
lines changed

src/ServerlessWorkflow.Sdk.UnitTests/Resources/workflows/operation.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"type": "operation",
3535
"actions": [
3636
{
37-
"name": "Function",
37+
"name": "Function1",
3838
"functionRef": {
3939
"refName": "Function",
4040
"arguments": {
@@ -43,7 +43,7 @@
4343
}
4444
},
4545
{
46-
"name": "Function",
46+
"name": "Function2",
4747
"eventRef": {
4848
"triggerEventRef": "ProducedEvent",
4949
"resultEventRef": "ConsumedEvent"

src/ServerlessWorkflow.Sdk/Models/OAuth2AuthenticationProperties.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ public class OAuth2AuthenticationProperties
114114
public virtual string? SubjectToken { get; set; }
115115

116116
/// <summary>
117-
/// Gets/sets an identifier, as described in Section 3, that indicates the type of the security token in the "subject_token" parameter.
117+
/// Gets/sets an identifie that indicates the type of the security token in the "subject_token" parameter.
118118
/// </summary>
119119
[Newtonsoft.Json.JsonProperty("subject_token_type")]
120120
[System.Text.Json.Serialization.JsonPropertyName("subject_token_type")]
121121
[ProtoMember(10)]
122122
[DataMember(Name = "subject_token_type", Order = 10)]
123-
public virtual string? SubjectTokenType { get; set; }
123+
public virtual OAuth2TokenType? SubjectTokenType { get; set; }
124124

125125
/// <summary>
126126
/// Gets/sets a 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.
@@ -138,7 +138,7 @@ public class OAuth2AuthenticationProperties
138138
[System.Text.Json.Serialization.JsonPropertyName("actor_token_type")]
139139
[ProtoMember(11)]
140140
[DataMember(Name = "actor_token_type", Order = 11)]
141-
public virtual string? ActorTokenType { get; set; }
141+
public virtual OAuth2TokenType? ActorTokenType { get; set; }
142142

143143
}
144144

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
namespace ServerlessWorkflow.Sdk
19+
{
20+
/// <summary>
21+
/// Enumerates all supported token types
22+
/// </summary>
23+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
24+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.StringEnumConverterFactory))]
25+
public enum OAuth2TokenType
26+
{
27+
/// <summary>
28+
/// Indicates an access token
29+
/// </summary>
30+
[EnumMember(Value = "urn:ietf:params:oauth:token-type:access_token")]
31+
AccessToken,
32+
/// <summary>
33+
/// Indicates an identity token
34+
/// </summary>
35+
[EnumMember(Value = "urn:ietf:params:oauth:token-type:id_token")]
36+
IdentityToken
37+
}
38+
39+
}

src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.xml

Lines changed: 41 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServerlessWorkflow.Sdk/Services/FluentBuilders/Interfaces/IOAuth2AuthenticationBuilder.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,20 @@ public interface IOAuth2AuthenticationBuilder
8383
IOAuth2AuthenticationBuilder UseAudiences(params string[] audiences);
8484

8585
/// <summary>
86-
/// Configures the <see cref="AuthenticationDefinition"/> to exchange the specified subject token when requesting an access token
86+
/// Configures the token that represents the identity of the party on behalf of whom the request is being made.Typically, the subject of this token will be the subject of the security token issued in response to the request.
8787
/// </summary>
88-
/// <param name="token">The token to exchange</param>
88+
/// <param name="tokenType">The type of the specified token</param>
89+
/// <param name="token">The subject token</param>
8990
/// <returns>The configured <see cref="IOAuth2AuthenticationBuilder"/></returns>
90-
IOAuth2AuthenticationBuilder WithSubjectToken(string token);
91+
IOAuth2AuthenticationBuilder WithSubjectToken(OAuth2TokenType tokenType, string token);
9192

9293
/// <summary>
93-
/// Configures the <see cref="AuthenticationDefinition"/> to impersonate the specified user
94+
/// Configures the 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.
9495
/// </summary>
95-
/// <param name="subject">The subject of the user to impersonate</param>
96+
/// <param name="tokenType">The type of the specified token</param>
97+
/// <param name="token">The actor token</param>
9698
/// <returns>The configured <see cref="IOAuth2AuthenticationBuilder"/></returns>
97-
IOAuth2AuthenticationBuilder WithRequestedSubject(string subject);
98-
99-
/// <summary>
100-
/// Configures the <see cref="AuthenticationDefinition"/> to exchange an access token with a new one from the specified issuer
101-
/// </summary>
102-
/// <param name="issuer">The issuer to exchnage the token with</param>
103-
/// <returns>The configured <see cref="IOAuth2AuthenticationBuilder"/></returns>
104-
IOAuth2AuthenticationBuilder WithRequestedIssuer(string issuer);
99+
IOAuth2AuthenticationBuilder WithActorToken(OAuth2TokenType tokenType, string token);
105100

106101
}
107102

src/ServerlessWorkflow.Sdk/Services/FluentBuilders/OAuth2AuthenticationBuilder.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public virtual IOAuth2AuthenticationBuilder UseAudiences(params string[] audienc
5252
{
5353
if (audiences == null)
5454
throw new ArgumentNullException(nameof(audiences));
55-
this.Properties.Audience = audiences.ToList();
55+
this.Properties.Audience = string.Join(" ", audiences);
5656
return this;
5757
}
5858

@@ -68,7 +68,7 @@ public virtual IOAuth2AuthenticationBuilder UseScopes(params string[] scopes)
6868
{
6969
if (scopes == null)
7070
throw new ArgumentNullException(nameof(scopes));
71-
this.Properties.Audience = scopes.ToList();
71+
this.Properties.Audience = string.Join(" ", scopes);
7272
return this;
7373
}
7474

@@ -100,47 +100,40 @@ public virtual IOAuth2AuthenticationBuilder WithClientSecret(string clientSecret
100100
}
101101

102102
/// <inheritdoc/>
103-
public virtual IOAuth2AuthenticationBuilder WithPassword(string password)
104-
{
105-
if (string.IsNullOrWhiteSpace(password))
106-
throw new ArgumentNullException(nameof(password));
107-
this.Properties.Password = password;
108-
return this;
109-
}
110-
111-
/// <inheritdoc/>
112-
public virtual IOAuth2AuthenticationBuilder WithRequestedIssuer(string issuer)
103+
public virtual IOAuth2AuthenticationBuilder WithUserName(string username)
113104
{
114-
if (string.IsNullOrWhiteSpace(issuer))
115-
throw new ArgumentNullException(nameof(issuer));
116-
this.Properties.RequestedIssuer = issuer;
105+
if (string.IsNullOrWhiteSpace(username))
106+
throw new ArgumentNullException(nameof(username));
107+
this.Properties.Username = username;
117108
return this;
118109
}
119110

120111
/// <inheritdoc/>
121-
public virtual IOAuth2AuthenticationBuilder WithRequestedSubject(string subject)
112+
public virtual IOAuth2AuthenticationBuilder WithPassword(string password)
122113
{
123-
if (string.IsNullOrWhiteSpace(subject))
124-
throw new ArgumentNullException(nameof(subject));
125-
this.Properties.RequestedSubject = subject;
114+
if (string.IsNullOrWhiteSpace(password))
115+
throw new ArgumentNullException(nameof(password));
116+
this.Properties.Password = password;
126117
return this;
127118
}
128119

129120
/// <inheritdoc/>
130-
public virtual IOAuth2AuthenticationBuilder WithSubjectToken(string token)
121+
public virtual IOAuth2AuthenticationBuilder WithSubjectToken(OAuth2TokenType tokenType, string token)
131122
{
132123
if (string.IsNullOrWhiteSpace(token))
133124
throw new ArgumentNullException(nameof(token));
125+
this.Properties.SubjectTokenType = tokenType;
134126
this.Properties.SubjectToken = token;
135127
return this;
136128
}
137129

138130
/// <inheritdoc/>
139-
public virtual IOAuth2AuthenticationBuilder WithUserName(string username)
131+
public virtual IOAuth2AuthenticationBuilder WithActorToken(OAuth2TokenType tokenType, string token)
140132
{
141-
if (string.IsNullOrWhiteSpace(username))
142-
throw new ArgumentNullException(nameof(username));
143-
this.Properties.Username = username;
133+
if (string.IsNullOrWhiteSpace(token))
134+
throw new ArgumentNullException(nameof(token));
135+
this.Properties.ActorTokenType = tokenType;
136+
this.Properties.ActorToken = token;
144137
return this;
145138
}
146139

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy