private void FillConsentModel( string returnUrl, AuthorizationRequest request, Client client, Resources resources) { Input = Input ?? new InputModel(); Input.RememberConsent = Input?.RememberConsent ?? true; Input.ScopesConsented = Input?.ScopesConsented ?? Enumerable.Empty <string>(); ClientName = client.ClientName ?? client.ClientId; ClientUrl = client.ClientUri; ClientLogoUrl = client.LogoUri; AllowRememberConsent = client.AllowRememberConsent; IdentityScopes = resources.IdentityResources.Select(x => CreateScopeViewModel(x, Input.ScopesConsented.Contains(x.Name))).ToArray(); ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => CreateScopeViewModel(x, Input.ScopesConsented.Contains(x.Name))).ToArray(); if (ConsentOptions.EnableOfflineAccess && resources.OfflineAccess) { ResourceScopes = ResourceScopes.Union(new ScopeViewModel[] { GetOfflineAccessScope(Input.ScopesConsented.Contains(IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess)) }); } }
public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources) { RememberConsent = model?.RememberConsent ?? true; ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty <string>(); ReturnUrl = returnUrl; ClientName = client.ClientName; ClientUrl = client.ClientUri; ClientLogoUrl = client.LogoUri; AllowRememberConsent = client.AllowRememberConsent; IdentityScopes = resources.IdentityResources.Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); if (resources.OfflineAccess) { ResourceScopes = ResourceScopes.Union(new ScopeViewModel[] { ScopeViewModel.GetOfflineAccess(ScopesConsented.Contains(IdentityServerConstants.StandardScopes.OfflineAccess) || model == null) }); } }
public ResourceScopeAttribute(ResourceScopes resourceScope) { ResourceScope = resourceScope; }