ServiceHmacTokenHandler

Namespace: ASPSecurityKit.AuthProviders
Assembly: ASPSecurityKit.dll

Summary

Implements IAuthenticationSchemeHandler to authenticate using ServiceHMAC.

Remarks

This scheme is the recommended scheme for secure authentication for incoming webhooks (callbacks) from services that support dynamic URL per callback. The hmac should be by the name in queryString as defined by QSServiceHmac. The supported format for value is [idTokenType]:[idToken]:[signatureHash]:[timestamp]:[additionalParams]. Read more about it on https://ASPSecurityKit.net/docs/authentication-schemes/#service-hmac This scheme is usually not enabled by default; you must do so using the appropriate mechanism provided in your platform-specific ASPSecurityKit library.

Constructors

#ctor(sessionProvider,securityContext,errorResource)

Summary

Initializes a new instance of the ServiceHmacTokenHandler class.

Parameters
Name Type Description
sessionProvider ASPSecurityKit.IAuthSessionProvider The session provider.
securityContext ASPSecurityKit.ISecurityContext The security context.
errorResource ASPSecurityKit.IErrorMessageResourceProvider The error resource.

Methods

Validate(requestService)

Summary

Evaluates the specified request against the SHT auth scheme.

Returns

AuthSchemeValidationResult instance with Evaluated as true If the scheme was found in the request (along with either Auth as not null if evaluation succeeded or Error populated if it failed); otherwise, false.

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

Sign(uri,details,authUrn,secret)

Summary

Signs the specified URL with SHT using the specified ServiceHmac options.

Returns

The signed URL.

Parameters
Name Type Description
uri System.Uri The URL to sign.
details ASPSecurityKit.AuthProviders.IServiceHmacTokenDetails The object with details about the params, validity etc. to be used for computing the SHT signature for the specified operation.
authUrn System.String The identity token (idTokenType:idToken) to be used for signing.
secret System.String The secret associated with the identity token to compute the signature hash.
Exceptions
Type Description
System.ArgumentNullException When uri/details is null, or, when authUrn/secret is null/whitespace.

ValidateAsync(requestService)

Summary

Evaluates the specified request against the SHT auth scheme.

Returns

AuthSchemeValidationResult instance with Evaluated as true If the scheme was found in the request (along with either Auth as not null if evaluation succeeded or Error populated if it failed); otherwise, false.

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

ValidateAsync(requestService,cancellationToken)

Summary

Evaluates the specified request against the SHT auth scheme.

Returns

AuthSchemeValidationResult instance with Evaluated as true If the scheme was found in the request (along with either Auth as not null if evaluation succeeded or Error populated if it failed); otherwise, false.

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.

SignAsync(uri,details,authUrn,secret)

Summary

Signs the specified URL with SHT using the specified ServiceHmac options.

Returns

The signed URL.

Parameters
Name Type Description
uri System.Uri The URL to sign.
details ASPSecurityKit.AuthProviders.IServiceHmacTokenDetails The object with details about the params, validity etc. to be used for computing the SHT signature for the specified operation.
authUrn System.String The identity token (idTokenType:idToken) to be used for signing.
secret System.String The secret associated with the identity token to compute the signature hash.
Exceptions
Type Description
System.ArgumentNullException When uri/details is null, or, when authUrn/secret is null/whitespace.

SignAsync(uri,details,authUrn,secret,cancellationToken)

Summary

Signs the specified URL with SHT using the specified ServiceHmac options.

Returns

The signed URL.

Parameters
Name Type Description
uri System.Uri The URL to sign.
details ASPSecurityKit.AuthProviders.IServiceHmacTokenDetails The object with details about the params, validity etc. to be used for computing the SHT signature for the specified operation.
authUrn System.String The identity token (idTokenType:idToken) to be used for signing.
secret System.String The secret associated with the identity token to compute the signature hash.
cancellationToken System.Threading.CancellationToken The cancellation token.
Exceptions
Type Description
System.ArgumentNullException When uri/details is null, or, when authUrn/secret is null/whitespace.