Table of Contents

Class DistributedDeviceFlowThrottlingService

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.Core.dll

The device flow's polling throttle, kept in IDistributedCache. Duende's.

public sealed class DistributedDeviceFlowThrottlingService : IDeviceFlowThrottlingService
Inheritance
DistributedDeviceFlowThrottlingService
Implements
Inherited Members

Remarks

Duende 8.0.1's DistributedDeviceFlowThrottlingService, measured: the last poll's time under a key per device, rewritten on every poll, and slow_down for one that came sooner than the interval after it. The default from 0.131.0, in place of InMemoryDeviceFlowThrottlingService, whose count a device escaped by landing on another instance.

The interval is the server's DeviceFlow.Interval, which is what the device authorization response told the device; Duende's throttle reads the client's PollingInterval first, which its response does not advertise. The key is the device code's hash, not the code: a shared cache is somewhere else a code could be read from. The entry lives as long as the device code does.

Constructors

DistributedDeviceFlowThrottlingService(IDistributedCache, TimeProvider, IOptions<IdentityServerOptions>)

A throttle kept in cache, at the interval options sets.

public DistributedDeviceFlowThrottlingService(IDistributedCache cache, TimeProvider time, IOptions<IdentityServerOptions> options)

Parameters

cache IDistributedCache

The distributed cache the last poll's time is kept in.

time TimeProvider

The clock a poll is timed by.

options IOptions<IdentityServerOptions>

The server's options; DeviceFlow.Interval is the interval enforced, in seconds.

Methods

ShouldSlowDownAsync(string, DeviceCode, CancellationToken)

Records this poll and returns true if it arrived sooner than the interval allows.

public Task<bool> ShouldSlowDownAsync(string deviceCode, DeviceCode data, CancellationToken cancellationToken = default)

Parameters

deviceCode string
data DeviceCode
cancellationToken CancellationToken

Returns

Task<bool>