From bb172193c430944926aab84ee8c5543e5f0ae8a3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Jan 2023 20:54:17 +0200 Subject: [PATCH] feat: override standard idenity resources (#124) --- README.md | 2 ++ src/Config.cs | 21 ++++++++++++++------- src/OpenIdConnectServerMock.csproj | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c2ea115..d16435d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/Config.cs b/src/Config.cs index 9a83e4d..cdc9f00 100644 --- a/src/Config.cs +++ b/src/Config.cs @@ -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)) { @@ -121,13 +122,19 @@ public static IEnumerable GetClients() public static IEnumerable GetIdentityResources() { - var standardResources = new List + IEnumerable identityResources = new List(); + 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 + { + new IdentityResources.OpenId(), + new IdentityResources.Profile(), + new IdentityResources.Email() + }; + identityResources = identityResources.Union(standardResources); + } + return identityResources.Union(GetCustomIdentityResources()); } public static List GetUsers() diff --git a/src/OpenIdConnectServerMock.csproj b/src/OpenIdConnectServerMock.csproj index 1b5fc11..559b7ea 100644 --- a/src/OpenIdConnectServerMock.csproj +++ b/src/OpenIdConnectServerMock.csproj @@ -8,7 +8,7 @@ true Configurable mock server with OpenId Connect functionality - 0.8.0 + 0.8.2 https://github.com/Soluto/oidc-server-mock Apache-2.0 OIDC