Skip to content

Commit

Permalink
feat: override standard idenity resources (Soluto#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleF83 authored Jan 28, 2023
1 parent b1fc8f3 commit bb17219
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ There are two ways to provide configuration for supported scopes, clients and us

The configuration format can be Yaml or JSON both for inline or file path options.

In order to be able to override standard identity resources set `OVERRIDE_STANDARD_IDENTITY_RESOURCES` env var to `True`.

## Base path

The server can be configured to run with base path. So all the server endpoints will be also available with some prefix segment.
Expand Down
21 changes: 14 additions & 7 deletions src/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace OpenIdConnectServer
{
public static class Config
{
public static AspNetServicesOptions GetAspNetServicesOptions() {
public static AspNetServicesOptions GetAspNetServicesOptions()
{
string aspNetServicesOptionsStr = Environment.GetEnvironmentVariable("ASPNET_SERVICES_OPTIONS_INLINE");
if (string.IsNullOrWhiteSpace(aspNetServicesOptionsStr))
{
Expand Down Expand Up @@ -121,13 +122,19 @@ public static IEnumerable<Client> GetClients()

public static IEnumerable<IdentityResource> GetIdentityResources()
{
var standardResources = new List<IdentityResource>
IEnumerable<IdentityResource> identityResources = new List<IdentityResource>();
var overrideStandardResources = Environment.GetEnvironmentVariable("OVERRIDE_STANDARD_IDENTITY_RESOURCES");
if (string.IsNullOrEmpty(overrideStandardResources) || Boolean.Parse(overrideStandardResources) != true)
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};
return standardResources.Union(GetCustomIdentityResources());
var standardResources = new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};
identityResources = identityResources.Union(standardResources);
}
return identityResources.Union(GetCustomIdentityResources());
}

public static List<TestUser> GetUsers()
Expand Down
2 changes: 1 addition & 1 deletion src/OpenIdConnectServerMock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<IsPackable>true</IsPackable>
<Description>Configurable mock server with OpenId Connect functionality</Description>
<VersionPrefix>0.8.0</VersionPrefix>
<VersionPrefix>0.8.2</VersionPrefix>
<PackageProjectUrl>https://github.com/Soluto/oidc-server-mock</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageTags>OIDC</PackageTags>
Expand Down

0 comments on commit bb17219

Please sign in to comment.