using IdentityServer4.Models; using Microsoft.Extensions.Options; using System.Collections.Generic; using IdentityServer4; namespace Identity.API.Configuration { public class Config { // ApiResources define the apis in your system public static IEnumerable GetApis() { return new List { new ApiResource("orders", "Orders Service"), new ApiResource("basket", "Basket Service") }; } // Identity resources are data like user ID, name, or email address of a user // see: http://docs.identityserver.io/en/release/configuration/resources.html public static IEnumerable GetResources() { return new List { new IdentityResources.OpenId(), new IdentityResources.Profile() }; } // client want to access resources (aka scopes) public static IEnumerable GetClients(Dictionary clientsUrl) { return new List { // JavaScript Client new Client { ClientId = "js", ClientName = "eShop SPA OpenId Client", AllowedGrantTypes = GrantTypes.Implicit, AllowAccessTokensViaBrowser = true, RedirectUris = { $"{clientsUrl["Spa"]}/" }, RequireConsent = false, PostLogoutRedirectUris = { $"{clientsUrl["Spa"]}/" }, AllowedCorsOrigins = { $"{clientsUrl["Spa"]}" }, AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, "orders", "basket" } }, new Client { ClientId = "xamarin", ClientName = "eShop Xamarin OpenId Client", AllowedGrantTypes = GrantTypes.Implicit, AllowAccessTokensViaBrowser = true, RedirectUris = { "http://eshopxamarin/callback.html" }, RequireConsent = false, PostLogoutRedirectUris = { "http://13.88.8.119:5105/Account/Redirecting", "http://10.6.1.234:5105/Account/Redirecting" }, AllowedCorsOrigins = { "http://eshopxamarin" }, AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, "orders", "basket" } }, new Client { ClientId = "mvc", ClientName = "MVC Client", ClientSecrets = new List { new Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, RequireConsent = false, AllowOfflineAccess = true, RedirectUris = new List { $"{clientsUrl["Mvc"]}/signin-oidc", "http://104.40.62.65:5100/signin-oidc", "http://localhost:5100/signin-oidc", "http://13.88.8.119:5100/signin-oidc" }, PostLogoutRedirectUris = new List { $"{clientsUrl["Mvc"]}/signout-callback-oidc", "http://localhost:5100/signout-callback-oidc" }, AllowedScopes = new List { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.OfflineAccess, "orders", "basket", }, } }; } } }