Skip to main content

AuthenticateAttribute

Protect access to this API to Authenticated Users only

Assembly: ServiceStack.dll
View Source
Declaration
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class AuthenticateAttribute : RequestFilterAsyncAttribute, _Attribute, IHasRequestFilterAsync, IRequestFilterBase

Properties

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
Declaration
public string Provider { get; set; }

HtmlRedirect

Redirect the client to a specific URL if authentication failed. If this property is null, simply 401 Unauthorized is returned.

View Source
Declaration
public string HtmlRedirect { get; set; }

Inherited Properties

ApplyTo

View Source
Declaration
public ApplyTo ApplyTo { get; set; }

Priority

View Source
Declaration
public int Priority { get; set; }

Methods

ExecuteAsync(IRequest, IResponse, Object)

View Source
Declaration
public override async Task ExecuteAsync(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

Authenticate(IRequest, Object, IAuthSession, IAuthProvider[])

View Source
Declaration
[Obsolete("Use AuthenticateAsync")]
public static bool Authenticate(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthProvider[]authProviders

AuthenticateAsync(IRequest, Object, IAuthSession, IAuthProvider[])

View Source
Declaration
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
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthProvider[]authProviders

AssertAuthenticated(IRequest, Object, IAuthSession, IAuthProvider[])

View Source
Declaration
[Obsolete("Use AuthenticateAsync")]
public static void AssertAuthenticated(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthProvider[]authProviders

AssertAuthenticatedAsync(IRequest, Object, IAuthSession, IAuthProvider[])

View Source
Declaration
public static async Task AssertAuthenticatedAsync(IRequest req, object requestDto = null, IAuthSession session = null, IAuthProvider[] authProviders = null)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthProvider[]authProviders

ThrowNotAuthenticated(IRequest)

View Source
Declaration
public static void ThrowNotAuthenticated(IRequest req = null)
Parameters
TypeName
ServiceStack.Web.IRequestreq

ThrowInvalidRole(IRequest)

View Source
Declaration
public static void ThrowInvalidRole(IRequest req = null)
Parameters
TypeName
ServiceStack.Web.IRequestreq

ThrowInvalidPermission(IRequest)

View Source
Declaration
public static void ThrowInvalidPermission(IRequest req = null)
Parameters
TypeName
ServiceStack.Web.IRequestreq

HandleShortCircuitedErrors(IRequest, IResponse, Object, HttpStatusCode, String)

View Source
Declaration
protected virtual Task HandleShortCircuitedErrors(IRequest req, IResponse res, object requestDto, HttpStatusCode statusCode, string statusDescription = null)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto
System.Net.HttpStatusCodestatusCode
System.StringstatusDescription

Equals(AuthenticateAttribute)

View Source
Declaration
protected bool Equals(AuthenticateAttribute other)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.AuthenticateAttributeother

Equals(Object)

View Source
Declaration
public override bool Equals(object obj)
Returns

System.Boolean

Parameters
TypeName
System.Objectobj

GetHashCode()

View Source
Declaration
public override int GetHashCode()
Returns

System.Int32

Inherited Methods

Copy()

Create a ShallowCopy of this instance.

View Source
Declaration
public virtual IRequestFilterBase Copy()
Returns

ServiceStack.Web.IRequestFilterBase

ExecuteAsync(IRequest, IResponse, Object)

This method is only executed if the HTTP method matches the ServiceStack.RequestFilterAsyncAttribute.ApplyTo property.

View Source
Declaration
public abstract Task ExecuteAsync(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqThe http request wrapper

| | ServiceStack.Web.IResponse | res | The http response wrapper

| | System.Object | requestDto | The request DTO

|

RequestFilterAsync(IRequest, IResponse, Object)

View Source
Declaration
public Task RequestFilterAsync(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

Implements