connect RE to IdS

This commit is contained in:
Muhammad Azeez 2021-01-18 10:53:22 +03:00
parent 0265455823
commit 0f7550c362
2 changed files with 48 additions and 5 deletions

View File

@ -22,6 +22,7 @@ namespace OidcSamples.AuthorizationServer
}; };
private const string TrafficPoliceApi = "traffic-police-api"; private const string TrafficPoliceApi = "traffic-police-api";
private const string RealEstateApi = "real-estate-api";
public static IEnumerable<ApiScope> ApiScopes => public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[] new ApiScope[]
@ -29,6 +30,10 @@ namespace OidcSamples.AuthorizationServer
new ApiScope( new ApiScope(
TrafficPoliceApi, TrafficPoliceApi,
"Traffic Police API scope"), "Traffic Police API scope"),
new ApiScope(
RealEstateApi,
"Real Estate API scope"),
}; };
public static IEnumerable<ApiResource> ApiResources => public static IEnumerable<ApiResource> ApiResources =>
@ -39,6 +44,13 @@ namespace OidcSamples.AuthorizationServer
// list of audiences when this scope is requested // list of audiences when this scope is requested
Scopes = new List<string>{ TrafficPoliceApi }, Scopes = new List<string>{ TrafficPoliceApi },
}, },
new ApiResource(RealEstateApi, "Real Estate API")
{
// This will make sure that `real-estate-api` will be in the
// list of audiences when this scope is requested
Scopes = new List<string>{ RealEstateApi },
},
}; };
public static IEnumerable<Client> Clients => public static IEnumerable<Client> Clients =>
@ -65,7 +77,7 @@ namespace OidcSamples.AuthorizationServer
IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email, IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.Address, IdentityServerConstants.StandardScopes.Address,
"traffic-police-api", TrafficPoliceApi,
}, },
RequirePkce = true, RequirePkce = true,
PostLogoutRedirectUris = PostLogoutRedirectUris =
@ -76,6 +88,37 @@ namespace OidcSamples.AuthorizationServer
RequireConsent = false, RequireConsent = false,
}, },
new Client new Client
{
// IdentityTokenLifetime =
// AuthorizationCodeLifetime =
AccessTokenLifetime = 60 * 60 * 8,
AllowOfflineAccess = true,
UpdateAccessTokenClaimsOnRefresh = true,
ClientName = "Real Estate React App",
ClientId = "real-estate-react-app",
AllowedGrantTypes = GrantTypes.Code,
RequireClientSecret = false,
RedirectUris =
{
"http://localhost:4000/signin-oidc"
},
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.Address,
RealEstateApi,
},
RequirePkce = true,
PostLogoutRedirectUris =
{
"http://localhost:4000/signout-callback-oidc"
},
RequireConsent = false,
},
new Client
{ {
AccessTokenLifetime = 60 * 60 * 8, AccessTokenLifetime = 60 * 60 * 8,
AllowOfflineAccess = true, AllowOfflineAccess = true,

View File

@ -3,11 +3,11 @@ import { storeUserError, storeUser } from "../actions/authActions";
const config = { const config = {
authority: "http://localhost:10000", authority: "http://localhost:10000",
client_id: "traffic-police-react-app", client_id: "real-estate-react-app",
redirect_uri: "http://localhost:3000/signin-oidc", redirect_uri: "http://localhost:4000/signin-oidc",
response_type: "code", response_type: "code",
scope: "openid profile traffic-police-api", scope: "openid profile real-estate-api",
post_logout_redirect_uri: "http://localhost:3000/signout-oidc", post_logout_redirect_uri: "http://localhost:4000/signout-oidc",
}; };
const userManager = new UserManager(config); const userManager = new UserManager(config);