private void CreateInputModel(string returnUrl, Client client, Resources resources) { bool showDefault = false; // if page is loading for the first time, this is used to set default scope checkboxes to checked if (Input == null) { showDefault = true; Input = new InputModel { RememberConsent = true }; } ScopesConsented = ScopesConsented ??= Enumerable.Empty <string>(); Input.ReturnUrl = returnUrl; ClientName = client.ClientName ?? client.ClientId; ClientUrl = client.ClientUri; ClientLogoUrl = client.LogoUri; AllowRememberConsent = client.AllowRememberConsent; IdentityScopes = resources.IdentityResources.Select(x => CreateScopeViewModel(x, ScopesConsented.Contains(x.Name) || showDefault)).ToList(); ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => CreateScopeViewModel(x, ScopesConsented.Contains(x.Name) || showDefault)).ToList(); if (ConsentOptions.EnableOfflineAccess && resources.OfflineAccess) { ResourceScopes = ResourceScopes.Union(new ScopeViewModel[] { GetOfflineAccessScope(ScopesConsented.Contains(IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess) || showDefault) }).ToList(); } }
public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources scopes) { 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 = scopes.IdentityResources.Select(x => new ScopeViewModel() { Name = x.Name, Description = x.Description, DisplayName = x.DisplayName, Emphasize = x.Emphasize, Required = x.Required, Checked = (ScopesConsented.Contains(x.Name) || model == null) || x.Required }).ToArray(); ResourceScopes = scopes.ApiResources.Select(x => new ScopeViewModel/*(ScopesConsented.Contains(x.Name) || model == null)*/ { Name = x.Name, Description = x.Description, DisplayName = x.DisplayName, Checked = (ScopesConsented.Contains(x.Name) || model == null) }).ToArray(); }
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.ApiScopes.Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); }
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 ConsentViewModel(ConsentInputModel model, string consentId, ConsentRequest request, Client client, IEnumerable <Scope> scopes, ILocalizationService localization) { RememberConsent = model?.RememberConsent ?? true; ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty <string>(); ConsentId = consentId; ClientName = client.ClientName; ClientUrl = client.ClientUri; ClientLogoUrl = client.LogoUri; AllowRememberConsent = client.AllowRememberConsent; IdentityScopes = scopes.Where(x => x.Type == ScopeType.Identity).Select(x => new ScopeViewModel(localization, x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); ResourceScopes = scopes.Where(x => x.Type == ScopeType.Resource).Select(x => new ScopeViewModel(localization, x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); }