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

## SessionClientRegistry Class

Keeps the clients of a session as a numbered list in entity storage, one key per client, under a generation
that bounds how long the list lives: at least a retention after the session's last authorization, and at most
two\.

```csharp
public class SessionClientRegistry : Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry
```

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

Implements [ISessionClientRegistry](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry 'Abblix\.Oidc\.Server\.Features\.Storages\.ISessionClientRegistry')

### Remarks
A client is added by claiming the first free position of the current generation, so two authorizations
arriving together claim two positions instead of writing one list twice\. The list is read from the first
position up to the first free one, so no record of a generation is written to expire before the generation
itself, and a session whose generation is gone starts a new one instead of writing into positions of the old
one that may already have emptied\. That holds while the clocks of the server's instances agree: a record
written by an instance whose clock is behind the one that last renewed the generation ends earlier by the
difference, and a logout in that moment does not reach the clients listed after it\.

A session goes on under its id when its end user signs in again, so the list is renewed rather than left to
expire on the schedule of the first client: the generation and its records are written to last two
retentions, and once a retention has passed since the last renewal, the next authorization keeps every one of
them two retentions from then. A renewal moves only the expiry of what is still stored, so it never brings
back a generation that has ended or writes an old one over the one that replaced it. A renewal of a generation
that is replaced while the renewal runs gives the replacement the end it computed, which is earlier than the
replacement's own by the time between the two, so the replacement may end that much less than a retention
after an authorization.

A second key per client says the client is already recorded, so recording a client the session already knows
costs four reads, the generation, the marker, the generation again and the note of the last renewal, rather
than a search of the list. A renewal costs a read and two extensions per client on top, once a retention.
### Constructors

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

Keeps the clients of a session as a numbered list in entity storage, one key per client, under a generation
that bounds how long the list lives: at least a retention after the session's last authorization, and at most
two\.

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

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

Where the records are claimed and read\.

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

Names the generation, each position, each client and the last renewal\.

###### `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/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.Storages.SessionClientRegistry.SessionClientRegistry(Abblix.Oidc.Server.Features.Storages.IEntityStorage,Abblix.Oidc.Server.Features.Storages.IEntityStorageKeyFactory,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_,System.TimeProvider,Microsoft.Extensions.Logging.ILogger_Abblix.Oidc.Server.Features.Storages.SessionClientRegistry_).options}

Supplies how long a generation lasts after the session's last authorization\.

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

Supplies the moment a generation's end is measured from\.

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

Reports a session whose list is full\.

### Remarks
A client is added by claiming the first free position of the current generation, so two authorizations
arriving together claim two positions instead of writing one list twice\. The list is read from the first
position up to the first free one, so no record of a generation is written to expire before the generation
itself, and a session whose generation is gone starts a new one instead of writing into positions of the old
one that may already have emptied\. That holds while the clocks of the server's instances agree: a record
written by an instance whose clock is behind the one that last renewed the generation ends earlier by the
difference, and a logout in that moment does not reach the clients listed after it\.

A session goes on under its id when its end user signs in again, so the list is renewed rather than left to
expire on the schedule of the first client: the generation and its records are written to last two
retentions, and once a retention has passed since the last renewal, the next authorization keeps every one of
them two retentions from then. A renewal moves only the expiry of what is still stored, so it never brings
back a generation that has ended or writes an old one over the one that replaced it. A renewal of a generation
that is replaced while the renewal runs gives the replacement the end it computed, which is earlier than the
replacement's own by the time between the two, so the replacement may end that much less than a retention
after an authorization.

A second key per client says the client is already recorded, so recording a client the session already knows
costs four reads, the generation, the marker, the generation again and the note of the last renewal, rather
than a search of the list. A renewal costs a read and two extensions per client on top, once a retention.
### Methods

## SessionClientRegistry\.AddClientAsync\(TenantDefinition, string, string, CancellationToken\) Method {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken)}

Records that a client signed in to a session, and keeps the clients recorded for the session readable for
at least [SessionClientsRetention](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Configuration.OidcOptions#Abblix.Oidc.Server.Common.Configuration.OidcOptions.SessionClientsRetention 'Abblix\.Oidc\.Server\.Common\.Configuration\.OidcOptions\.SessionClientsRetention') from now\. Recording a
client already recorded lists it no second time\.

```csharp
public System.Threading.Tasks.Task AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, string sessionId, string clientId, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
```
#### Parameters

###### `tenant` [TenantDefinition](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken).tenant}

The tenant the session belongs to\.

###### `sessionId` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken).sessionId}

The session the client signed in to\.

###### `clientId` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken).clientId}

The client\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken).cancellationToken}

Cancels the operation\.

Implements [AddClientAsync\(TenantDefinition, string, string, CancellationToken\)](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry#Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry.AddClientAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,string,System.Threading.CancellationToken) 'Abblix\.Oidc\.Server\.Features\.Storages\.ISessionClientRegistry\.AddClientAsync\(Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition, string, string, System\.Threading\.CancellationToken\)')

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

### Remarks
A session goes on under its id when its end user signs in again, so an implementation that let the list
expire a fixed time after its first client would end a long session without telling the clients that
signed in to it early\.

## SessionClientRegistry\.GetClientsAsync\(TenantDefinition, string, CancellationToken\) Method {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken)}

The clients recorded for a session, each once\.

```csharp
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<string>> GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, string sessionId, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
```
#### Parameters

###### `tenant` [TenantDefinition](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).tenant}

The tenant the session belongs to\.

###### `sessionId` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).sessionId}

The session\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Oidc.Server.Features.Storages.SessionClientRegistry.GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).cancellationToken}

Cancels the lookup\.

Implements [GetClientsAsync\(TenantDefinition, string, CancellationToken\)](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry#Abblix.Oidc.Server.Features.Storages.ISessionClientRegistry.GetClientsAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken) 'Abblix\.Oidc\.Server\.Features\.Storages\.ISessionClientRegistry\.GetClientsAsync\(Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition, string, System\.Threading\.CancellationToken\)')

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.IReadOnlyCollection&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlycollection-1 'System\.Collections\.Generic\.IReadOnlyCollection\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlycollection-1 'System\.Collections\.Generic\.IReadOnlyCollection\`1')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The recorded client identifiers; empty when none are recorded or the records have expired\.
