public async Task RegisterApi(ClientInsertModel clientData) { //var apiResource = new ApiResource(clientData.ApiName); ///*{ _mapper.Map<ApiResource>(clientData);*/ //await _context.ApiResources.AddAsync(apiResource.ToEntity()); //await _context.SaveChangesAsync(); }
public Client Map(ClientInsertModel insertModel) { var client = _mapper.Map <Client>(insertModel); client.AllowOfflineAccess = false; client.AllowedGrantTypes = GrantTypes.Implicit; client.AllowAccessTokensViaBrowser = true; client.RedirectUris = insertModel.RedirectUris.Split(",").Select(x => x.Trim()).ToList(); client.PostLogoutRedirectUris = insertModel.PostLogoutUris.Split(",").Select(x => x.Trim()).ToList(); client.LogoUri = client.LogoUri ?? "/images/oauth-app-default.svg"; return(client); }
public async Task <IActionResult> Add(ClientInsertModel clientDto) { _userId = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == "sub").Value); if (clientDto.Type.Equals("oauth-client") && clientDto.ClientLogo != null) { var fileName = $"images/Clients/{Guid.NewGuid()}{Path.GetExtension(clientDto.ClientLogo.FileName)}"; await _filesSvc.SaveFile(fileName, clientDto.ClientLogo); clientDto.LogoUri = fileName; } var pwd = _clientSvc.AddClient(clientDto, _userId); return(RedirectToAction(nameof(NewClient), new { pass = pwd })); }
public Client Map(ClientInsertModel insertModel) { var client = new Client(); client.ClientId = $"client-{Guid.NewGuid()}"; client.ClientName = insertModel.ClientName; client.AllowOfflineAccess = true; client.AllowedGrantTypes = GrantTypes.ClientCredentials; //client.Claims.Add(new Claim("GameName", client.ClientName)); client.AllowedScopes.Add("Platform.ScoreService"); client.AllowedScopes.Add("Platform.GameCatalogService"); client.AllowedScopes.Add("Platform.ProfileService"); client.LogoUri = client.LogoUri ?? "/images/server-app-default.svg"; return(client); }
public string AddClient(ClientInsertModel clientDto, Guid userId) { var client = new Client(); var clientPwd = $"secret-{Guid.NewGuid()}"; switch (clientDto.Type) { case "oauth-client": client = _mapper.MapClient(new ImplicitClientMapStrategy(_mapper), clientDto); break; case "application": client = _mapper.MapClient(new ApplicationClientMapStrategy(_mapper), clientDto); client.ClientSecrets.Remove(client.ClientSecrets.FirstOrDefault()); client.ClientSecrets.Add(new Secret(clientPwd.Sha256())); break; default: break; } _context.Add(client.ToEntity()); var user = _userCtx.Users.Include(u => u.Clients).FirstOrDefault(u => u.SubjectId == userId); user.Clients.Add(new UserClient() { UserId = userId, ClientId = client.ClientId, User = user }); _userCtx.Users.Update(user); _userCtx.SaveChanges(); _context.SaveChanges(); return(clientPwd); }
public static Client MapClient(this IMapper mapper, IClientMapStrategy strategy, ClientInsertModel client) => strategy.Map(client);