public static ApiResourcePoco GetApis(string apiName)
        {
            ApiResourcePoco g = null;

            g = GetApis().FirstOrDefault(c => c.Name == apiName);
            return(g);
        }
Exemple #2
0
        /// <summary>
        /// Maps a Api resource poco to a Identity Server ApiResource
        /// </summary>
        /// <param name="poco" cref='ApiResourcePoco'>ApiResourcePoco</param>
        /// <returns cref='ApiResource'>ApiResource</returns>
        public static ApiResource Map(ApiResourcePoco poco)
        {
            ApiResource result = new ApiResource {
                Name = poco.Name,

                ApiSecrets = { new Secret((poco.ApiSecrets).Sha256()) },

                Description = poco.Description,

                DisplayName = poco.DisplayName,

                Enabled = poco.Enabled,

                Scopes = MapApiScopes(poco.ApiScopes),

                UserClaims =
                {
                    JwtClaimTypes.Name,
                    JwtClaimTypes.Email,
                    JwtClaimTypes.Role,
                    JwtClaimTypes.Subject
                }
            };

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Maps a Identity Server ApiResource to an Api resource poco to a
        /// </summary>
        /// <param name="poco" cref='ApiResource'>ApiResource</param>
        /// <returns cref='ApiResourcePoco'>ApiResourcePoco</returns>
        public static ApiResourcePoco Map(ApiResource api)
        {
            ApiResourcePoco result = new ApiResourcePoco
            {
                Name        = api.Name,
                ApiSecrets  = "*****",
                DisplayName = api.DisplayName,
                Description = api.Description,
                UserClaims  = MapUserClaims(api.UserClaims),
                ApiScopes   = MapApiScopes(api.Scopes)
            };

            return(result);
        }
 public Task<ApiResource> FindApiResourceAsync(string name)
 {
     ApiResourcePoco apiPoco = _repo.FindApiRecourceByNameAsync(name).Result;
     ApiResource Result = ApiMapper.Map(apiPoco);
     return Task.FromResult<ApiResource>(Result);
 }