コード例 #1
0
        private static (ApiResource apiResource, ApiScope scope) ToDuende(this Scope ids3Scope)
        {
            if (ids3Scope == null)
            {
                return(null, null);
            }
            if (ids3Scope.Type != (int)ScopeType.Resource)
            {
                return(null, null);
            }

            var scope = new ApiScope
            {
                Name                    = ids3Scope.Name,
                DisplayName             = ids3Scope.DisplayName,
                Description             = ids3Scope.Description,
                Emphasize               = ids3Scope.Emphasize,
                Required                = ids3Scope.Required,
                ShowInDiscoveryDocument = ids3Scope.ShowInDiscoveryDocument,
                Properties              = new Dictionary <string, string>()
            };

            var apiResource = new ApiResource
            {
                Name        = ids3Scope.Name,
                DisplayName = ids3Scope.DisplayName,
                Description = ids3Scope.Description,
                Enabled     = ids3Scope.Enabled,
                Scopes      = new List <string> {
                    ids3Scope.Name
                },
                ApiSecrets = ids3Scope.ScopeSecrets?.Select(x => x.ToDuende()).ToList(),
                UserClaims = ids3Scope.ScopeClaims?.Select(x => x.Name).ToList(),
                Properties = new Dictionary <string, string>()
            };

            return(apiResource, scope);
        }
        private static IdentityResource ToDuende(this Scope scope)
        {
            if (scope == null)
            {
                return(null);
            }
            if (scope.Type != (int)ScopeType.Identity)
            {
                return(null);
            }

            return(new IdentityResource
            {
                Name = scope.Name,
                DisplayName = scope.DisplayName,
                Description = scope.Description,
                Enabled = scope.Enabled,
                Emphasize = scope.Emphasize,
                Required = scope.Required,
                ShowInDiscoveryDocument = scope.ShowInDiscoveryDocument,
                UserClaims = scope.ScopeClaims?.Select(x => x.Name).ToList()
            });
        }