Пример #1
0
        /// <summary>
        /// 添加一个客户端
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <OperationResponse> CreateAsync(ClientInputDto input)
        {
            input.NotNull(nameof(input));
            PrepareClientTypeForNewClient(input);
            var cliententity = new Client(input.ClientId, input.ClientName, input.AllowAccessTokensViaBrowser, input.AllowOfflineAccess);

            //var cliententity = new Client();
            cliententity.AddGrantTypes(input.AllowedGrantTypes);
            return(await _clientDomainService.CreateAsync(cliententity));
        }
Пример #2
0
        /// <summary>
        /// 客户端设置授权类型
        /// </summary>
        /// <param name="input"></param>
        private void PrepareClientTypeForNewClient(ClientInputDto input)
        {
            switch (input.ClientType)
            {
            case ClientTypeEnum.Implicit:
                input.AllowedGrantTypes.AddRange(GrantTypes.Implicit);
                break;

            case ClientTypeEnum.ImplicitAndClientCredentials:
                input.AllowedGrantTypes.AddRange(GrantTypes.ImplicitAndClientCredentials);
                break;

            case ClientTypeEnum.Code:
                input.AllowedGrantTypes.AddRange(GrantTypes.Code);
                break;

            case ClientTypeEnum.Hybrid:
                input.AllowedGrantTypes.AddRange(GrantTypes.Hybrid);
                break;

            case ClientTypeEnum.HybridAndClientCredentials:
                input.AllowedGrantTypes.AddRange(GrantTypes.HybridAndClientCredentials);
                break;

            case ClientTypeEnum.ClientCredentials:
                input.AllowedGrantTypes.AddRange(GrantTypes.ClientCredentials);
                break;

            case ClientTypeEnum.ResourceOwnerPassword:
                input.AllowedGrantTypes.AddRange(GrantTypes.ResourceOwnerPassword);
                break;

            case ClientTypeEnum.ResourceOwnerPasswordAndClientCredentials:
                input.AllowedGrantTypes.AddRange(GrantTypes.ResourceOwnerPasswordAndClientCredentials);
                break;

            case ClientTypeEnum.DeviceFlow:
                input.AllowedGrantTypes.AddRange(GrantTypes.DeviceFlow);
                break;
            }
        }
Пример #3
0
 public async Task <AjaxResult> CreateAsync([FromBody] ClientInputDto input)
 {
     return((await _clientContract.CreateAsync(input)).ToAjaxResult());
 }