Skip to content

Instantly share code, notes, and snippets.

View Mgs25's full-sized avatar
🏢

Methran GS Mgs25

🏢
View GitHub Profile
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(o =>
{
o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
{
Name = "Authorization",
public class Student
{
public string Name { get; set; } = null!;
public int Age { get; set; }
public Gender Gender { get; set; }
}
public enum Gender
{
Male = 1,
Female = 2
}
[ApiController]
[Authorize]
[Route("[controller]")]
public class StudentController : ControllerBase
{
private static readonly Student[] StudentNames = new[]
{
new Student() {
Name = "Methran",
Age = 19,
public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public BasicAuthenticationHandler(
IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock
) : base(options, logger, encoder, clock)
{
}