This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
builder.Services.AddControllers(); | |
builder.Services.AddEndpointsApiExplorer(); | |
builder.Services.AddSwaggerGen(o => | |
{ | |
o.AddSecurityDefinition("basic", new OpenApiSecurityScheme | |
{ | |
Name = "Authorization", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student | |
{ | |
public string Name { get; set; } = null!; | |
public int Age { get; set; } | |
public Gender Gender { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Gender | |
{ | |
Male = 1, | |
Female = 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ApiController] | |
[Authorize] | |
[Route("[controller]")] | |
public class StudentController : ControllerBase | |
{ | |
private static readonly Student[] StudentNames = new[] | |
{ | |
new Student() { | |
Name = "Methran", | |
Age = 19, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> | |
{ | |
public BasicAuthenticationHandler( | |
IOptionsMonitor<AuthenticationSchemeOptions> options, | |
ILoggerFactory logger, | |
UrlEncoder encoder, | |
ISystemClock clock | |
) : base(options, logger, encoder, clock) | |
{ | |
} |