Commit dc3c8f30 authored by Eric Dieckman's avatar Eric Dieckman
Browse files

Add session info

parent 32947d1f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@
        </member>
        <member name="T:Cals.Visor.Identity.VisorUser">
            <summary>
            <see cref="T:Cals.Authentication.IApplicationUser"/> for the Directory Edit app.
            <see cref="T:Cals.Authentication.IWiscEduUser"/> for VISOR app.
            </summary>
        </member>
        <member name="T:Cals.Web.ErrorHandling.EndpointExtractor">
+20 −0
Original line number Diff line number Diff line
using Cals.Visor.Identity;
using Microsoft.AspNetCore.Mvc;

namespace Cals.Visor.Api.Controllers;
[Route("[controller]")]
[ApiController]
public class SessionController : ControllerBase
{
    [ProducesResponseType(typeof(SessionInfo), StatusCodes.Status200OK)]
    [HttpGet("~/session_info", Name = "GetSessionInfo")]
    public IActionResult GetUserInfo()
    {
        var sessionInfo = new SessionInfo()
        {
            User = new VisorUser(HttpContext.User)
        };

        return Ok(sessionInfo);
    }
}
+8 −0
Original line number Diff line number Diff line
using Cals.Visor.Identity;

namespace Cals.Visor.Api;

public class SessionInfo
{
    public VisorUser? User { get; set; }
}
+2 −2
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@ using Cals.Authentication;
namespace Cals.Visor.Identity;

/// <summary>
/// <see cref="IApplicationUser"/> for the Directory Edit app.
/// <see cref="IWiscEduUser"/> for VISOR app.
/// </summary>
public class VisorUser : ClaimsApplicationUser, IApplicationUser
public class VisorUser : WiscEduOidcUser, IWiscEduUser
{
    public const string VisorAuthenticationType = "Visor";

+2 −13
Original line number Diff line number Diff line
@@ -139,17 +139,6 @@ builder.Services
                await Task.CompletedTask;
            }
        };

        //options.Events = new JwtBearerEvents
        //{
        //    OnTokenValidated = context =>
        //    {
        //        ClaimsIdentity identity = (ClaimsIdentity)context.Principal!.Identity!;
        //        var token = context.SecurityToken.RawData;
        //        identity.AddClaim(new Claim("access_token", token));
        //        return Task.CompletedTask;
        //    }
        //}
    });

// Enable lowercase routes for controllers
@@ -272,7 +261,7 @@ ServiceActivator.Configure(app.Services);
app.Run();

// Configures the Azure Key Vault for this app
void ConfigureAzureKeyVault(WebApplicationBuilder builder)
static void ConfigureAzureKeyVault(WebApplicationBuilder builder)
{
    if (!builder.Environment.IsDevelopment())
    {
@@ -308,7 +297,7 @@ void ConfigureAzureKeyVault(WebApplicationBuilder builder)
}

// Add the background service platform Quartz for internal commands and outbox
void ConfigureQuartz(IServiceCollection services)
static void ConfigureQuartz(IServiceCollection services)
{
    services.AddQuartz(q =>
    {