Authentication finally moved to the dotnet way in webapi, ready to be added to to deal with users and such

Introspection access point properly uses basic auth of client id and secret to access
This commit is contained in:
2021-10-14 20:54:58 -04:00
parent 0dffa6e516
commit 320d939c76
9 changed files with 176 additions and 19 deletions

View File

@@ -2,33 +2,30 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WebAPI.Auth;
using WebAPI.Data;
namespace WebAPI.Controllers
{
[Authorize(Policy = "test")]
[Route("api/[controller]")]
[ApiController]
public class HelloWorldController : BaseController
{
private readonly PterodactylService _pterodactylService;
private readonly OIDCService _oidcService;
public HelloWorldController(PterodactylService pterodactylService, OIDCService oidcService)
public HelloWorldController(PterodactylService pterodactylService)
{
_pterodactylService = pterodactylService;
_oidcService = oidcService;
}
[HttpGet]
public async Task<string> HelloWorld()
{
if (await _oidcService.ValidateAccessToken(BearerToken))
{
return "Validated";
}
return "Failed";
return "Success";
}
}