public async Task <IActionResult> DenyClient(string clientRef) { var clientReference = Guid.Parse(clientRef); var client = ClientAuthorizationStack.Get(clientReference); var response = await PostToApi("UsersClients", new CreateUserClientDto() { ClientPublicId = client.ClientPublicId, IsActif = false }); var url = $"{_conf.OAuthApiUrl.AbsoluteUri}authorize?response_type={client.ResponseType}" + $"&client_id={client.ClientPublicId}" + $"&state={client.State}" + $"&scope={client.Scope}" + $"&redirect_uri={client.RedirectUri}"; if (((int)response.StatusCode) < 300) { return(Redirect(url)); } // TODO manage exceptions throw new Exception("TODO mécanisme exception"); }
public async Task <ActionResult> AuthorizeClient([FromQuery(Name = "response_type")] string responseType, [FromQuery(Name = "client_id")] string clientId, [FromQuery(Name = "state")] string state, [FromQuery(Name = "redirect_uri")] Uri redirectUri, [FromQuery(Name = "scope")] string scope) { var nv = new NameValueCollection(); nv.Add("skip", "0"); nv.Add("limit", "50"); nv.Add("publicId", clientId); var response = await GetToApi($"Clients", nv); var clients = JsonConvert.DeserializeObject <SearchResult <ClientDto> >(await response.Content.ReadAsStringAsync()); // check client validity var myClient = clients.Datas.FirstOrDefault(); if (myClient == null) { throw new Exception("TODO exception si client null"); // TODO manage exceptions } var clientRef = ClientAuthorizationStack.Add(new ClientRedirectInfo(responseType, redirectUri, scope, state, clientId)); var model = new AuthorizeClientModel() { ClientName = myClient.Name, ClientRef = clientRef.ToString() }; if (myClient.Scopes != null) { model.NiceWordingScopes = myClient.Scopes. Select(s => s.NiceWording).ToList(); } return(View(model)); }