Beispiel #1
0
        public static IEnumerable <IdentityResource> LoadIdentityResources(IConfiguration configuration)
        {
            var defaultResources = new IdentityResource[]
            {
                // some standard scopes from the OIDC spec
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
                new IdentityResources.Email()
            };

            var resources = configuration.GetSection("Scopes:Identity").Get <IdentityResourceOption[]>();

            if (resources == null)
            {
                return(defaultResources);
            }

            var customResources = from r in resources
                                  select new IdentityResource(r.Name, r.DisplayName, r.UserClaims)
            {
                Enabled                 = r.Enabled,
                Description             = r.Description,
                Emphasize               = r.Emphasize,
                Required                = r.Required,
                ShowInDiscoveryDocument = r.ShowInDiscoveryDocument
            };

            return(defaultResources.Concat(customResources));
        }