Table of Contents

Class ApiKeySentinelAttribute

Namespace
Cuemon.AspNetCore.Mvc.Filters.Headers
Assembly
Cuemon.AspNetCore.Mvc.dll

Provides a convenient way to protect your API with an ApiKeySentinelFilter.

public class ApiKeySentinelAttribute : ServiceFilterAttribute, IFilterFactory, IOrderedFilter, IFilterMetadata
Inheritance
ApiKeySentinelAttribute
Implements
Inherited Members

Examples

The following example applies to a controller and inspects the filter service type it resolves.

using System;
using Cuemon.AspNetCore.Mvc.Filters.Headers;
using Microsoft.AspNetCore.Mvc;

namespace MyApp.Examples;

[ApiController]
[Route("api/[controller]")]
[ApiKeySentinel]
public sealed class SecureController : ControllerBase
{
    [HttpGet]
    public IActionResult GetSecureData()
    {
        return Ok(new { Data = "Protected data" });
    }
}

public static class ApiKeySentinelAttributeExample
{
    public static void Demonstrate()
    {
        var attribute = new ApiKeySentinelAttribute();

        Console.WriteLine(attribute.ServiceType == typeof(ApiKeySentinelFilter));
        Console.WriteLine(attribute.IsReusable);
    }
}

Constructors

ApiKeySentinelAttribute()

Initializes a new instance of the ApiKeySentinelAttribute class.

public ApiKeySentinelAttribute()

See Also