Require authorisation by default
This commit is contained in:
parent
18aecde93a
commit
6e732dbc69
3 changed files with 2 additions and 10 deletions
|
@ -1,5 +1,4 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Robware.Auth.API;
|
||||
|
@ -23,15 +22,12 @@ namespace Robware.Api.Auth.Controllers {
|
|||
public async Task<ActionResult> Validate(string key) => await _apiKeyValidator.Validate(key) ? (ActionResult) Ok() : Unauthorized();
|
||||
|
||||
[HttpPost(nameof(Create))]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<ApiKey>> Create(string name) => await _apiKeyRepository.Create(name);
|
||||
|
||||
[HttpGet(nameof(List))]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<ApiKey[]>> List() => (await _apiKeyRepository.GetAll()).ToArray();
|
||||
|
||||
[HttpDelete(nameof(Delete))]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> Delete(string key) => await _apiKeyRepository.Delete(key) ? (ActionResult) NoContent() : BadRequest();
|
||||
|
||||
private async Task<ActionResult> SetEnabled(string key, bool enabled) {
|
||||
|
@ -48,11 +44,9 @@ namespace Robware.Api.Auth.Controllers {
|
|||
}
|
||||
|
||||
[HttpPatch(nameof(Disable))]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> Disable(string key) => await SetEnabled(key, false);
|
||||
|
||||
[HttpPatch(nameof(Enable))]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> Enable(string key) => await SetEnabled(key, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue