Browse Source

Added username claim to API claims available in token

tags/3.0.0^2
Teknikode 10 months ago
parent
commit
389023c3eb

+ 1
- 1
IdentityServer/Configuration.cs View File

@@ -90,7 +90,7 @@ namespace Teknik.IdentityServer.Configuration
Name = config.UserConfig.IdentityServerConfig.APIName,
DisplayName = "Teknik API",
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()) },
Scopes = new List<Scope> {
new Scope("teknik-api.read", "Teknik API Read Access"),

+ 3
- 6
Teknik/Areas/API/V1/Controllers/UploadAPIv1Controller.cs View File

@@ -41,13 +41,10 @@ namespace Teknik.Areas.API.V1.Controllers
if (User.Identity.IsAuthenticated)
{
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);
if (userInfo.AccountType == AccountType.Premium)
{
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
}
if (model.file.Length <= maxUploadSize)

+ 3
- 6
Teknik/Areas/Upload/Controllers/UploadController.cs View File

@@ -66,13 +66,10 @@ namespace Teknik.Areas.Upload.Controllers
if (User.Identity.IsAuthenticated)
{
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);
if (userInfo.AccountType == AccountType.Premium)
{
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
maxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
}
}
if (uploadFile.file.Length <= maxUploadSize)

Loading…
Cancel
Save