AuthorizationProvider

Namespace: ASPSecurityKit.AuthProviders
Assembly: ASPSecurityKit.dll

Summary

Implements IAuthorizationProvider and performs authorization step of the security pipeline.

Remarks

Out of the box it supports various checks for authorizing the requested operation; to learn about those checks, visit https://ASPSecurityKit.net/docs/the-security-pipeline/#authorization

Constructors

#ctor(userService,authEvents,settings,activityPermittedHandler,securityContext,authSessionProvider,failureHandler,logger,errorResource)

Summary

Initializes a new instance of the AuthorizationProvider class.

Parameters
Name Type Description
userService ASPSecurityKit.IUserService The user service.
authEvents ASPSecurityKit.ISecurityEvents The authEvents.
settings ASPSecurityKit.ISecuritySettings The security settings.
activityPermittedHandler ASPSecurityKit.AuthProviders.IActivityPermittedHandler The activity permitted handler.
securityContext ASPSecurityKit.ISecurityContext The security context.
authSessionProvider ASPSecurityKit.IAuthSessionProvider The authSession provider.
failureHandler ASPSecurityKit.ISecurityFailureResponseHandler The failure handler.
logger ASPSecurityKit.ILogger The logger.
errorResource ASPSecurityKit.IErrorMessageResourceProvider The error resource.

Properties

UserService

Summary

Gets the instance of IUserService for the current request.

AuthEvents

Summary

Gets the instance of ISecurityEvents for the current request to raise authorization related events.

Settings

Summary

Gets the instance of ISecuritySettings.

SecurityContext

Summary

Gets the instance of ISecurityContext for the current request.

AuthSessionProvider

Summary

Gets the instance of IAuthSessionProvider for the current request.

Methods

IsAuthorized(requestService)

Summary

Authorizes the specified request. To learn more about the checks the default implementation performs, visit https://ASPSecurityKit.net/docs/the-security-pipeline/#authorization

Returns

AuthResult instance with Code as Success if authorization was successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
Exceptions
Type Description
System.ArgumentNullException When requestService is null.

HandleUnauthorizedRequest(requestService,result)

Summary

Handles response when request couldn’t be authorized.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
result ASPSecurityKit.AuthProviders.AuthResult The result instance with failure details.
Exceptions
Type Description
System.ArgumentNullException When requestService/result is null.
System.ArgumentException When result is not a failed one.

IsAllowedDuringImpersonation(requestService)

Summary

Determines whether the specified request is allowed during impersonation based on the AllowedOperationsForImpersonation rules.

Returns

true if the specified request is allowed during impersonation; otherwise, false.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.

OtherChecksBeforeActivityAuthorization(requestService)

Summary

Override this method to perform additional checks (if needed) that are to be performed before activity permitted check is finally made by IsAuthorized.

Returns

AuthResult instance with Code as Success if custom checks were successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
Remarks

You can stop further checks by returning SuccessButSkip as Code without causing a failure (it’ll be returned as Success by IsAuthorized).

IsAuthorizedAsync(requestService)

Summary

Authorizes the specified request. To learn more about the checks the default implementation performs, visit https://ASPSecurityKit.net/docs/the-security-pipeline/#authorization

Returns

AuthResult instance with Code as Success if authorization was successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
Exceptions
Type Description
System.ArgumentNullException When requestService is null.

IsAuthorizedAsync(requestService,cancellationToken)

Summary

Authorizes the specified request. To learn more about the checks the default implementation performs, visit https://ASPSecurityKit.net/docs/the-security-pipeline/#authorization

Returns

AuthResult instance with Code as Success if authorization was successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
cancellationToken System.Threading.CancellationToken The cancellation token.
Exceptions
Type Description
System.ArgumentNullException When requestService is null.

HandleUnauthorizedRequestAsync(requestService,result)

Summary

Handles response when request couldn’t be authorized.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
result ASPSecurityKit.AuthProviders.AuthResult The result instance with failure details.
Exceptions
Type Description
System.ArgumentNullException When requestService/result is null.
System.ArgumentException When result is not a failed one.

HandleUnauthorizedRequestAsync(requestService,result,cancellationToken)

Summary

Handles response when request couldn’t be authorized.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
result ASPSecurityKit.AuthProviders.AuthResult The result instance with failure details.
cancellationToken System.Threading.CancellationToken The cancellation token.
Exceptions
Type Description
System.ArgumentNullException When requestService/result is null.
System.ArgumentException When result is not a failed one.

IsAllowedDuringImpersonationAsync(requestService)

Summary

Determines whether the specified request is allowed during impersonation based on the AllowedOperationsForImpersonation rules.

Returns

true if the specified request is allowed during impersonation; otherwise, false.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.

IsAllowedDuringImpersonationAsync(requestService,cancellationToken)

Summary

Determines whether the specified request is allowed during impersonation based on the AllowedOperationsForImpersonation rules.

Returns

true if the specified request is allowed during impersonation; otherwise, false.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
cancellationToken System.Threading.CancellationToken The cancellation token.

OtherChecksBeforeActivityAuthorizationAsync(requestService)

Summary

Override this method to perform additional checks (if needed) that are to be performed before activity permitted check is finally made by IsAuthorized.

Returns

AuthResult instance with Code as Success if custom checks were successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
Remarks

You can stop further checks by returning SuccessButSkip as Code without causing a failure (it’ll be returned as Success by IsAuthorized).

OtherChecksBeforeActivityAuthorizationAsync(requestService,cancellationToken)

Summary

Override this method to perform additional checks (if needed) that are to be performed before activity permitted check is finally made by IsAuthorized.

Returns

AuthResult instance with Code as Success if custom checks were successful; otherwise, a possible reason of failure.

Parameters
Name Type Description
requestService ASPSecurityKit.IRequestService The request service.
cancellationToken System.Threading.CancellationToken The cancellation token.
Remarks

You can stop further checks by returning SuccessButSkip as Code without causing a failure (it’ll be returned as Success by IsAuthorized).