everything works now
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-05-19 23:14:57 +02:00
parent 0b01340e88
commit beab15a7ef
10 changed files with 168 additions and 32 deletions

View File

@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System;
using System.Data;
using System.Net.Mime;
using System.Security.Claims;
@ -34,10 +34,10 @@ namespace HanyadikHetVan.Controllers.V1
[Produces(MediaTypeNames.Application.Json)]
public string Protected()
{
return this.User.FindFirst(ClaimTypes.Role).Value;
return this.User.FindFirst("user_role").Value;
}
[Authorize(Roles = "admin")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[HttpGet("roleprotected")]
[Produces(MediaTypeNames.Application.Json)]
public string RoleProtected()

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace HanyadikHetVan.Controllers.V2
@ -20,8 +21,8 @@ namespace HanyadikHetVan.Controllers.V2
_funfactService = funfactService ?? throw new ArgumentNullException(nameof(funfactService));
}
[HttpPut("{weeklytimespanId}")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(FunFactDTO))]
[HttpGet("WeeklyTimeSpan/{weeklytimespanId}")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List<FunFactDTO>))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetFunFactOfWeeklyTimeSpan(int weeklytimespanId)
{

View File

@ -1,5 +1,6 @@
using HanyadikHetVan.DTO;
using HanyadikHetVan.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -41,7 +42,7 @@ namespace HanyadikHetVan.Controllers.V2
}
}
[HttpDelete("{pauseId}")]
[Authorize(Roles = "admin")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WeeklyTimeSpanDTO))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -58,7 +59,7 @@ namespace HanyadikHetVan.Controllers.V2
}
}
[HttpPut]
[Authorize(Roles = "admin")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(PauseDTO))]
[ProducesResponseType(StatusCodes.Status404NotFound)]

View File

@ -1,6 +1,7 @@
using HanyadikHetVan.Data.Entities;
using HanyadikHetVan.DTO;
using HanyadikHetVan.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
@ -46,7 +47,7 @@ namespace HanyadikHetVan.Controllers.V2
}
}
[HttpDelete("{weeklyTimeSpanId}")]
[Authorize(Roles = "admin")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(bool))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -63,7 +64,7 @@ namespace HanyadikHetVan.Controllers.V2
}
}
[HttpPut]
[Authorize(Roles = "admin")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WeeklyTimeSpanDTO))]
[ProducesResponseType(StatusCodes.Status404NotFound)]