RequiredPermissionAttribute
Protect access to this API to only Authenticated Users assigned with all specified Permissions
Assembly: ServiceStack.dll
View Source
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class RequiredPermissionAttribute : AuthenticateAttribute, _Attribute, IHasRequestFilterAsync, IRequestFilterBase
Properties
RequiredPermissions
View Source
public List<string> RequiredPermissions { get; set; }
Inherited Properties
HtmlRedirect
Redirect the client to a specific URL if authentication failed.
If this property is null, simply 401 Unauthorized
is returned.
View Source
public string HtmlRedirect { get; set; }
Provider
Restrict authentication to a specific ServiceStack.Auth.IAuthProvider. For example, if this attribute should only permit access if the user is authenticated with ServiceStack.Auth.BasicAuthProvider, you should set this property to ServiceStack.Auth.BasicAuthProvider.Name.
View Source
public string Provider { get; set; }
Methods
ExecuteAsync(IRequest, IResponse, Object)
View Source
public override async Task ExecuteAsync(IRequest req, IResponse res, object requestDto)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Web.IResponse | res |
System.Object | requestDto |
HasAllPermissions(IRequest, IAuthSession, IAuthRepository)
View Source
[Obsolete("Use HasAllPermissionsAsync")]
public bool HasAllPermissions(IRequest req, IAuthSession session, IAuthRepository authRepo)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthRepository | authRepo |
HasAllPermissionsAsync(IRequest, IAuthSession, IAuthRepositoryAsync)
View Source
public async Task<bool> HasAllPermissionsAsync(IRequest req, IAuthSession session, IAuthRepositoryAsync authRepo)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthRepositoryAsync | authRepo |
HasAllPermissions(IRequest, IAuthSession, ICollection<String>)
View Source
[Obsolete("Use HasAllPermissionsAsync")]
public static bool HasAllPermissions(IRequest req, IAuthSession session, ICollection<string> requiredPermissions)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Auth.IAuthSession | session |
System.Collections.Generic.ICollection<System.String> | requiredPermissions |
HasAllPermissionsAsync(IRequest, IAuthSession, ICollection<String>, CancellationToken)
View Source
public static async Task<bool> HasAllPermissionsAsync(IRequest req, IAuthSession session, ICollection<string> requiredPermissions, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Auth.IAuthSession | session |
System.Collections.Generic.ICollection<System.String> | requiredPermissions |
System.Threading.CancellationToken | token |
AssertRequiredPermissions(IRequest, String[])
View Source
[Obsolete("AssertRequiredPermissionsAsync")]
public static void AssertRequiredPermissions(IRequest req, params string[] requiredPermissions)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.String[] | requiredPermissions |
AssertRequiredPermissionsAsync(IRequest, String[], CancellationToken)
Check all session is in all supplied roles otherwise a 401 HttpError is thrown
View Source
public static async Task AssertRequiredPermissionsAsync(IRequest req, string[] requiredPermissions, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.String[] | requiredPermissions |
System.Threading.CancellationToken | token |
HasRequiredPermissionsAsync(IRequest, String[])
View Source
public static Task<bool> HasRequiredPermissionsAsync(IRequest req, string[] requiredPermissions)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.String[] | requiredPermissions |
Equals(RequiredPermissionAttribute)
View Source
protected bool Equals(RequiredPermissionAttribute other)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.RequiredPermissionAttribute | other |
Equals(Object)
View Source
public override bool Equals(object obj)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Object | obj |
GetHashCode()
View Source
public override int GetHashCode()
Returns
System.Int32
Inherited Methods
AssertAuthenticated(IRequest, Object, IAuthSession, IAuthProvider[])
View Source
[Obsolete("Use AuthenticateAsync")]
public static void AssertAuthenticated(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.Object | requestDto |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthProvider[] | authProviders |
AssertAuthenticatedAsync(IRequest, Object, IAuthSession, IAuthProvider[])
View Source
public static async Task AssertAuthenticatedAsync(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.Object | requestDto |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthProvider[] | authProviders |
Authenticate(IRequest, Object, IAuthSession, IAuthProvider[])
View Source
[Obsolete("Use AuthenticateAsync")]
public static bool Authenticate(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.Object | requestDto |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthProvider[] | authProviders |
AuthenticateAsync(IRequest, Object, IAuthSession, IAuthProvider[])
View Source
public static async Task<bool> AuthenticateAsync(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.Object | requestDto |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthProvider[] | authProviders |
Equals(AuthenticateAttribute)
View Source
protected bool Equals(AuthenticateAttribute other)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.AuthenticateAttribute | other |
Equals(Object)
View Source
public override bool Equals(object obj)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Object | obj |
ExecuteAsync(IRequest, IResponse, Object)
View Source
public override async Task ExecuteAsync(IRequest req, IResponse res, object requestDto)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Web.IResponse | res |
System.Object | requestDto |
GetHashCode()
View Source
public override int GetHashCode()
Returns
System.Int32
HandleShortCircuitedErrors(IRequest, IResponse, Object, HttpStatusCode, String)
View Source
protected virtual Task HandleShortCircuitedErrors(IRequest req, IResponse res, object requestDto, HttpStatusCode statusCode, string statusDescription = null)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ServiceStack.Web.IResponse | res |
System.Object | requestDto |
System.Net.HttpStatusCode | statusCode |
System.String | statusDescription |
ThrowInvalidPermission(IRequest)
View Source
public static void ThrowInvalidPermission(IRequest req = null)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ThrowInvalidRole(IRequest)
View Source
public static void ThrowInvalidRole(IRequest req = null)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
ThrowNotAuthenticated(IRequest)
View Source
public static void ThrowNotAuthenticated(IRequest req = null)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
Implements
System.Runtime.InteropServices._Attribute
- ServiceStack.Web.IHasRequestFilterAsync
- ServiceStack.Web.IRequestFilterBase