Class AuthorizationTokenFilter
Filter to validate the authorization token sent in the request header.
Inheritance
Namespace: StoneCo.Framework.Host.Api.Filters
Assembly: cs.temp.dll.dll
Syntax
public class AuthorizationTokenFilter : IAsyncActionFilter
Constructors
AuthorizationTokenFilter(String)
Default constructor with token authorization information.
Declaration
public AuthorizationTokenFilter(string authorizationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | authorizationToken | Key to authorize request on Microservices, Domais or Enterprise Service Bus. |
Examples
In the host layer into configuration folder, create a new file that's name MvcOptionsConfigurations.
Create the private static string with the value represented on appsettings.json file.
appsettings.json
{
"Host": {
"AuthorizationToken": "a07f5aa4d2654c0e91412ee7025de133"
}
}
private static string
private static string AppSettingsHostToken => "Host:AuthorizationToken";
Create a new method as below.
public static MvcOptions ConfigureFilters(this MvcOptions options, IConfiguration configuration)
{
IConfigurationSection authorizationToken = configuration.GetSection(AppSettingsHostToken);
options.Filters.Add(new AuthorizationTokenFilter(authorizationToken?.Value));
return options;
}
Properties
AuthorizationToken
Key to authorize request on Microservices, Domais or Enterprise Service Bus.
Declaration
public string AuthorizationToken { get; }
Property Value
Type | Description |
---|---|
System.String | a07f5aa4d2654c0e91412ee7025de133 |
Methods
OnActionExecutionAsync(ActionExecutingContext, ActionExecutionDelegate)
The call that happens after the method action is performed.
Declaration
public Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
Parameters
Type | Name | Description |
---|---|---|
ActionExecutingContext | context | Context to action. |
ActionExecutionDelegate | next | The ActionExecutionDelegate invoked to execute the next action filter or the action itself. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that, on completion, indicates the filter has executed. |