2016-11-24 15:31:33 +01:00
|
|
|
|
using IdentityServer4.Models;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using System.Collections.Generic;
|
2017-04-05 09:18:14 -03:00
|
|
|
|
using IdentityServer4;
|
2016-11-24 15:31:33 +01:00
|
|
|
|
|
2017-01-30 11:35:16 +01:00
|
|
|
|
namespace 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"),
|
|
|
|
|
new ApiResource("basket", "Basket Service")
|
|
|
|
|
};
|
|
|
|
|
}
|
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)
|
2016-12-07 13:57:31 +01:00
|
|
|
|
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,
|
2016-12-22 18:34:57 +01:00
|
|
|
|
RedirectUris = { $"{clientsUrl["Spa"]}/" },
|
2017-01-04 11:08:24 +01:00
|
|
|
|
RequireConsent = false,
|
2016-12-22 18:34:57 +01:00
|
|
|
|
PostLogoutRedirectUris = { $"{clientsUrl["Spa"]}/" },
|
2016-12-07 13:57:31 +01:00
|
|
|
|
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"
|
|
|
|
|
}
|
2016-11-28 12:58:51 +01:00
|
|
|
|
},
|
|
|
|
|
new Client
|
|
|
|
|
{
|
|
|
|
|
ClientId = "xamarin",
|
|
|
|
|
ClientName = "eShop Xamarin OpenId Client",
|
|
|
|
|
AllowedGrantTypes = GrantTypes.Implicit,
|
|
|
|
|
AllowAccessTokensViaBrowser = true,
|
2016-12-07 13:57:31 +01:00
|
|
|
|
RedirectUris = { "http://eshopxamarin/callback.html" },
|
2017-01-04 11:08:24 +01:00
|
|
|
|
RequireConsent = false,
|
2017-01-12 16:18:43 +01:00
|
|
|
|
PostLogoutRedirectUris = { "http://13.88.8.119:5105/Account/Redirecting", "http://10.6.1.234:5105/Account/Redirecting" },
|
2016-12-07 13:57:31 +01:00
|
|
|
|
AllowedCorsOrigins = { "http://eshopxamarin" },
|
2016-11-28 12:58:51 +01:00
|
|
|
|
AllowedScopes =
|
|
|
|
|
{
|
2017-04-05 09:18:14 -03:00
|
|
|
|
IdentityServerConstants.StandardScopes.OpenId,
|
|
|
|
|
IdentityServerConstants.StandardScopes.Profile,
|
2016-11-28 12:58:51 +01:00
|
|
|
|
"orders",
|
|
|
|
|
"basket"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Client
|
|
|
|
|
{
|
|
|
|
|
ClientId = "mvc",
|
|
|
|
|
ClientName = "MVC Client",
|
|
|
|
|
ClientSecrets = new List<Secret>
|
|
|
|
|
{
|
|
|
|
|
new Secret("secret".Sha256())
|
|
|
|
|
},
|
2016-12-07 13:57:31 +01:00
|
|
|
|
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
|
2016-12-19 10:20:02 +01:00
|
|
|
|
AllowedGrantTypes = GrantTypes.Hybrid,
|
2017-01-04 11:08:24 +01:00
|
|
|
|
RequireConsent = false,
|
2017-04-05 09:18:14 -03:00
|
|
|
|
AllowOfflineAccess = true,
|
2016-11-28 12:58:51 +01:00
|
|
|
|
RedirectUris = new List<string>
|
|
|
|
|
{
|
2016-12-07 13:57:31 +01:00
|
|
|
|
$"{clientsUrl["Mvc"]}/signin-oidc",
|
2016-12-22 13:20:12 +01:00
|
|
|
|
"http://104.40.62.65:5100/signin-oidc",
|
2016-12-22 18:34:57 +01:00
|
|
|
|
"http://localhost:5100/signin-oidc",
|
|
|
|
|
"http://13.88.8.119:5100/signin-oidc"
|
2016-11-28 12:58:51 +01:00
|
|
|
|
},
|
|
|
|
|
PostLogoutRedirectUris = new List<string>
|
|
|
|
|
{
|
2017-03-07 16:50:19 +01:00
|
|
|
|
$"{clientsUrl["Mvc"]}/signout-callback-oidc",
|
|
|
|
|
"http://localhost:5100/signout-callback-oidc"
|
2016-11-28 12:58:51 +01:00
|
|
|
|
},
|
|
|
|
|
AllowedScopes = new List<string>
|
|
|
|
|
{
|
2017-04-05 09:18:14 -03:00
|
|
|
|
IdentityServerConstants.StandardScopes.OpenId,
|
|
|
|
|
IdentityServerConstants.StandardScopes.Profile,
|
|
|
|
|
IdentityServerConstants.StandardScopes.OfflineAccess,
|
2016-11-28 12:58:51 +01:00
|
|
|
|
"orders",
|
|
|
|
|
"basket",
|
|
|
|
|
},
|
2016-11-24 15:31:33 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|