using DevExpress.ExpressApp; using DevExpress.ExpressApp.Security; using DevExpress.ExpressApp.Security.Authentication; using DevExpress.ExpressApp.Security.Authentication.ClientServer; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; namespace DurnyklyYol.WebApi.JWT; [ApiController] [Route("api/[controller]")] // This is a JWT authentication service sample. public class AuthenticationController : ControllerBase { readonly IAuthenticationTokenProvider tokenProvider; public AuthenticationController(IAuthenticationTokenProvider tokenProvider) { this.tokenProvider = tokenProvider; } [HttpPost("Authenticate")] [SwaggerOperation("Checks if the user with the specified logon parameters exists in the database. If it does, authenticates this user.", "Refer to the following help topic for more information on authentication methods in the XAF Security System: Authentication.")] public IActionResult Authenticate( [FromBody] [SwaggerRequestBody(@"For example:
{ ""userName"": ""Admin"", ""password"": """" }")] AuthenticationStandardLogonParameters logonParameters ) { try { return Ok(tokenProvider.Authenticate(logonParameters)); } catch(AuthenticationException ex) { return Unauthorized(ex.GetJson()); } } }