Skip to content

Commit

Permalink
Merge pull request #176 from Etherna/feature/ESSO-231-add-gateway-cli…
Browse files Browse the repository at this point in the history
…-client

add gateway cli client
  • Loading branch information
tmm360 authored Mar 11, 2024
2 parents 2b080b4 + 9b1aa2a commit c83ce4d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/EthernaSSO/Configs/IdentityServer/IdServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public static class IdResourcesDef
private readonly string ethernaGateway_Webapp_ClientId;
private readonly string ethernaGateway_Webapp_Secret;

private readonly string ethernaGatewayCli_BaseUrl;
private readonly string ethernaGatewayCli_ClientId;

private readonly string ethernaIndex_BaseUrl;
private readonly string ethernaIndex_Sso_ClientId;
private readonly string ethernaIndex_Sso_Secret;
Expand Down Expand Up @@ -139,6 +142,9 @@ public IdServerConfig(IConfiguration configuration)
ethernaGateway_Webapp_ClientId = configuration["IdServer:Clients:EthernaGateway:Clients:Webapp:ClientId"] ?? throw new ServiceConfigurationException();
ethernaGateway_Webapp_Secret = configuration["IdServer:Clients:EthernaGateway:Clients:Webapp:Secret"] ?? throw new ServiceConfigurationException();

ethernaGatewayCli_BaseUrl = configuration["IdServer:Clients:EthernaGatewayCli:BaseUrl"] ?? throw new ServiceConfigurationException();
ethernaGatewayCli_ClientId = configuration["IdServer:Clients:EthernaGatewayCli:ClientId"] ?? throw new ServiceConfigurationException();

ethernaIndex_BaseUrl = configuration["IdServer:Clients:EthernaIndex:BaseUrl"] ?? throw new ServiceConfigurationException();
ethernaIndex_Sso_ClientId = configuration["IdServer:Clients:EthernaIndex:Clients:SsoServer:ClientId"] ?? throw new ServiceConfigurationException();
ethernaIndex_Sso_Secret = configuration["IdServer:Clients:EthernaIndex:Clients:SsoServer:Secret"] ?? throw new ServiceConfigurationException();
Expand Down Expand Up @@ -334,6 +340,40 @@ public IdServerConfig(IConfiguration configuration)
// Allow token refresh.
AllowOfflineAccess = true
},

//gateway cli
new Client
{
ClientId = ethernaGatewayCli_ClientId,
ClientName = "Etherna Gateway CLI",
RequireClientSecret = false,

AllowedGrantTypes = GrantTypes.Code,

//where to redirect to after login
RedirectUris = { ethernaGatewayCli_BaseUrl },

//where to redirect to after logout
PostLogoutRedirectUris = { ethernaGatewayCli_BaseUrl },

AllowedCorsOrigins = { ethernaGatewayCli_BaseUrl },

AlwaysIncludeUserClaimsInIdToken = true,
AllowedScopes =
{
//identity
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdResourcesDef.EtherAccounts.Name,

//resource
ApiScopesDef.UserInteractEthernaGateway.Name,
},

// Allow token refresh.
AllowOfflineAccess = true,
RefreshTokenUsage = TokenUsage.OneTimeOnly //because client have not secret
},

//index (sso client)
new Client
Expand Down
5 changes: 5 additions & 0 deletions src/EthernaSSO/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
}
},

"EthernaGatewayCli": {
"BaseUrl": "http://127.0.0.1:11430",
"ClientId": "ethernaGatewayCliId"
},

"EthernaIndex": {
"Clients": {
"SsoServer": {
Expand Down

0 comments on commit c83ce4d

Please sign in to comment.