-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
70 lines (64 loc) · 2.52 KB
/
Config.cs
File metadata and controls
70 lines (64 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using IdentityServer4.Models;
using System.Collections.Generic;
namespace IdentityServer4AspNetIdentity
{
public static class Config
{
// Tell Identity Server about the API resources we are protecting / that a client might want to access
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new IdentityResource[]
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email(),
// custom claims I want
new IdentityResource
{
Name = "userrole",
Description = "User level Claim",
UserClaims = { "role" }
}
};
}
// Tell Identity Server about the API resources we are protecting / that a client might want to access
public static IEnumerable<ApiResource> GetApis()
{
return new ApiResource[]
{
new ApiResource("resourcesapi", "Resource API")
{
Scopes = {
new Scope("api.read"),
new Scope("api.write")
}
}
};
}
// Tell Identity Server about the Clients that will be accessing it
public static IEnumerable<Client> GetClients()
{
return new[]
{
// SPA client using implicit flow
new Client
{
ClientId = "AngularClientApp",
ClientName = "Angular SPA Client",
AllowedGrantTypes = GrantTypes.Implicit,
RequirePkce = false,
RequireClientSecret = false,
RedirectUris = {"http://localhost:4200/auth-callback"},
PostLogoutRedirectUris = { "http://localhost:4200" },
AllowedCorsOrigins = { "http://localhost:4200" },
AllowAccessTokensViaBrowser = true,
AccessTokenLifetime = 3600, // 1hr,
AlwaysSendClientClaims = true,
AllowedScopes = { "openid", "profile", "email", "api.read", "userrole" }
}
};
}
}
}