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

## AuthenticationSchemeAdapter Class

Adapts ASP\.NET Authentication Scheme to the [IAuthSessionService](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.IAuthSessionService 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.IAuthSessionService') interface\.
This adapter allows the integration of the Abblix OIDC Server with standard ASP\.NET authentication mechanisms,
enabling the use of existing authentication schemes to manage OIDC sessions\.

```csharp
public class AuthenticationSchemeAdapter : Abblix.Oidc.Server.Features.UserAuthentication.IAuthSessionService
```

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

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

## AuthenticationSchemeAdapter\(IHttpContextAccessor, string\) Constructor {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.AuthenticationSchemeAdapter(Microsoft.AspNetCore.Http.IHttpContextAccessor,string)}

Adapts ASP\.NET Authentication Scheme to the [IAuthSessionService](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.IAuthSessionService 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.IAuthSessionService') interface\.
This adapter allows the integration of the Abblix OIDC Server with standard ASP\.NET authentication mechanisms,
enabling the use of existing authentication schemes to manage OIDC sessions\.

```csharp
public AuthenticationSchemeAdapter(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor, string authenticationScheme="Cookies");
```
#### Parameters

###### `httpContextAccessor` [Microsoft\.AspNetCore\.Http\.IHttpContextAccessor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.ihttpcontextaccessor 'Microsoft\.AspNetCore\.Http\.IHttpContextAccessor') {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.AuthenticationSchemeAdapter(Microsoft.AspNetCore.Http.IHttpContextAccessor,string).httpContextAccessor}

Provides access to the [Abblix\.Oidc\.Server\.AspNetCore\.AuthenticationSchemeAdapter\.HttpContext](https://learn.microsoft.com/en-us/dotnet/api/abblix.oidc.server.aspnetcore.authenticationschemeadapter.httpcontext 'Abblix\.Oidc\.Server\.AspNetCore\.AuthenticationSchemeAdapter\.HttpContext'),
            allowing operations on the HTTP context of the current request\.

###### `authenticationScheme` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.AuthenticationSchemeAdapter(Microsoft.AspNetCore.Http.IHttpContextAccessor,string).authenticationScheme}

The authentication scheme to use for all authentication operations\.
            This scheme will be explicitly specified when calling SignInAsync, SignOutAsync, and AuthenticateAsync methods\.
### Methods

## AuthenticationSchemeAdapter\.AuthenticateAsync\(\) Method {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.AuthenticateAsync()}

Attempts to authenticate the current user based on the configured default authentication scheme,
converting the authentication results into an [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession')\.

```csharp
public System.Threading.Tasks.Task<Abblix.Oidc.Server.Features.UserAuthentication.AuthSession?> AuthenticateAsync();
```

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

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A task that returns the [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession')
of the authenticated user or null if the authentication fails\.

### Remarks
A cookie that authenticates under the configured scheme but does not carry the OIDC session claims this adapter
writes \(for example a plain application login cookie sharing the same scheme name, or a cookie whose claims are
malformed\) is treated as "no OIDC session" \- the method returns null rather than throwing, so an unrelated cookie
never turns a request into a 500\.

## AuthenticationSchemeAdapter\.GetAvailableAuthSessions\(\) Method {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.GetAvailableAuthSessions()}

Asynchronously retrieves the current user's authentication session if available\.
This method wraps ASP\.NET's built\-in authentication mechanisms to provide an [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') model\.

```csharp
public System.Collections.Generic.IAsyncEnumerable<Abblix.Oidc.Server.Features.UserAuthentication.AuthSession> GetAvailableAuthSessions();
```

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

#### Returns
[System\.Collections\.Generic\.IAsyncEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')[AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')  
An asynchronous stream of [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') instances representing the user's current
authentication sessions\.

### Remarks
The cookie\-backed authentication scheme carries a single signed\-in identity, so this stream yields at most one
session \- the one represented by the current request's cookie\. Multiple concurrent user accounts per browser
session are not modelled by this adapter\.

## AuthenticationSchemeAdapter\.SignInAsync\(AuthSession\) Method {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.SignInAsync(Abblix.Oidc.Server.Features.UserAuthentication.AuthSession)}

Signs in the specified user into the application, setting up their authentication session\.
Critical claims \(Subject, SessionId, AuthenticationTime, AuthenticationMethodReferences\) are stored in principal claims\.
AffectedClientIds stored in properties as it's not needed in cookie events\.

```csharp
public System.Threading.Tasks.Task SignInAsync(Abblix.Oidc.Server.Features.UserAuthentication.AuthSession authSession);
```
#### Parameters

###### `authSession` [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.SignInAsync(Abblix.Oidc.Server.Features.UserAuthentication.AuthSession).authSession}

The authentication session details to be used for signing in\.

Implements [SignInAsync\(AuthSession\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.IAuthSessionService#Abblix.Oidc.Server.Features.UserAuthentication.IAuthSessionService.SignInAsync(Abblix.Oidc.Server.Features.UserAuthentication.AuthSession) 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.IAuthSessionService\.SignInAsync\(Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession\)')

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that represents the asynchronous sign\-in operation\.

## AuthenticationSchemeAdapter\.SignOutAsync\(\) Method {#Abblix.Oidc.Server.AspNetCore.AuthenticationSchemeAdapter.SignOutAsync()}

Signs out the current user from the application, ending their authenticated session\.

```csharp
public System.Threading.Tasks.Task SignOutAsync();
```

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

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that represents the asynchronous sign\-out operation\.
