44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using Asp.Versioning;
|
|
using GerstITS.Examples.Api.Versioning;
|
|
using GerstITS.Validation;
|
|
using GerstITS.Web.Api;
|
|
using GerstITS.Web.Api.FluentApi;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace GerstITS.Examples.Api.Controllers._1._1;
|
|
|
|
/// <summary>
|
|
/// Is responsible to demonstrate open id (jwt bearer) protected endpoints.
|
|
/// </summary>
|
|
[ApiController,
|
|
ApiVersion(Versions._1_1),
|
|
Authorize,
|
|
Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)]
|
|
public class SecuredController : FluentApiControllerBase
|
|
{
|
|
#region Constructors
|
|
|
|
public SecuredController(IValidator validator)
|
|
: base(validator)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Gets the name of the authenticated user. Requires a valid bearer token.
|
|
/// </summary>
|
|
/// <returns>Returns the name of the authenticated user.</returns>
|
|
[HttpGet,
|
|
Route("Me")]
|
|
public IActionResult Me()
|
|
{
|
|
return Api().Get(() => User.Identity.Name);
|
|
}
|
|
|
|
#endregion
|
|
}
|