mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix startup issue with jwt
This commit is contained in:
parent
673cb48b75
commit
9468346617
@ -120,11 +120,8 @@ namespace Kyoo.Authentication
|
|||||||
FileProvider = provider
|
FileProvider = provider
|
||||||
});
|
});
|
||||||
}, SA.StaticFiles),
|
}, SA.StaticFiles),
|
||||||
SA.New<IApplicationBuilder>(app =>
|
SA.New<IApplicationBuilder>(app => app.UseAuthentication(), SA.Authentication),
|
||||||
{
|
// SA.New<IApplicationBuilder>(app => app.UseAuthorization(), SA.Authorization)
|
||||||
app.UseAuthentication();
|
|
||||||
}, SA.Authentication),
|
|
||||||
SA.New<IApplicationBuilder>(app => app.UseAuthorization(), SA.Authorization)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,14 +161,23 @@ namespace Kyoo.Authentication.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get authenticated user.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Get information about the currently authenticated user. This can also be used to ensure that you are
|
||||||
|
/// logged in.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>The currently authenticated user.</returns>
|
||||||
|
/// <response code="403">The given access token is invalid.</response>
|
||||||
[HttpGet("me")]
|
[HttpGet("me")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<User>> GetMe()
|
public async Task<ActionResult<User>> GetMe()
|
||||||
{
|
{
|
||||||
if (!int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out int userID))
|
if (!int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out int userID))
|
||||||
return BadRequest("Invalid access token");
|
return Forbid();
|
||||||
return await _users.GetById(userID);
|
return await _users.Get(userID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ namespace Kyoo.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Configure(IServiceCollection services)
|
public void Configure(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddHttpContextAccessor();
|
||||||
services.AddTransient<IConfigureOptions<MvcNewtonsoftJsonOptions>, JsonOptions>();
|
services.AddTransient<IConfigureOptions<MvcNewtonsoftJsonOptions>, JsonOptions>();
|
||||||
|
|
||||||
services.AddMvcCore()
|
services.AddMvcCore()
|
||||||
|
@ -161,7 +161,8 @@ namespace Kyoo.Host.Generic
|
|||||||
.OrderByDescending(x => x.Priority);
|
.OrderByDescending(x => x.Priority);
|
||||||
|
|
||||||
using ILifetimeScope scope = container.BeginLifetimeScope(x =>
|
using ILifetimeScope scope = container.BeginLifetimeScope(x =>
|
||||||
x.RegisterInstance(app).SingleInstance().ExternallyOwned());
|
x.RegisterInstance(app).SingleInstance().ExternallyOwned()
|
||||||
|
);
|
||||||
IServiceProvider provider = scope.Resolve<IServiceProvider>();
|
IServiceProvider provider = scope.Resolve<IServiceProvider>();
|
||||||
foreach (IStartupAction step in steps)
|
foreach (IStartupAction step in steps)
|
||||||
step.Run(provider);
|
step.Run(provider);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user