AuthorizeRequestDefinitionRegistrar

Namespace: ASPSecurityKit.ServiceStack
Assembly: ASPSecurityKit.ServiceStack.dll

Summary

Default implementation for IAuthorizeRequestDefinitionRegistrar.

Methods

AuthorizerFor<TRequest>(authorizer,overrideIfAlreadyRegistered)

Summary

Registers a static authorizer for the given request type that will decide whether or not current request is authorized. Use this when you have a complex logic of authorizing a particular request (such as when you have multiple Ids in the request to verify.)

Parameters
Name Type Description
authorizer System.Func{``0,System.String,ASPSecurityKit.AuthProviders.AuthResult} | The authorizer method. |
overrideIfAlreadyRegistered System.Boolean Indicates whether to override existing registration for the given request type.
Generic Types
Name Description
TRequest The request type.
Exceptions
Type Description
System.ArgumentNullException When authorizer is null.
System.InvalidOperationException When an authorizer is already registered and overrideIfAlreadyRegistered is false.

AuthorizerFor(requestType,definitionContainer,authorizer,overrideIfAlreadyRegistered)

Summary

Registers an async instance authorizer for the given request type that will decide whether or not current request is authorized. Use this when you have a complex logic of authorizing a particular request (such as when you have multiple Ids in the request to verify.)

Parameters
Name Type Description
requestType System.Type The request type.
definitionContainer System.Type The type containing the authorizer.
authorizer System.Func{System.Object,System.Object,System.String,System.Threading.Tasks.Task{ASPSecurityKit.AuthProviders.AuthResult}} The authorizer method.
overrideIfAlreadyRegistered System.Boolean Indicates whether to override existing registration for the given request type.
Exceptions
Type Description
System.ArgumentNullException When requestType/definitionContainer/authorizer is null.
System.InvalidOperationException When an authorizer is already registered and overrideIfAlreadyRegistered is false.

AuthorizerFor(requestType,definitionContainer,authorizer,overrideIfAlreadyRegistered)

Summary

Registers an async instance authorizer for the given request type that will decide whether or not current request is authorized. Use this when you have a complex logic of authorizing a particular request (such as when you have multiple Ids in the request to verify.)

Parameters
Name Type Description
requestType System.Type The request type.
definitionContainer System.Type The type containing the authorizer.
authorizer System.Func{System.Object,System.Object,System.String,ASPSecurityKit.AuthProviders.AuthResult} The authorizer method.
overrideIfAlreadyRegistered System.Boolean Indicates whether to override existing registration for the given request type.
Exceptions
Type Description
System.ArgumentNullException When requestType/definitionContainer/authorizer is null.
System.InvalidOperationException When an authorizer is already registered and overrideIfAlreadyRegistered is false.

CanAuthorize(requestType)

Summary

Determines whether or not a custom authorizer has been defined for the given request.

Returns

true if a custom authorizer has been defined for the given request; otherwise, false.

Parameters
Name Type Description
requestType System.Type The request type.
Exceptions
Type Description
System.ArgumentNullException When requestType is null.

TryResolve(container,requestType)

Summary

Gets the auth definition with its holding type instance (if any) resolved using the given DI container if applicable for the specified request type. If no definition is registered for the given request type, returns null.

Returns

The auth definition with its holding type instance (if any) resolved using the given DI container for the specified request type. If no definition is registered for the given request type, returns null.

Parameters
Name Type Description
container ASPSecurityKit.IContainer The container.
requestType System.Type The request type.
Exceptions
Type Description
System.ArgumentNullException When container/requestType is null.