Esempio n. 1
0
        /// <summary>
        /// Update the specified role.
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public async Task <Models.RoleModel> UpdateRoleAsync(Models.RoleModel role)
        {
            var json     = role.Serialize();
            var content  = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await _client.PutAsync($"{this.Options.Admin.Authority}/roles-by-id/{role.Id}", content);

            return(response.HandleResponse(role));
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new composite role within the client specified by the 'clientId', the belongs to the role specified by the 'parentName'.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="parentName"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public async Task <Models.RoleModel> CreateCompositeRoleAsync(Guid clientId, string parentName, Models.RoleModel role)
        {
            var json     = role.Serialize();
            var content  = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await _client.PostAsync($"{this.Options.Admin.Authority}/clients/{clientId}/roles/{parentName}/composites", content);

            return(await response.HandleResponseAsync <Models.RoleModel>());
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new realm role.
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public async Task <Models.RoleModel> CreateRoleAsync(Models.RoleModel role)
        {
            var json = role.Serialize();

            using var content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await _client.PostAsync($"{this.Options.Admin.Authority}/roles", content);

            return(await response.HandleResponseAsync <Models.RoleModel>());
        }