Skip to content

Commit 47d5675

Browse files
committed
fix(Sdk): Fixed serialization of OAUTH2 properties to expected snake case by decorating its properties with the appropriate attributes
fix(Sdk): Fixed the OAuth2GrantType enum by replacing string equivalencies with the proper OAUTH2 values
1 parent ae17992 commit 47d5675

File tree

4 files changed

+58
-29
lines changed

4 files changed

+58
-29
lines changed

src/ServerlessWorkflow.Sdk/Models/OAuth2AuthenticationProperties.cs

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,83 +33,112 @@ public class OAuth2AuthenticationProperties
3333
/// <summary>
3434
/// Gets/sets the OAuth2 grant type to use
3535
/// </summary>
36+
[Newtonsoft.Json.JsonProperty("grant_type")]
37+
[System.Text.Json.Serialization.JsonPropertyName("grant_type")]
3638
[ProtoMember(1)]
37-
[DataMember(Order = 1)]
39+
[DataMember(Name= "grant_type", Order = 1)]
3840
public virtual OAuth2GrantType GrantType { get; set; }
3941

4042
/// <summary>
4143
/// Gets/sets the uri of the OAuth2 authority to use to generate an access token
4244
/// </summary>
4345
[Required]
44-
[Newtonsoft.Json.JsonRequired]
46+
[Newtonsoft.Json.JsonRequired, Newtonsoft.Json.JsonProperty("authority")]
47+
[System.Text.Json.Serialization.JsonPropertyName("authority")]
4548
[ProtoMember(2, IsRequired = true)]
46-
[DataMember(Order = 2, IsRequired = true)]
49+
[DataMember(Name = "authority", Order = 2, IsRequired = true)]
4750
public virtual Uri Authority { get; set; } = null!;
4851

4952
/// <summary>
5053
/// Gets/sets the id of the OAuth2 client to use
5154
/// </summary>
5255
[Required]
53-
[Newtonsoft.Json.JsonRequired]
56+
[Newtonsoft.Json.JsonRequired, Newtonsoft.Json.JsonProperty("client_id")]
57+
[System.Text.Json.Serialization.JsonPropertyName("client_id")]
5458
[ProtoMember(3, IsRequired = true)]
55-
[DataMember(Order = 3, IsRequired = true)]
59+
[DataMember(Name = "client_id", Order = 3, IsRequired = true)]
5660
public virtual string ClientId { get; set; } = null!;
5761

5862
/// <summary>
5963
/// Gets/sets the secret of the non-public OAuth2 client to use. Required when <see cref="GrantType"/> has been set to <see cref="OAuth2GrantType.TokenExchange"/>
6064
/// </summary>
65+
[Newtonsoft.Json.JsonProperty("client_secret")]
66+
[System.Text.Json.Serialization.JsonPropertyName("client_secret")]
6167
[ProtoMember(4)]
62-
[DataMember(Order = 4)]
68+
[DataMember(Name = "client_secret", Order = 4)]
6369
public virtual string? ClientSecret { get; set; }
6470

6571
/// <summary>
6672
/// Gets/sets the username to use when authenticating
6773
/// </summary>
74+
[Newtonsoft.Json.JsonProperty("username")]
75+
[System.Text.Json.Serialization.JsonPropertyName("username")]
6876
[ProtoMember(5)]
69-
[DataMember(Order = 5)]
77+
[DataMember(Name = "username", Order = 5)]
7078
public virtual string? Username { get; set; }
7179

7280
/// <summary>
7381
/// Gets/sets the password to use when authenticating
7482
/// </summary>
83+
[Newtonsoft.Json.JsonProperty("password")]
84+
[System.Text.Json.Serialization.JsonPropertyName("password")]
7585
[ProtoMember(6)]
76-
[DataMember(Order = 6)]
86+
[DataMember(Name = "password", Order = 6)]
7787
public virtual string? Password { get; set; }
7888

7989
/// <summary>
80-
/// Gets/sets a <see cref="List{T}"/> containing the authorized scopes of the resulting token
90+
/// Gets/sets a space-separated list containing the authorized scopes to request
8191
/// </summary>
92+
[Newtonsoft.Json.JsonProperty("scope")]
93+
[System.Text.Json.Serialization.JsonPropertyName("scope")]
8294
[ProtoMember(7)]
83-
[DataMember(Order = 7)]
84-
public virtual List<string>? Scopes { get; set; }
95+
[DataMember(Name = "scope", Order = 7)]
96+
public virtual string? Scope { get; set; }
8597

8698
/// <summary>
87-
/// Gets/sets a <see cref="List{T}"/> containing the authorized audiences of the resulting token
99+
/// Gets/sets a space-separated list containing the authorized audiences of the resulting token
88100
/// </summary>
101+
[Newtonsoft.Json.JsonProperty("audience")]
102+
[System.Text.Json.Serialization.JsonPropertyName("audience")]
89103
[ProtoMember(8)]
90-
[DataMember(Order = 8)]
91-
public virtual List<string>? Audiences { get; set; }
104+
[DataMember(Name = "audience", Order = 8)]
105+
public virtual string? Audience { get; set; }
92106

93107
/// <summary>
94-
/// Gets/sets the token to exchange for Impersonation
108+
/// Gets/sets 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.
95109
/// </summary>
110+
[Newtonsoft.Json.JsonProperty("subject_token")]
111+
[System.Text.Json.Serialization.JsonPropertyName("subject_token")]
96112
[ProtoMember(9)]
97-
[DataMember(Order = 9)]
113+
[DataMember(Name = "subject_token", Order = 9)]
98114
public virtual string? SubjectToken { get; set; }
99115

100116
/// <summary>
101-
/// Gets/sets the requested subject for Impersonation and Direct Naked Impersonation, which can be the id or the username of the user to impersonate
117+
/// Gets/sets an identifier, as described in Section 3, that indicates the type of the security token in the "subject_token" parameter.
102118
/// </summary>
119+
[Newtonsoft.Json.JsonProperty("subject_token_type")]
120+
[System.Text.Json.Serialization.JsonPropertyName("subject_token_type")]
103121
[ProtoMember(10)]
104-
[DataMember(Order = 10)]
105-
public virtual string? RequestedSubject { get; set; }
122+
[DataMember(Name = "subject_token_type", Order = 10)]
123+
public virtual string? SubjectTokenType { get; set; }
106124

107125
/// <summary>
108-
/// Gets/sets the issuer that must generate a new token in return for the exchanged one
126+
/// 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.
109127
/// </summary>
128+
[Newtonsoft.Json.JsonProperty("actor_token")]
129+
[System.Text.Json.Serialization.JsonPropertyName("actor_token")]
110130
[ProtoMember(11)]
111-
[DataMember(Order = 11)]
112-
public virtual string? RequestedIssuer { get; set; }
131+
[DataMember(Name = "actor_token", Order = 11)]
132+
public virtual string? ActorToken { get; set; }
133+
134+
/// <summary>
135+
/// Gets/sets an identifier, as described in Section 3, that indicates the type of the security token in the "actor_token" parameter. This is REQUIRED when the "actor_token" parameter is present in the request but MUST NOT be included otherwise.
136+
/// </summary>
137+
[Newtonsoft.Json.JsonProperty("actor_token_type")]
138+
[System.Text.Json.Serialization.JsonPropertyName("actor_token_type")]
139+
[ProtoMember(11)]
140+
[DataMember(Name = "actor_token_type", Order = 11)]
141+
public virtual string? ActorTokenType { get; set; }
113142

114143
}
115144

src/ServerlessWorkflow.Sdk/OAuth2GrantType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public enum OAuth2GrantType
3232
/// <summary>
3333
/// Indicates the <see href="https://datatracker.ietf.org/doc/html/rfc6749#section-4.4">client credentials grant type</see>
3434
/// </summary>
35-
[EnumMember(Value = "clientCredentials")]
35+
[EnumMember(Value = "client_credentials")]
3636
ClientCredentials,
3737
/// <summary>
3838
/// Indicates the <see href="https://datatracker.ietf.org/doc/html/rfc8693">token exchange grant type</see>
3939
/// </summary>
40-
[EnumMember(Value = "tokenExchange")]
40+
[EnumMember(Value = "urn:ietf:params:oauth:grant-type:token-exchange")]
4141
TokenExchange
4242
}
4343

src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<NeutralLanguage>en</NeutralLanguage>
7-
<AssemblyVersion>0.8.1.10</AssemblyVersion>
8-
<FileVersion>0.8.1.10</FileVersion>
9-
<Version>0.8.1.10</Version>
7+
<AssemblyVersion>0.8.1.11</AssemblyVersion>
8+
<FileVersion>0.8.1.11</FileVersion>
9+
<Version>0.8.1.11</Version>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1212
<PackageLicenseFile>LICENSE</PackageLicenseFile>

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

Lines changed: 2 additions & 2 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.Audiences = audiences.ToList();
55+
this.Properties.Audience = audiences.ToList();
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.Audiences = scopes.ToList();
71+
this.Properties.Audience = scopes.ToList();
7272
return this;
7373
}
7474

0 commit comments

Comments
 (0)