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

## AuthSessionExtensions Class

Provides extension methods for [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession'), facilitating the conversion
between authentication session information and JWT claims\.

```csharp
public static class AuthSessionExtensions
```

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

## AuthSessionExtensions\.ApplyTo\(this AuthSession, JsonWebTokenPayload\) Method {#Abblix.Oidc.Server.Features.UserAuthentication.AuthSessionExtensions.ApplyTo(thisAbblix.Oidc.Server.Features.UserAuthentication.AuthSession,Abblix.Jwt.JsonWebTokenPayload)}

Applies the values from an [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') object to a [JsonWebTokenPayload](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebTokenPayload 'Abblix\.Jwt\.JsonWebTokenPayload'),
effectively transferring the authentication session information into JWT claims\.

```csharp
public static void ApplyTo(this Abblix.Oidc.Server.Features.UserAuthentication.AuthSession authSession, Abblix.Jwt.JsonWebTokenPayload payload);
```
#### 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.Features.UserAuthentication.AuthSessionExtensions.ApplyTo(thisAbblix.Oidc.Server.Features.UserAuthentication.AuthSession,Abblix.Jwt.JsonWebTokenPayload).authSession}

The authentication session containing the user's authentication information\.

###### `payload` [JsonWebTokenPayload](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebTokenPayload 'Abblix\.Jwt\.JsonWebTokenPayload') {#Abblix.Oidc.Server.Features.UserAuthentication.AuthSessionExtensions.ApplyTo(thisAbblix.Oidc.Server.Features.UserAuthentication.AuthSession,Abblix.Jwt.JsonWebTokenPayload).payload}

The JWT payload where the authentication session information will be applied as claims\.

### Remarks
This method transfers authentication session details into the JWT payload, including:
\- Subject, SessionId, AuthenticationTime, IdentityProvider, AuthContextClassRef, AuthenticationMethodReferences
\- Email and EmailVerified \(when specified in the session\)
\- Any additional custom claims from AdditionalClaims

## AuthSessionExtensions\.ToAuthSession\(this JsonWebTokenPayload\) Method {#Abblix.Oidc.Server.Features.UserAuthentication.AuthSessionExtensions.ToAuthSession(thisAbblix.Jwt.JsonWebTokenPayload)}

Creates an [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') object from a collection of JWT claims present in a [JsonWebTokenPayload](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebTokenPayload 'Abblix\.Jwt\.JsonWebTokenPayload')\.

```csharp
public static Abblix.Oidc.Server.Features.UserAuthentication.AuthSession ToAuthSession(this Abblix.Jwt.JsonWebTokenPayload payload);
```
#### Parameters

###### `payload` [JsonWebTokenPayload](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebTokenPayload 'Abblix\.Jwt\.JsonWebTokenPayload') {#Abblix.Oidc.Server.Features.UserAuthentication.AuthSessionExtensions.ToAuthSession(thisAbblix.Jwt.JsonWebTokenPayload).payload}

The JWT payload containing claims that represent an authentication session\.

#### Returns
[AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession')  
An instance of [AuthSession](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.UserAuthentication.AuthSession 'Abblix\.Oidc\.Server\.Features\.UserAuthentication\.AuthSession') populated with information derived from the JWT claims\.

### Remarks
This method allows for the reconstruction of an authentication session from the claims encoded in a JWT\.
It is particularly useful when processing JWTs to extract authentication and user session details\.
