NDB.Security.Authentication.Identity - guest user claim
parent
685be06f80
commit
67a9b643d8
|
@ -6,6 +6,7 @@
|
|||
<PackageProjectUrl>https://dev.azure.com/tstanciu94/NDB</PackageProjectUrl>
|
||||
<RepositoryUrl>https://dev.azure.com/tstanciu94/NDB</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<PackageTags>NDB Cache</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
namespace NDB.Security.Authentication.Identity.Constants
|
||||
{
|
||||
public struct ClaimTypes
|
||||
{
|
||||
public const string
|
||||
IsGuestUser = "IsGuestUser";
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ namespace NDB.Security.Authentication.Identity
|
|||
var authenticateAsGuest = _authenticationOptions.AuthenticateAsGuest?.Invoke(Request) ?? false;
|
||||
if (authenticateAsGuest)
|
||||
{
|
||||
var guestTicket = GetAuthenticationTicket(new User() { UserId = _authenticationOptions.GuestUserId, UserName = _authenticationOptions.GuestUserName });
|
||||
var guestTicket = GetAuthenticationTicket(new User() { UserId = _authenticationOptions.GuestUserId, UserName = _authenticationOptions.GuestUserName }, true);
|
||||
return AuthenticateResult.Success(guestTicket);
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,12 @@ namespace NDB.Security.Authentication.Identity
|
|||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
|
||||
private AuthenticationTicket GetAuthenticationTicket(User user)
|
||||
private AuthenticationTicket GetAuthenticationTicket(User user, bool isGuest = false)
|
||||
{
|
||||
var claims = new[] {
|
||||
new Claim(ClaimTypes.NameIdentifier, user.UserId.ToString()),
|
||||
new Claim(ClaimTypes.Name, user.UserName),
|
||||
new Claim(Constants.ClaimTypes.IsGuestUser, isGuest.ToString())
|
||||
};
|
||||
|
||||
var identity = new ClaimsIdentity(claims, Scheme.Name);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<RepositoryUrl>https://dev.azure.com/tstanciu94/NDB</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<PackageTags>NDB Authentication Identity</PackageTags>
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -22,7 +22,7 @@ dotnet nuget push NDB.Extensions.Swagger.1.0.2.nupkg -k ***REMOVED*** -s http://
|
|||
|
||||
dotnet nuget push NDB.Extensions.Http.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||
|
||||
dotnet nuget push NDB.Security.Authentication.Identity.1.0.2.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||
dotnet nuget push NDB.Security.Authentication.Identity.1.0.3.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||
|
||||
dotnet nuget push NDB.Extensions.Caching.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||
#######################################################################################################################################################
|
Loading…
Reference in New Issue