Class TemporaryUserService
Service for creating a temporary user that is reverted when the class is disposed.
Inherited Members
Namespace: IRM.AspNetCore.Identity
Assembly: IRM.AspNetCore.Identity.dll
Syntax
public class TemporaryUserService : IDisposable
Constructors
TemporaryUserService(HttpContext, ILogger)
Creates a new instance of TemporaryUserService.
Declaration
public TemporaryUserService(HttpContext httpContext, ILogger logger)
Parameters
|
Microsoft.AspNetCore.Http.HttpContext
httpContext
The current Microsoft.AspNetCore.Http.HttpContext. |
|
Microsoft.Extensions.Logging.ILogger
logger
The logger used to log messages, warnings and errors. |
TemporaryUserService(IHttpContextAccessor, ILogger)
Creates a new instance of TemporaryUserService.
Declaration
public TemporaryUserService(IHttpContextAccessor contextAccessor, ILogger logger)
Parameters
|
Microsoft.AspNetCore.Http.IHttpContextAccessor
contextAccessor
The accessor used to access the Microsoft.AspNetCore.Http.HttpContext. |
|
Microsoft.Extensions.Logging.ILogger
logger
The logger used to log messages, warnings and errors. |
Fields
AuthenticationType
Gets the autentication type for the user created by this service.
Declaration
public const string AuthenticationType = "Temporary"
Field Value
|
String
|
Methods
CreateUser(IEnumerable<Claim>[])
Creates a temporary user, that is set to Microsoft.AspNetCore.Http.HttpContext.User until disposed.
Declaration
public virtual ClaimsPrincipal CreateUser(params IEnumerable<Claim>[] claims)
Parameters
|
IEnumerable<System.Security.Claims.Claim>[]
claims
The claims used to create the user. |
Returns
|
System.Security.Claims.ClaimsPrincipal
A System.Security.Claims.ClaimsPrincipal representing the temporary user. |
CreateUserIfOtherTenant(Nullable<Guid>, IEnumerable<Claim>)
Creates a temporary user if tenantId has a value that differs from the current user.
Declaration
public virtual ClaimsPrincipal CreateUserIfOtherTenant(Guid? tenantId, IEnumerable<Claim> claims = null)
Parameters
|
System.Nullable<System.Guid>
tenantId
The value of the tenant identity for the new user. |
|
IEnumerable<System.Security.Claims.Claim>
claims
The claims used to create the user. |
Returns
|
System.Security.Claims.ClaimsPrincipal
A System.Security.Claims.ClaimsPrincipal representing the temporary user or the original user if it is for the supplied |
Dispose()
Reverts the Microsoft.AspNetCore.Http.HttpContext.User to the original user.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Reverts the Microsoft.AspNetCore.Http.HttpContext.User to the original user when disposing.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
|
Boolean
disposing
true if disposing; otherwise false. |
Finalize()
Declaration
protected void Finalize()