1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Added username claim to API claims available in token

This commit is contained in:
Uncled1023 2019-01-17 23:53:49 -08:00
parent ec6240279b
commit 389023c3eb
3 changed files with 7 additions and 13 deletions

View File

@ -90,7 +90,7 @@ namespace Teknik.IdentityServer.Configuration
Name = config.UserConfig.IdentityServerConfig.APIName, Name = config.UserConfig.IdentityServerConfig.APIName,
DisplayName = "Teknik API", DisplayName = "Teknik API",
Description = "Teknik API Access for end users", Description = "Teknik API Access for end users",
UserClaims = new List<string> {"role"}, UserClaims = new List<string> {"role", "username"},
ApiSecrets = new List<Secret> {new Secret(config.UserConfig.IdentityServerConfig.APISecret.Sha256()) }, ApiSecrets = new List<Secret> {new Secret(config.UserConfig.IdentityServerConfig.APISecret.Sha256()) },
Scopes = new List<Scope> { Scopes = new List<Scope> {
new Scope("teknik-api.read", "Teknik API Read Access"), new Scope("teknik-api.read", "Teknik API Read Access"),

View File

@ -41,13 +41,10 @@ namespace Teknik.Areas.API.V1.Controllers
if (User.Identity.IsAuthenticated) if (User.Identity.IsAuthenticated)
{ {
maxUploadSize = _config.UploadConfig.MaxUploadSizeBasic; maxUploadSize = _config.UploadConfig.MaxUploadSizeBasic;
if (User.Identity.IsAuthenticated) IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(_config, User.Identity.Name);
if (userInfo.AccountType == AccountType.Premium)
{ {
IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(_config, User.Identity.Name); maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
if (userInfo.AccountType == AccountType.Premium)
{
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
} }
} }
if (model.file.Length <= maxUploadSize) if (model.file.Length <= maxUploadSize)

View File

@ -66,13 +66,10 @@ namespace Teknik.Areas.Upload.Controllers
if (User.Identity.IsAuthenticated) if (User.Identity.IsAuthenticated)
{ {
maxUploadSize = _config.UploadConfig.MaxUploadSizeBasic; maxUploadSize = _config.UploadConfig.MaxUploadSizeBasic;
if (User.Identity.IsAuthenticated) IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(_config, User.Identity.Name);
if (userInfo.AccountType == AccountType.Premium)
{ {
IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(_config, User.Identity.Name); maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
if (userInfo.AccountType == AccountType.Premium)
{
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
} }
} }
if (uploadFile.file.Length <= maxUploadSize) if (uploadFile.file.Length <= maxUploadSize)