2016-11-24 15:31:33 +01:00
|
|
|
|
using IdentityServer4.Models;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace eShopOnContainers.Identity.Configuration
|
|
|
|
|
{
|
|
|
|
|
public class Config
|
|
|
|
|
{
|
|
|
|
|
// scopes define the resources in your system
|
|
|
|
|
public static IEnumerable<Scope> GetScopes()
|
|
|
|
|
{
|
|
|
|
|
return new List<Scope>
|
|
|
|
|
{
|
|
|
|
|
//Authentication OpenId uses this scopes;
|
|
|
|
|
StandardScopes.OpenId,
|
|
|
|
|
StandardScopes.Profile,
|
|
|
|
|
|
|
|
|
|
//Each api we want to securice;
|
|
|
|
|
new Scope
|
|
|
|
|
{
|
|
|
|
|
Name = "orders",
|
|
|
|
|
Description = "Orders Service"
|
|
|
|
|
},
|
|
|
|
|
new Scope
|
|
|
|
|
{
|
|
|
|
|
Name = "basket",
|
|
|
|
|
Description = "Basket Service"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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"]}/" },
|
|
|
|
|
PostLogoutRedirectUris = { $"{clientsUrl["Spa"]}/" },
|
2016-12-07 13:57:31 +01:00
|
|
|
|
AllowedCorsOrigins = { $"{clientsUrl["Spa"]}" },
|
2016-11-24 15:31:33 +01:00
|
|
|
|
AllowedScopes =
|
|
|
|
|
{
|
|
|
|
|
StandardScopes.OpenId.Name,
|
|
|
|
|
StandardScopes.Profile.Name,
|
|
|
|
|
"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" },
|
|
|
|
|
PostLogoutRedirectUris = { "http://eshopxamarin/callback.html/index.html" },
|
|
|
|
|
AllowedCorsOrigins = { "http://eshopxamarin" },
|
2016-11-28 12:58:51 +01:00
|
|
|
|
AllowedScopes =
|
|
|
|
|
{
|
|
|
|
|
StandardScopes.OpenId.Name,
|
|
|
|
|
StandardScopes.Profile.Name,
|
|
|
|
|
"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,
|
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-01-04 09:59:36 +01:00
|
|
|
|
$"{clientsUrl["Mvc"]}/",
|
|
|
|
|
"http://localhost:5100/"
|
2016-11-28 12:58:51 +01:00
|
|
|
|
},
|
|
|
|
|
AllowedScopes = new List<string>
|
|
|
|
|
{
|
|
|
|
|
StandardScopes.OpenId.Name,
|
|
|
|
|
StandardScopes.Profile.Name,
|
|
|
|
|
StandardScopes.OfflineAccess.Name,
|
|
|
|
|
"orders",
|
|
|
|
|
"basket",
|
|
|
|
|
},
|
2016-11-24 15:31:33 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|