diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs index 55a4c76c59..00ab537d90 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -47,23 +47,19 @@ namespace BackendAdminApp.Host .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ClientId = configuration["AuthServer:ClientId"]; + options.ClientSecret = configuration["AuthServer:ClientSecret"]; options.RequireHttpsMetadata = false; options.ResponseType = OpenIdConnectResponseType.CodeIdToken; - - options.ClientId = "backend-admin-app-client"; - options.ClientSecret = "1q2w3e*"; - options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; - options.Scope.Add("role"); options.Scope.Add("email"); options.Scope.Add("phone"); options.Scope.Add("BackendAdminAppGateway"); options.Scope.Add("IdentityService"); options.Scope.Add("ProductService"); - options.ClaimActions.MapAbpClaimTypes(); }); diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/appsettings.json b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/appsettings.json index 014af300a1..cfc597fc38 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/appsettings.json +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/appsettings.json @@ -1,4 +1,9 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ClientId": "backend-admin-app-client", + "ClientSecret": "1q2w3e*" + }, "RemoteServices": { "Default": { "BaseUrl": "http://localhost:65115/" diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index 2a005cb455..db1009bcc3 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -50,23 +50,19 @@ namespace PublicWebSite.Host .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ClientId = configuration["AuthServer:ClientId"]; + options.ClientSecret = configuration["AuthServer:ClientSecret"]; options.RequireHttpsMetadata = false; options.ResponseType = OpenIdConnectResponseType.CodeIdToken; - - options.ClientId = "public-website-client"; - options.ClientSecret = "1q2w3e*"; - options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; - options.Scope.Add("role"); options.Scope.Add("email"); options.Scope.Add("phone"); options.Scope.Add("PublicWebSiteGateway"); options.Scope.Add("ProductService"); options.Scope.Add("BloggingService"); - options.ClaimActions.MapAbpClaimTypes(); }); diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/appsettings.json b/samples/MicroserviceDemo/applications/PublicWebSite.Host/appsettings.json index 12670d68c3..edf6f8b09d 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/appsettings.json +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/appsettings.json @@ -1,4 +1,9 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ClientId": "public-website-client", + "ClientSecret": "1q2w3e*" + }, "RemoteServices": { "Default": { "BaseUrl": "http://localhost:64897/" diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs index 889d282186..b89ae24a9f 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs @@ -33,10 +33,9 @@ namespace BackendAdminAppGateway.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "BackendAdminAppGateway"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json index 5913e851ed..b6f59c374f 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "BackendAdminAppGateway" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true" }, diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs index 05907a7062..b869e121c8 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs @@ -33,10 +33,9 @@ namespace InternalGateway.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "InternalGateway"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json b/samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json index cf3c02d1ce..75df9901e2 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "InternalGateway" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true" }, diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs index bf2833ad76..33874d6438 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs @@ -33,10 +33,9 @@ namespace PublicWebSiteGateway.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "PublicWebSiteGateway"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/appsettings.json b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/appsettings.json index e29e77768a..d0e8ae7f2f 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/appsettings.json +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "PublicWebSiteGateway" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true" }, diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index 436738a431..3ad540a897 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -42,10 +42,9 @@ namespace BloggingService.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "BloggingService"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json b/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json index 561f40d3b8..fa523718a2 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "BloggingService" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", "Blogging": "mongodb://localhost|MsDemo_Blogging" diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs index 8eb2334f48..fc05793b7b 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs @@ -37,10 +37,9 @@ namespace IdentityService.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "IdentityService"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/appsettings.json b/samples/MicroserviceDemo/microservices/IdentityService.Host/appsettings.json index de0f813c17..785d86a44a 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/appsettings.json +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "IdentityService" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true" }, diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs index 2ee399750b..60d93ce198 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs @@ -37,10 +37,9 @@ namespace ProductService.Host context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { - options.Authority = "http://localhost:64999"; + options.Authority = configuration["AuthServer:Authority"]; + options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; - options.ApiName = "ProductService"; - //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/appsettings.json b/samples/MicroserviceDemo/microservices/ProductService.Host/appsettings.json index 7891e47757..0a29cc06bf 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/appsettings.json +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/appsettings.json @@ -1,4 +1,8 @@ { + "AuthServer": { + "Authority": "http://localhost:64999", + "ApiName": "ProductService" + }, "ConnectionStrings": { "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", "ProductManagement": "Server=localhost;Database=MsDemo_ProductManagement;Trusted_Connection=True;MultipleActiveResultSets=true"