Skip to content

Commit

Permalink
New - Ajout d'un platform name pour l'initialisation des urls
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Mar 11, 2021
1 parent 4f97c74 commit 8f21a48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Sheaft.Identity/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ public void Configure(IApplicationBuilder app)
});
configContext.SaveChanges();
}

var platform = Configuration.GetValue<string>("Clients:Platform");
if (!string.IsNullOrWhiteSpace(platform))
platform = $"{platform}.";

var appName = Configuration.GetValue<string>("Clients:App:Name");
if (configContext.Clients.All(c => c.ClientName != appName))
Expand All @@ -629,7 +633,7 @@ public void Configure(IApplicationBuilder app)
new ClientSecret{Value = Configuration.GetValue<string>("Clients:App:Secret")}
},
ClientName = appName,
ClientUri = "http://localhost:4200",
ClientUri = $"https://{platform}app.sheaft.com",
RequireClientSecret = false,
AllowAccessTokensViaBrowser = true,
RequirePkce = true,
Expand All @@ -638,7 +642,8 @@ public void Configure(IApplicationBuilder app)
new ClientCorsOrigin { Origin = "http://localhost:5002" },
new ClientCorsOrigin { Origin = "https://localhost:5003" },
new ClientCorsOrigin { Origin = "http://localhost:5009" },
new ClientCorsOrigin { Origin = "https://localhost:5010" }
new ClientCorsOrigin { Origin = "https://localhost:5010" },
new ClientCorsOrigin { Origin = $"https://{platform}app.sheaft.com" }
},
AllowedScopes = new List<ClientScope>() {
new ClientScope { Scope = IdentityServerConstants.StandardScopes.OpenId },
Expand All @@ -655,14 +660,17 @@ public void Configure(IApplicationBuilder app)
Enabled = true,
RedirectUris = new List<ClientRedirectUri>() {
new ClientRedirectUri { RedirectUri = "http://localhost:4200" },
new ClientRedirectUri { RedirectUri = "http://localhost:4200/#/" },
new ClientRedirectUri { RedirectUri = "http://localhost:4200/#/callback" },
new ClientRedirectUri { RedirectUri = "http://localhost:4200/#/callback-silent" },
new ClientRedirectUri { RedirectUri = $"https://{platform}app.sheaft.com" },
new ClientRedirectUri { RedirectUri = $"https://{platform}app.sheaft.com/#/callback" },
new ClientRedirectUri { RedirectUri = $"https://{platform}app.sheaft.com/#/callback-silent" },
},
PostLogoutRedirectUris = new List<ClientPostLogoutRedirectUri>() {
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "http://localhost:4200"},
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "http://localhost:4200/#/" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "http://localhost:4200/#/logout" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = $"https://{platform}app.sheaft.com" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = $"https://{platform}app.sheaft.com/#/logout" },
},
EnableLocalLogin = true,
AllowOfflineAccess = true,
Expand Down Expand Up @@ -705,13 +713,14 @@ public void Configure(IApplicationBuilder app)
new ClientSecret{Value = Configuration.GetValue<string>("Clients:Manage:Secret")}
},
ClientName = manageName,
ClientUri = "http://localhost:5007",
ClientUri = $"https://{platform}manage.sheaft.com",
RequireClientSecret = false,
AllowAccessTokensViaBrowser = true,
RequirePkce = true,
AllowedCorsOrigins = new List<ClientCorsOrigin>() {
new ClientCorsOrigin { Origin = "https://localhost:5008" },
new ClientCorsOrigin { Origin = "http://localhost:5007" },
new ClientCorsOrigin { Origin = $"https://{platform}manage.sheaft.com" },
},
AllowedScopes = new List<ClientScope>() {
new ClientScope { Scope = IdentityServerConstants.StandardScopes.OpenId },
Expand All @@ -726,10 +735,12 @@ public void Configure(IApplicationBuilder app)
RedirectUris = new List<ClientRedirectUri>() {
new ClientRedirectUri { RedirectUri = "https://localhost:5008/signin-oidc" },
new ClientRedirectUri { RedirectUri = "http://localhost:5007/signin-oidc" },
new ClientRedirectUri { RedirectUri = $"https://{platform}manage.sheaft.com/signin-oidc" },
},
PostLogoutRedirectUris = new List<ClientPostLogoutRedirectUri>() {
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "https://localhost:5008/signout-oidc" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "http://localhost:5007/signout-oidc" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = $"https://{platform}manage.sheaft.com/signout-oidc" },
},
EnableLocalLogin = true,
AllowOfflineAccess = true,
Expand Down Expand Up @@ -776,13 +787,14 @@ public void Configure(IApplicationBuilder app)
new ClientSecret{Value = Configuration.GetValue<string>("Clients:Jobs:Secret")}
},
ClientName = jobName,
ClientUri = "http://localhost:5019",
ClientUri = $"https://{platform}jobs.sheaft.com",
RequireClientSecret = false,
AllowAccessTokensViaBrowser = true,
RequirePkce = true,
AllowedCorsOrigins = new List<ClientCorsOrigin>() {
new ClientCorsOrigin { Origin = "https://localhost:5020" },
new ClientCorsOrigin { Origin = "http://localhost:5019" },
new ClientCorsOrigin { Origin = $"https://{platform}jobs.sheaft.com" },
},
AllowedScopes = new List<ClientScope>() {
new ClientScope { Scope = IdentityServerConstants.StandardScopes.OpenId },
Expand All @@ -797,10 +809,12 @@ public void Configure(IApplicationBuilder app)
RedirectUris = new List<ClientRedirectUri>() {
new ClientRedirectUri { RedirectUri = "https://localhost:5020/signin-oidc" },
new ClientRedirectUri { RedirectUri = "http://localhost:5019/signin-oidc" },
new ClientRedirectUri { RedirectUri = $"https://{platform}jobs.sheaft.com/signin-oidc" },
},
PostLogoutRedirectUris = new List<ClientPostLogoutRedirectUri>() {
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "https://localhost:5020/signout-oidc" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = "http://localhost:5019/signout-oidc" },
new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = $"https://{platform}jobs.sheaft.com/signout-oidc" },
},
EnableLocalLogin = true,
AllowOfflineAccess = true,
Expand Down
6 changes: 6 additions & 0 deletions Sheaft.Identity/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"bounces": "##REPLACE##"
},
"Clients": {
"Platform": "",
"App": {
"Id": "##REPLACE##",
"Name": "##REPLACE##",
Expand All @@ -59,6 +60,11 @@
"Id": "##REPLACE##",
"Name": "##REPLACE##",
"Secret": "##REPLACE##"
},
"Jobs": {
"Id": "##REPLACE##",
"Name": "##REPLACE##",
"Secret": "##REPLACE##"
}
},
"IdentityDatabase": {
Expand Down

0 comments on commit 8f21a48

Please sign in to comment.