internal IdentityServer4.EntityFramework.Entities.Client ToClient() { var redirectUris = RedirectUris?.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList(); var allowedCorsOrigins = AllowedCorsOrigins?.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList(); var client = new Models.Client { AbsoluteRefreshTokenLifetime = AbsoluteRefreshTokenLifetime, AccessTokenLifetime = AccessTokenLifetime, AccessTokenType = AccessTokenType, AllowAccessTokensViaBrowser = AllowAccessTokensViaBrowser, AllowedCorsOrigins = allowedCorsOrigins, AllowedGrantTypes = GetAllowedGrantTypes(), AllowedScopes = AllowedScopes?.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries) .Where(cors => !string.IsNullOrWhiteSpace(cors)).ToList(), AllowOfflineAccess = AllowOfflineAccess, AllowPlainTextPkce = AllowPlainTextPkce, AllowRememberConsent = AllowRememberConsent, AlwaysIncludeUserClaimsInIdToken = AlwaysIncludeUserClaimsInIdToken, AlwaysSendClientClaims = AlwaysSendClientClaims, AuthorizationCodeLifetime = AuthorizationCodeLifetime, BackChannelLogoutSessionRequired = BackChannelLogoutSessionRequired, BackChannelLogoutUri = BackChannelLogoutUri, ClientClaimsPrefix = ClientClaimsPrefix, ClientId = ClientId, ClientName = ClientName, ClientUri = ClientUri, ConsentLifetime = ConsentLifetime, Description = Description, DeviceCodeLifetime = DeviceCodeLifetime, Enabled = Enabled, EnableLocalLogin = EnableLocalLogin, FrontChannelLogoutSessionRequired = FrontChannelLogoutSessionRequired, FrontChannelLogoutUri = FrontChannelLogoutUri, IdentityProviderRestrictions = IdentityProviderRestrictions?.Split("\r\n", StringSplitOptions.RemoveEmptyEntries), IdentityTokenLifetime = IdentityTokenLifetime, IncludeJwtId = IncludeJwtId, LogoUri = LogoUri, PairWiseSubjectSalt = PairWiseSubjectSalt, PostLogoutRedirectUris = PostLogoutRedirectUris? .Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList(), // Properties ProtocolType = ProtocolType, RedirectUris = redirectUris, RefreshTokenExpiration = RefreshTokenExpiration, RefreshTokenUsage = RefreshTokenUsage, RequireClientSecret = RequireClientSecret, RequireConsent = RequireConsent, RequirePkce = RequirePkce, SlidingRefreshTokenLifetime = SlidingRefreshTokenLifetime, UpdateAccessTokenClaimsOnRefresh = UpdateAccessTokenClaimsOnRefresh, UserCodeType = UserCodeType, UserSsoLifetime = UserSsoLifetime, }; var secrets = ClientSecrets?.Split("\r\n", StringSplitOptions.RemoveEmptyEntries) .Select(x => new Secret(x.Sha256())).ToList(); if (secrets != null && secrets.Count == 0) { client.ClientSecrets = secrets; } return(client.ToEntity()); }
public virtual void RemoveCorsOrigin(string uri) { AllowedCorsOrigins.RemoveAll(c => c.Origin == uri); }
public virtual ClientCorsOrigin FindCorsOrigin(string uri) { return(AllowedCorsOrigins.FirstOrDefault(c => c.Origin == uri)); }
public virtual void RemoveAllCorsOrigins() { AllowedCorsOrigins.Clear(); }
public virtual void AddCorsOrigin([NotNull] string origin) { AllowedCorsOrigins.Add(new ClientCorsOrigin(Id, origin)); }
/// <summary> /// Returns true if Oauth2ClientSubmit instances are equal /// </summary> /// <param name="other">Instance of Oauth2ClientSubmit to be compared</param> /// <returns>Boolean</returns> public bool Equals(Oauth2ClientSubmit other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ClientId == other.ClientId || ClientId != null && ClientId.Equals(other.ClientId) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( AllowedGrantTypes == other.AllowedGrantTypes || AllowedGrantTypes != null && other.AllowedGrantTypes != null && AllowedGrantTypes.SequenceEqual(other.AllowedGrantTypes) ) && ( RedirectUris == other.RedirectUris || RedirectUris != null && other.RedirectUris != null && RedirectUris.SequenceEqual(other.RedirectUris) ) && ( AllowedCorsOrigins == other.AllowedCorsOrigins || AllowedCorsOrigins != null && other.AllowedCorsOrigins != null && AllowedCorsOrigins.SequenceEqual(other.AllowedCorsOrigins) ) && ( PostLogoutRedirectUris == other.PostLogoutRedirectUris || PostLogoutRedirectUris != null && other.PostLogoutRedirectUris != null && PostLogoutRedirectUris.SequenceEqual(other.PostLogoutRedirectUris) ) && ( AllowedScopes == other.AllowedScopes || AllowedScopes != null && other.AllowedScopes != null && AllowedScopes.SequenceEqual(other.AllowedScopes) ) && ( ClientSecrets == other.ClientSecrets || ClientSecrets != null && other.ClientSecrets != null && ClientSecrets.SequenceEqual(other.ClientSecrets) ) && ( HashedClientSecrets == other.HashedClientSecrets || HashedClientSecrets != null && other.HashedClientSecrets != null && HashedClientSecrets.SequenceEqual(other.HashedClientSecrets) ) && ( AllowedOfflineAccess == other.AllowedOfflineAccess || AllowedOfflineAccess.Equals(other.AllowedOfflineAccess) ) && ( AccessTokenLifetime == other.AccessTokenLifetime || AccessTokenLifetime.Equals(other.AccessTokenLifetime) ) && ( IdentityTokenLifetime == other.IdentityTokenLifetime || IdentityTokenLifetime.Equals(other.IdentityTokenLifetime) )); }
public void AddEmptyCORSUrl() => AllowedCorsOrigins.Add(new SimpleValue <string>(String.Empty));
public void UpdateEntity(IdentityServer4.EntityFramework.Entities.Client entity) { entity.Enabled = Enabled; entity.ClientId = ClientId; entity.ProtocolType = ProtocolType; entity.RequireClientSecret = RequireClientSecret; entity.ClientName = ClientName; entity.Description = Description; entity.ClientUri = ClientUri; entity.LogoUri = LogoUri; entity.RequireConsent = RequireConsent; entity.AllowRememberConsent = AllowRememberConsent; entity.AlwaysIncludeUserClaimsInIdToken = AlwaysIncludeUserClaimsInIdToken; entity.AllowedGrantTypes = AllowedGrantTypes.Select(x => new ClientGrantType { GrantType = x, }).ToList(); entity.RequirePkce = RequirePkce; entity.AllowPlainTextPkce = AllowPlainTextPkce; entity.AllowAccessTokensViaBrowser = AllowAccessTokensViaBrowser; entity.RedirectUris = RedirectUris.Select(x => new ClientRedirectUri { RedirectUri = x, }).ToList(); entity.PostLogoutRedirectUris = PostLogoutRedirectUris.Select(x => new ClientPostLogoutRedirectUri { PostLogoutRedirectUri = x, }).ToList(); entity.FrontChannelLogoutUri = FrontChannelLogoutUri; entity.FrontChannelLogoutSessionRequired = FrontChannelLogoutSessionRequired; entity.BackChannelLogoutUri = BackChannelLogoutUri; entity.BackChannelLogoutSessionRequired = BackChannelLogoutSessionRequired; entity.AllowOfflineAccess = AllowOfflineAccess; entity.AllowedScopes = AllowedScopes.Select(x => new ClientScope { Scope = x, }).ToList(); entity.IdentityTokenLifetime = IdentityTokenLifetime; entity.AccessTokenLifetime = AccessTokenLifetime; entity.AuthorizationCodeLifetime = AuthorizationCodeLifetime; entity.ConsentLifetime = ConsentLifetime; entity.AbsoluteRefreshTokenLifetime = AbsoluteRefreshTokenLifetime; entity.SlidingRefreshTokenLifetime = SlidingRefreshTokenLifetime; entity.RefreshTokenUsage = (int)RefreshTokenUsage; entity.UpdateAccessTokenClaimsOnRefresh = UpdateAccessTokenClaimsOnRefresh; entity.RefreshTokenExpiration = (int)RefreshTokenExpiration; entity.AccessTokenType = (int)AccessTokenType; entity.EnableLocalLogin = EnableLocalLogin; entity.IdentityProviderRestrictions = IdentityProviderRestrictions.Select(x => new ClientIdPRestriction { Provider = x, }).ToList(); entity.IncludeJwtId = IncludeJwtId; entity.AlwaysSendClientClaims = AlwaysSendClientClaims; entity.ClientClaimsPrefix = ClientClaimsPrefix; entity.PairWiseSubjectSalt = PairWiseSubjectSalt; entity.AllowedCorsOrigins = AllowedCorsOrigins.Select(x => new ClientCorsOrigin { Origin = x, }).ToList(); entity.UserSsoLifetime = UserSsoLifetime; entity.UserCodeType = UserCodeType; entity.DeviceCodeLifetime = DeviceCodeLifetime; }