236 lines
9.6 KiB
C#
Raw Normal View History

using IdentityServer4;
using IdentityServer4.Models;
2016-11-24 15:31:33 +01:00
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
2016-11-24 15:31:33 +01:00
{
public class Config
{
2017-04-05 09:18:14 -03:00
// ApiResources define the apis in your system
public static IEnumerable<ApiResource> GetApis()
2016-11-24 15:31:33 +01:00
{
2017-04-05 09:18:14 -03:00
return new List<ApiResource>
2016-11-24 15:31:33 +01:00
{
2017-04-05 09:18:14 -03:00
new ApiResource("orders", "Orders Service"),
2017-06-01 10:10:37 +02:00
new ApiResource("basket", "Basket Service"),
2017-06-09 12:43:46 +02:00
new ApiResource("marketing", "Marketing Service"),
2018-01-26 16:09:36 +00:00
new ApiResource("locations", "Locations Service"),
2018-02-15 17:30:39 +01:00
new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator")
2017-04-05 09:18:14 -03:00
};
}
2016-11-24 15:31:33 +01:00
2017-04-05 09:18:14 -03:00
// 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<IdentityResource> GetResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile()
2016-11-24 15:31:33 +01:00
};
}
// client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUrl)
2016-11-24 15:31:33 +01:00
{
return new List<Client>
{
// 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"]}" },
2016-11-24 15:31:33 +01:00
AllowedScopes =
{
2017-04-05 09:18:14 -03:00
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
2016-11-24 15:31:33 +01:00
"orders",
"basket",
"locations",
2018-01-26 16:09:36 +00:00
"marketing",
2018-02-15 17:30:39 +01:00
"mobileshoppingagg"
2016-11-24 15:31:33 +01:00
}
},
new Client
{
ClientId = "xamarin",
ClientName = "eShop Xamarin OpenId Client",
AllowedGrantTypes = GrantTypes.Hybrid,
//Used to retrieve the access token on the back channel.
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { clientsUrl["Xamarin"] },
RequireConsent = false,
RequirePkce = true,
PostLogoutRedirectUris = { $"{clientsUrl["Xamarin"]}/Account/Redirecting" },
AllowedCorsOrigins = { "http://eshopxamarin" },
AllowedScopes = new List<string>
{
2017-04-05 09:18:14 -03:00
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"locations",
2018-01-26 16:09:36 +00:00
"marketing",
2018-02-15 17:30:39 +01:00
"mobileshoppingagg"
},
//Allow requesting refresh tokens for long lived API access
AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true
},
new Client
{
ClientId = "mvc",
ClientName = "MVC Client",
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Hybrid,
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
2017-04-05 09:18:14 -03:00
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signout-callback-oidc"
},
AllowedScopes = new List<string>
{
2017-04-05 09:18:14 -03:00
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"locations",
2018-01-26 16:09:36 +00:00
"marketing",
2018-02-15 17:30:39 +01:00
"mobileshoppingagg"
},
},
new Client
{
ClientId = "mvctest",
ClientName = "MVC Client Test",
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Hybrid,
AllowAccessTokensViaBrowser = true,
RequireConsent = false,
AllowOfflineAccess = true,
RedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signout-callback-oidc"
},
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"locations",
2018-01-26 16:09:36 +00:00
"marketing",
2018-02-15 17:30:39 +01:00
"mobileshoppingagg"
},
},
new Client
{
ClientId = "locationsswaggerui",
ClientName = "Locations Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { $"{clientsUrl["LocationsApi"]}/swagger/o2c.html" },
PostLogoutRedirectUris = { $"{clientsUrl["LocationsApi"]}/swagger/" },
AllowedScopes =
{
"locations"
}
},
new Client
{
ClientId = "marketingswaggerui",
ClientName = "Marketing Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { $"{clientsUrl["MarketingApi"]}/swagger/o2c.html" },
PostLogoutRedirectUris = { $"{clientsUrl["MarketingApi"]}/swagger/" },
AllowedScopes =
{
"marketing"
}
},
new Client
{
ClientId = "basketswaggerui",
ClientName = "Basket Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { $"{clientsUrl["BasketApi"]}/swagger/o2c.html" },
PostLogoutRedirectUris = { $"{clientsUrl["BasketApi"]}/swagger/" },
AllowedScopes =
{
"basket"
}
},
new Client
{
ClientId = "orderingswaggerui",
ClientName = "Ordering Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { $"{clientsUrl["OrderingApi"]}/swagger/o2c.html" },
PostLogoutRedirectUris = { $"{clientsUrl["OrderingApi"]}/swagger/" },
AllowedScopes =
{
"orders"
}
2018-01-26 16:09:36 +00:00
},
new Client
{
2018-02-15 17:30:39 +01:00
ClientId = "mobileshoppingaggswaggerui",
ClientName = "Mobile Shopping Aggregattor Swagger UI",
2018-01-26 16:09:36 +00:00
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
2018-02-15 17:30:39 +01:00
RedirectUris = { $"{clientsUrl["MobileShoppingAgg"]}/swagger/o2c.html" },
PostLogoutRedirectUris = { $"{clientsUrl["MobileShoppingAgg"]}/swagger/" },
2018-01-26 16:09:36 +00:00
AllowedScopes =
{
2018-02-15 17:30:39 +01:00
"mobileshoppingagg"
2018-01-26 16:09:36 +00:00
}
2016-11-24 15:31:33 +01:00
}
2018-01-26 16:09:36 +00:00
2016-11-24 15:31:33 +01:00
};
}
}
}