-
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
agile.zhou
committed
Aug 20, 2023
1 parent
acb13bc
commit 6b06158
Showing
16 changed files
with
167 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...onfig.Server.OIDC/IOidcSettingProvider.cs → ...C/SettingProvider/IOidcSettingProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
AgileConfig.Server.OIDC/TokenEndpointAuthMethods/BasicTokenEndpointAuthMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
|
||
namespace AgileConfig.Server.OIDC.TokenEndpointAuthMethods | ||
{ | ||
internal class BasicTokenEndpointAuthMethod : ITokenEndpointAuthMethod | ||
{ | ||
public (HttpContent HttpContent, string BasicAuthorizationString) GetAuthHttpContent(string code, OidcSetting oidcSetting) | ||
{ | ||
var kvs = new List<KeyValuePair<string, string>>() { | ||
new KeyValuePair<string, string>("code", code), | ||
new KeyValuePair<string, string>("grant_type", "authorization_code"), | ||
new KeyValuePair<string, string>("redirect_uri", oidcSetting.RedirectUri) | ||
}; | ||
var httpContent = new FormUrlEncodedContent(kvs); | ||
|
||
var txt = $"{oidcSetting.ClientId}:{oidcSetting.ClientSecret}"; | ||
string authorizationString = Convert.ToBase64String(Encoding.UTF8.GetBytes(txt)); | ||
|
||
return (httpContent, authorizationString); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
AgileConfig.Server.OIDC/TokenEndpointAuthMethods/ITokenEndpointAuthMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace AgileConfig.Server.OIDC.TokenEndpointAuthMethods | ||
{ | ||
internal interface ITokenEndpointAuthMethod | ||
{ | ||
(HttpContent HttpContent, string BasicAuthorizationString) GetAuthHttpContent(string code, OidcSetting oidcSetting); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
AgileConfig.Server.OIDC/TokenEndpointAuthMethods/NoneTokenEndpointAuthMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Text; | ||
|
||
namespace AgileConfig.Server.OIDC.TokenEndpointAuthMethods | ||
{ | ||
internal class NoneTokenEndpointAuthMethod : ITokenEndpointAuthMethod | ||
{ | ||
public (HttpContent HttpContent, string BasicAuthorizationString) GetAuthHttpContent(string code, OidcSetting oidcSetting) | ||
{ | ||
var kvs = new List<KeyValuePair<string, string>>() { | ||
new KeyValuePair<string, string>("code", code), | ||
new KeyValuePair<string, string>("grant_type", "authorization_code"), | ||
new KeyValuePair<string, string>("redirect_uri", oidcSetting.RedirectUri) | ||
}; | ||
var httpContent = new FormUrlEncodedContent(kvs); | ||
|
||
return (httpContent, ""); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
AgileConfig.Server.OIDC/TokenEndpointAuthMethods/PostTokenEndpointAuthMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace AgileConfig.Server.OIDC.TokenEndpointAuthMethods | ||
{ | ||
internal class PostTokenEndpointAuthMethod : ITokenEndpointAuthMethod | ||
{ | ||
public (HttpContent HttpContent, string BasicAuthorizationString) GetAuthHttpContent(string code, OidcSetting oidcSetting) | ||
{ | ||
var kvs = new List<KeyValuePair<string, string>>() { | ||
new KeyValuePair<string, string>("code", code), | ||
new KeyValuePair<string, string>("grant_type", "authorization_code"), | ||
new KeyValuePair<string, string>("redirect_uri", oidcSetting.RedirectUri), | ||
new KeyValuePair<string, string>("client_id", oidcSetting.ClientId), | ||
new KeyValuePair<string, string>("client_secret", oidcSetting.ClientSecret), | ||
}; | ||
var httpContent = new FormUrlEncodedContent(kvs); | ||
|
||
return (httpContent, ""); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
AgileConfig.Server.OIDC/TokenEndpointAuthMethods/TokenEndpointAuthMethodFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace AgileConfig.Server.OIDC.TokenEndpointAuthMethods | ||
{ | ||
internal static class TokenEndpointAuthMethodFactory | ||
{ | ||
public static ITokenEndpointAuthMethod Create(string methodName) | ||
{ | ||
if (methodName == "client_secret_basic") | ||
{ | ||
return new BasicTokenEndpointAuthMethod(); | ||
} | ||
else if (methodName == "client_secret_post") | ||
{ | ||
return new PostTokenEndpointAuthMethod(); | ||
} | ||
else if (methodName == "none") | ||
{ | ||
return new NoneTokenEndpointAuthMethod(); | ||
} | ||
else | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
} |