/// <summary>
    /// Adds an address resource.
    /// </summary>
    /// <param name="configure">The <see cref="Action{IdentityResourceBuilder}"/> to configure the address scope.</param>
    public void AddAddress(Action <IdentityResourceBuilder> configure)
    {
        var resource = IdentityResourceBuilder.Address();

        configure(resource);
        Add(resource.Build());
    }
예제 #2
0
    public void Configure(ApiAuthorizationOptions options)
    {
        var data = _configuration.Get <IdentityResourceDefinition>();

        if (data != null && data.Scopes != null)
        {
            var scopes = ParseScopes(data.Scopes);
            if (scopes != null && scopes.Length > 0)
            {
                ClearDefaultIdentityResources(options);
            }
            foreach (var scope in scopes)
            {
                switch (scope)
                {
                case Duende.IdentityServer.IdentityServerConstants.StandardScopes.OpenId:
                    options.IdentityResources.Add(IdentityResourceBuilder.OpenId()
                                                  .AllowAllClients()
                                                  .FromConfiguration()
                                                  .Build());
                    break;

                case Duende.IdentityServer.IdentityServerConstants.StandardScopes.Profile:
                    options.IdentityResources.Add(IdentityResourceBuilder.Profile()
                                                  .AllowAllClients()
                                                  .FromConfiguration()
                                                  .Build());
                    break;

                case Duende.IdentityServer.IdentityServerConstants.StandardScopes.Address:
                    options.IdentityResources.Add(IdentityResourceBuilder.Address()
                                                  .AllowAllClients()
                                                  .FromConfiguration()
                                                  .Build());
                    break;

                case Duende.IdentityServer.IdentityServerConstants.StandardScopes.Email:
                    options.IdentityResources.Add(IdentityResourceBuilder.Email()
                                                  .AllowAllClients()
                                                  .FromConfiguration()
                                                  .Build());
                    break;

                case Duende.IdentityServer.IdentityServerConstants.StandardScopes.Phone:
                    options.IdentityResources.Add(IdentityResourceBuilder.Phone()
                                                  .AllowAllClients()
                                                  .FromConfiguration()
                                                  .Build());
                    break;

                default:
                    throw new InvalidOperationException($"Invalid identity resource name '{scope}'");
                }
            }
        }
    }
 /// <summary>
 /// Adds an address resource.
 /// </summary>
 public void AddAddress() =>
 Add(IdentityResourceBuilder.Address().Build());