#### [Abblix\.Oidc\.Server](https://www.abblix.com/en/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Features\.DeviceAuthorization](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization')

## UserCodeRateLimiter Class

Implements rate limiting for user code verification attempts to prevent brute force attacks\.
Uses exponential backoff and per\-IP rate limiting as recommended by RFC 8628 Section 5\.2\.

```csharp
public class UserCodeRateLimiter : Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → UserCodeRateLimiter

Implements [IUserCodeRateLimiter](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces\.IUserCodeRateLimiter')
### Constructors

## UserCodeRateLimiter\(ILogger\<UserCodeRateLimiter\>, IEntityStorage, IEntityStorageKeyFactory, TimeProvider, IOptions\<OidcOptions\>\) Constructor {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_)}

Implements rate limiting for user code verification attempts to prevent brute force attacks\.
Uses exponential backoff and per\-IP rate limiting as recommended by RFC 8628 Section 5\.2\.

```csharp
public UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger<Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter> logger, Abblix.Oidc.Server.Features.Storages.IEntityStorage storage, Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory keyFactory, System.TimeProvider timeProvider, Microsoft.Extensions.Options.IOptions<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options);
```
#### Parameters

###### `logger` [Microsoft\.Extensions\.Logging\.ILogger&lt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger-1 'Microsoft\.Extensions\.Logging\.ILogger\`1')[UserCodeRateLimiter](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.UserCodeRateLimiter')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger-1 'Microsoft\.Extensions\.Logging\.ILogger\`1') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).logger}

Logger for security events\.

###### `storage` [IEntityStorage](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).storage}

The storage service for persisting rate limit state\.

###### `keyFactory` [IEntityStorageKeyFactory](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorageKeyFactory') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).keyFactory}

The factory for generating storage keys\.

###### `timeProvider` [System\.TimeProvider](https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider 'System\.TimeProvider') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).timeProvider}

Provides access to the current time\.

###### `options` [Microsoft\.Extensions\.Options\.IOptions&lt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptions-1 'Microsoft\.Extensions\.Options\.IOptions\`1')[OidcOptions](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Configuration.OidcOptions 'Abblix\.Oidc\.Server\.Common\.Configuration\.OidcOptions')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptions-1 'Microsoft\.Extensions\.Options\.IOptions\`1') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.UserCodeRateLimiter(Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter_,Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,System.TimeProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).options}

Configuration options containing device authorization settings\.
### Methods

## UserCodeRateLimiter\.CheckAsync\(string, string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.CheckAsync(string,string)}

Checks if a verification attempt should be allowed for the given user code and client identifier\.
Implements exponential backoff and per\-IP rate limiting to prevent brute force attacks\.

```csharp
public System.Threading.Tasks.Task<Abblix.Utils.Result<bool,System.TimeSpan>> CheckAsync(string userCode, string clientIdentifier);
```
#### Parameters

###### `userCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.CheckAsync(string,string).userCode}

The user code being verified\.

###### `clientIdentifier` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.CheckAsync(string,string).clientIdentifier}

The client identifier \(IP address or other identifier\)\.

Implements [CheckAsync\(string, string\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter.CheckAsync(string,string) 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces\.IUserCodeRateLimiter\.CheckAsync\(string, string\)')

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Abblix\.Utils\.Result&lt;](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')[,](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[System\.TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan 'System\.TimeSpan')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A [Abblix\.Utils\.Result&lt;&gt;](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2') containing:
\- Success \(`true`\): The verification attempt is allowed to proceed\.
\- Failure \([System\.TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan 'System\.TimeSpan')\): The attempt is rate limited; the value indicates the duration
  the client must wait before retrying \(Retry\-After\)\.

## UserCodeRateLimiter\.RecordFailureAsync\(string, string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordFailureAsync(string,string)}

Records a failed verification attempt for rate limiting purposes\.

```csharp
public System.Threading.Tasks.Task RecordFailureAsync(string userCode, string clientIdentifier);
```
#### Parameters

###### `userCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordFailureAsync(string,string).userCode}

The user code that failed verification\.

###### `clientIdentifier` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordFailureAsync(string,string).clientIdentifier}

The client identifier \(IP address or other identifier\)\.

Implements [RecordFailureAsync\(string, string\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter.RecordFailureAsync(string,string) 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces\.IUserCodeRateLimiter\.RecordFailureAsync\(string, string\)')

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')

## UserCodeRateLimiter\.RecordSuccessAsync\(string, string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordSuccessAsync(string,string)}

Records a successful verification to reset rate limiting counters\.

```csharp
public System.Threading.Tasks.Task RecordSuccessAsync(string userCode, string clientIdentifier);
```
#### Parameters

###### `userCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordSuccessAsync(string,string).userCode}

The user code that was successfully verified\.

###### `clientIdentifier` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.UserCodeRateLimiter.RecordSuccessAsync(string,string).clientIdentifier}

The client identifier \(IP address or other identifier\)\.

Implements [RecordSuccessAsync\(string, string\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IUserCodeRateLimiter.RecordSuccessAsync(string,string) 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces\.IUserCodeRateLimiter\.RecordSuccessAsync\(string, string\)')

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')
