aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/IdentityServer
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2020-08-11 21:16:02 +0200
committerivarlovlie <git@ivarlovlie.no>2020-08-11 21:16:02 +0200
commita5f1018fda5572912c126b1e8dd656209fca0e46 (patch)
tree8e6ae53e8f190bad395dc8c974c41ab376889a9e /src/server/IdentityServer
parent69854dca474bf73eec9f8fcbf20f328e4453c8cf (diff)
downloaddough-a5f1018fda5572912c126b1e8dd656209fca0e46.tar.xz
dough-a5f1018fda5572912c126b1e8dd656209fca0e46.zip
persisted grants
Diffstat (limited to 'src/server/IdentityServer')
-rw-r--r--src/server/IdentityServer/Config.cs7
-rw-r--r--src/server/IdentityServer/ProfileService.cs25
2 files changed, 20 insertions, 12 deletions
diff --git a/src/server/IdentityServer/Config.cs b/src/server/IdentityServer/Config.cs
index c005377..ac38aa4 100644
--- a/src/server/IdentityServer/Config.cs
+++ b/src/server/IdentityServer/Config.cs
@@ -18,20 +18,15 @@ namespace Dough.IdentityServer
ClientId = BrowserClientId,
AllowedGrantTypes = GrantTypes.Code,
RequireClientSecret = false,
-
RedirectUris = Constants.BrowserAppLoginRedirectUrls,
PostLogoutRedirectUris = Constants.BrowserAppLogoutRedirectUrls,
AllowedCorsOrigins = Constants.BrowserAppUrls,
AccessTokenType = AccessTokenType.Reference,
RequireConsent = false,
RefreshTokenExpiration = TokenExpiration.Sliding,
+ RefreshTokenUsage = TokenUsage.ReUse,
AlwaysSendClientClaims = true,
AllowOfflineAccess = true,
- Claims = new List<ClientClaim>
- {
- new ClientClaim()
- },
-
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
diff --git a/src/server/IdentityServer/ProfileService.cs b/src/server/IdentityServer/ProfileService.cs
index 197086c..0c14dd5 100644
--- a/src/server/IdentityServer/ProfileService.cs
+++ b/src/server/IdentityServer/ProfileService.cs
@@ -1,8 +1,11 @@
-using System.Reflection;
+using System;
+using System.Collections.Generic;
+using System.Security.Claims;
using System.Threading.Tasks;
+using Dough.Models;
using Dough.Models.Database;
using Dough.Utilities;
-using IdentityServer4;
+using IdentityModel;
using IdentityServer4.Models;
using IdentityServer4.Services;
@@ -17,14 +20,24 @@ namespace Dough.IdentityServer
_context = context;
}
- public Task GetProfileDataAsync(ProfileDataRequestContext context)
+ public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
- throw new System.NotImplementedException();
+ var userId = context.Subject.GetClaimValueOrDefault(JwtClaimTypes.Subject)?.ToGuidOrDefault();
+ if (userId == default) return;
+ var user = _context.Users.SingleOrDefault((Guid) userId);
+ var claims = new List<Claim>
+ {
+ new Claim(JwtClaimTypes.PreferredUserName, user.Username)
+ };
+ context.AddRequestedClaims(claims);
}
- public Task IsActiveAsync(IsActiveContext context)
+ public async Task IsActiveAsync(IsActiveContext context)
{
- return default;
+ var userId = context.Subject.GetClaimValueOrDefault(JwtClaimTypes.Subject)?.ToGuidOrDefault();
+ if (userId == default) return;
+ var user = _context.Users.SingleOrDefault((Guid) userId);
+ context.IsActive = !user.Hidden;
}
}
} \ No newline at end of file