109 lines
4.4 KiB
C#
Raw Normal View History

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)
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"
}
},
new Client
{
ClientId = "xamarin",
ClientName = "eShop Xamarin OpenId Client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { "http://eshopxamarin/callback.html" },
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" },
AllowedCorsOrigins = { "http://eshopxamarin" },
AllowedScopes =
{
2017-04-05 09:18:14 -03:00
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"orders",
"basket"
}
},
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,
RequireConsent = false,
2017-04-05 09:18:14 -03:00
AllowOfflineAccess = true,
RedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signin-oidc",
2016-12-22 13:20:12 +01:00
"http://104.40.62.65:5100/signin-oidc",
"http://localhost:5100/signin-oidc",
"http://13.88.8.119:5100/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
2017-03-07 16:50:19 +01:00
$"{clientsUrl["Mvc"]}/signout-callback-oidc",
"http://localhost:5100/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",
},
2016-11-24 15:31:33 +01:00
}
};
}
}
}