11using IdentityServer4 . Models ;
22using Microsoft . Extensions . Options ;
33using System . Collections . Generic ;
4+ using IdentityServer4 ;
45
56namespace Identity . API . Configuration
67{
78 public class Config
89 {
9- // scopes define the resources in your system
10- public static IEnumerable < Scope > GetScopes ( )
10+ // ApiResources define the apis in your system
11+ public static IEnumerable < ApiResource > GetApis ( )
1112 {
12- return new List < Scope >
13+ return new List < ApiResource >
1314 {
14- //Authentication OpenId uses this scopes;
15- StandardScopes . OpenId ,
16- StandardScopes . Profile ,
15+ new ApiResource ( "orders" , "Orders Service" ) ,
16+ new ApiResource ( "basket" , "Basket Service" )
17+ } ;
18+ }
1719
18- //Each api we want to securice;
19- new Scope
20- {
21- Name = "orders" ,
22- Description = "Orders Service"
23- } ,
24- new Scope
25- {
26- Name = "basket" ,
27- Description = "Basket Service"
28- }
20+ // Identity resources are data like user ID, name, or email address of a user
21+ // see: http://docs.identityserver.io/en/release/configuration/resources.html
22+ public static IEnumerable < IdentityResource > GetResources ( )
23+ {
24+ return new List < IdentityResource >
25+ {
26+ new IdentityResources . OpenId ( ) ,
27+ new IdentityResources . Profile ( )
2928 } ;
3029 }
3130
@@ -47,8 +46,8 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
4746 AllowedCorsOrigins = { $ "{ clientsUrl [ "Spa" ] } " } ,
4847 AllowedScopes =
4948 {
50- StandardScopes . OpenId . Name ,
51- StandardScopes . Profile . Name ,
49+ IdentityServerConstants . StandardScopes . OpenId ,
50+ IdentityServerConstants . StandardScopes . Profile ,
5251 "orders" ,
5352 "basket"
5453 }
@@ -65,8 +64,8 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
6564 AllowedCorsOrigins = { "http://eshopxamarin" } ,
6665 AllowedScopes =
6766 {
68- StandardScopes . OpenId . Name ,
69- StandardScopes . Profile . Name ,
67+ IdentityServerConstants . StandardScopes . OpenId ,
68+ IdentityServerConstants . StandardScopes . Profile ,
7069 "orders" ,
7170 "basket"
7271 }
@@ -82,6 +81,7 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
8281 ClientUri = $ "{ clientsUrl [ "Mvc" ] } ", // public uri of the client
8382 AllowedGrantTypes = GrantTypes . Hybrid ,
8483 RequireConsent = false ,
84+ AllowOfflineAccess = true ,
8585 RedirectUris = new List < string >
8686 {
8787 $ "{ clientsUrl [ "Mvc" ] } /signin-oidc",
@@ -96,9 +96,9 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
9696 } ,
9797 AllowedScopes = new List < string >
9898 {
99- StandardScopes . OpenId . Name ,
100- StandardScopes . Profile . Name ,
101- StandardScopes . OfflineAccess . Name ,
99+ IdentityServerConstants . StandardScopes . OpenId ,
100+ IdentityServerConstants . StandardScopes . Profile ,
101+ IdentityServerConstants . StandardScopes . OfflineAccess ,
102102 "orders" ,
103103 "basket" ,
104104 } ,
0 commit comments