forked from robisim74/AngularSPAWebAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
62 lines (57 loc) · 2.21 KB
/
Config.cs
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
using IdentityServer4;
using IdentityServer4.Models;
using System.Collections.Generic;
namespace AngularSPAWebAPI
{
public class Config
{
// Identity resources (used by UserInfo endpoint).
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResource("roles", new List<string> { "role" })
};
}
// Api resources.
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("WebAPI" ) {
UserClaims = { "role" }
}
};
}
// Clients want to access resources.
public static IEnumerable<Client> GetClients()
{
// Clients credentials.
return new List<Client>
{
// http://docs.identityserver.io/en/release/reference/client.html.
new Client
{
ClientId = "AngularSPA",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, // Resource Owner Password Credential grant.
AllowAccessTokensViaBrowser = true,
RequireClientSecret = false, // This client does not need a secret to request tokens from the token endpoint.
AccessTokenLifetime = 900, // Lifetime of access token in seconds.
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId, // For UserInfo endpoint.
IdentityServerConstants.StandardScopes.Profile,
"roles",
"WebAPI"
},
AllowOfflineAccess = true, // For refresh token.
RefreshTokenUsage = TokenUsage.OneTimeOnly,
AbsoluteRefreshTokenLifetime = 7200,
SlidingRefreshTokenLifetime = 900,
RefreshTokenExpiration = TokenExpiration.Sliding
}
};
}
}
}