Ejemplo n.º 1
0
        private void PrepareClientTypeForNewClient(CreateClientInput client)
        {
            switch (client.ClientType)
            {
            case ClientType.Empty:
                break;

            case ClientType.Hybrid:
                client.AllowedGrantTypes.AddRange(IdentityServer4.Models.GrantTypes.Hybrid);
                break;

            case ClientType.Spa:
                client.AllowedGrantTypes.AddRange(IdentityServer4.Models.GrantTypes.Code);
                client.RequirePkce         = true;
                client.RequireClientSecret = false;
                break;

            case ClientType.Implicit:
                client.AllowedGrantTypes.AddRange(IdentityServer4.Models.GrantTypes.Implicit);
                break;

            case ClientType.Machine:
                client.AllowedGrantTypes.AddRange(IdentityServer4.Models.GrantTypes.ResourceOwnerPasswordAndClientCredentials);
                break;

            case ClientType.Device:
                client.AllowedGrantTypes.AddRange(IdentityServer4.Models.GrantTypes.DeviceFlow);
                client.RequireClientSecret = false;
                client.AllowOfflineAccess  = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
        public async Task <ResponseBase <bool> > Create(CreateClientInput input)
        {
            var client = _mapper.Map <Client>(input);

            client.AllowedGrantTypes = input.AllowedGrantTypes.Select(a => new ClientGrantType()
            {
                GrantType = a
            }).ToList();
            client.RedirectUris = input.RedirectUris.Select(a => new ClientRedirectUri()
            {
                RedirectUri = a
            }).ToList();
            client.AllowedScopes = input.AllowedScopes.Select(a => new ClientScope()
            {
                Scope = a
            }).ToList();
            client.PostLogoutRedirectUris = input.PostLogoutRedirectUris.Select(a => new ClientPostLogoutRedirectUri()
            {
                PostLogoutRedirectUri = a
            }).ToList();
            await _clientRepository.Create(client);

            return(new ResponseBase <bool>()
            {
                Result = true
            });
        }
Ejemplo n.º 3
0
        public async Task Create(CreateClientInput input)
        {
            var client  = ObjectMapper.Map <Client>(input);
            var request = await _clientRepository.InsertAsync(client);

            var result = request;
        }
        public async Task Create([FromBody]
                                 CreateClientInput input)
        {
            var entity = _mapper.Map <Client>(input);
            await _clientsDbContext.Clients.AddAsync(entity);

            await _clientsDbContext.SaveChangesAsync();
        }
Ejemplo n.º 5
0
        public async Task <CreateClientOutput> CreateClient(CreateClientInput input)
        {
            var client          = input.MapTo <Client>();
            var createdClientId = await _clientManager.Create(client);

            return(new CreateClientOutput {
                Id = createdClientId
            });
        }
Ejemplo n.º 6
0
    public async Task <Client> CreateClient([Service] ApplicationDbContext db, CreateClientInput input)
    {
        var client = new Client
        {
            ClientId                          = input.ClientId,
            ClientName                        = input.ClientName,
            Created                           = DateTime.Now,
            Enabled                           = true,
            ProtocolType                      = "a",
            RequireClientSecret               = false,
            RequireConsent                    = false,
            AllowRememberConsent              = false,
            AlwaysIncludeUserClaimsInIdToken  = false,
            RequirePkce                       = false,
            AllowPlainTextPkce                = false,
            AllowAccessTokensViaBrowser       = false,
            FrontChannelLogoutSessionRequired = false,
            BackChannelLogoutSessionRequired  = false,
            AllowOfflineAccess                = false,
            IdentityTokenLifetime             = 1,
            AccessTokenLifetime               = 1,
            AuthorizationCodeLifetime         = 1,
            AbsoluteRefreshTokenLifetime      = 1,
            SlidingRefreshTokenLifetime       = 1,
            RefreshTokenUsage                 = 1,
            UpdateAccessTokenClaimsOnRefresh  = false,
            RefreshTokenExpiration            = 1,
            AccessTokenType                   = 1,
            EnableLocalLogin                  = false,
            IncludeJwtId                      = false,
            AlwaysSendClientClaims            = false,
            DeviceCodeLifetime                = 1,
            NonEditable                       = false
        };

        client.ClientSecrets = input.ClientSecrets.Select(cs => new ClientSecret()
        {
            Created     = DateTime.Now,
            Description = cs.Description,
            Expiration  = cs.Expiration,
            Type        = cs.Type,
            Value       = cs.Value
        }).ToList();

        db.Clients.Add(client);

        await db.SaveChangesAsync();

        return(client);
    }
Ejemplo n.º 7
0
        public async Task Execute(int id, CreateClientInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }
            var client = new User()
            {
                Name        = input.Name,
                Surname     = input.Surname,
                PhoneNumber = input.PhoneNumber,
                Email       = input.Email
            };
            await _clientRepository.Update(id, client);

            var createClientOutput = new CreateClientOutput(client.Name, client.Surname, client.PhoneNumber, client.Email);

            _outputHandler.Standard(createClientOutput);
        }
Ejemplo n.º 8
0
        public async Task Execute(CreateClientInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var client = new User()
            {
                Name        = input.Name,
                Surname     = input.Surname,
                PhoneNumber = input.PhoneNumber,
                Email       = input.Email,
                Password    = CryptUtils.EncryptPassword(input.Password),
                Role        = Role.Client
            };
            await _clientRepository.Register(client);

            var createClientOutput = new CreateClientOutput(client.Name, client.Surname, client.PhoneNumber, client.Email);

            _outputHandler.Standard(createClientOutput);
        }
Ejemplo n.º 9
0
        public async Task <ResponseBase <bool> > Create([FromBody] CreateClientInput input)
        {
            var result = await _clientService.Create(input);

            return(result);
        }
Ejemplo n.º 10
0
        //private readonly IRepository<Client, long> _clientRepository;

        //public ClientAppService(
        //    IRepository<Client, long> clientRepository)
        //{
        //    _clientRepository = clientRepository;
        //}
        public Task CreateClient(CreateClientInput input)
        {
            //_clientRepository.Create(input);
            throw new System.NotImplementedException();
        }
Ejemplo n.º 11
0
        public async Task <Client> AddClient(CreateClientInput input)
        {
            var client = input.MapTo <Client>();

            return(await _clientRepository.InsertAsync(client));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Create(CreateClientInput input)
        {
            await _ClientAppService.Create(input);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Update(int id, [FromBody] CreateClientInput input)
        {
            await _updateClientUseCase.Execute(id, input);

            return(_updateClientPresenter.ViewModel);
        }
        public async Task <IActionResult> Register([FromBody] CreateClientInput input)
        {
            await _registerClientUseCase.Execute(input);

            return(_registerClientPresenter.ViewModel);
        }
Ejemplo n.º 15
0
 public async System.Threading.Tasks.Task Create(CreateClientInput input)
 {
     var Client = ObjectMapper.Map <Client>(input);
     await _ClientRepository.InsertAsync(Client);
 }