getEndSessionResponse method
Future<OidcEndSessionResponse?>
getEndSessionResponse(
- OidcProviderMetadata metadata,
- OidcEndSessionRequest request,
- OidcPlatformSpecificOptions options,
- Map<
String, dynamic> preparationResult,
inherited
Returns the end session response for an RP initiated logout request.
may throw an OidcException
.
Implementation
@override
Future<OidcEndSessionResponse?> getEndSessionResponse(
OidcProviderMetadata metadata,
OidcEndSessionRequest request,
OidcPlatformSpecificOptions options,
Map<String, dynamic> preparationResult,
) async {
final endSessionEndpoint = metadata.endSessionEndpoint;
if (endSessionEndpoint == null) {
throw const OidcException(
'OIDC provider MUST declare an '
'authorization endpoint, a token endpoint and an endSessionEndpoint',
);
}
final resp = await appAuth.endSession(
EndSessionRequest(
additionalParameters:
request.extra.map((key, value) => MapEntry(key, value.toString())),
serviceConfiguration: AuthorizationServiceConfiguration(
endSessionEndpoint: metadata.endSessionEndpoint?.toString(),
authorizationEndpoint: metadata.authorizationEndpoint.toString(),
tokenEndpoint: metadata.tokenEndpoint.toString(),
),
idTokenHint: request.idTokenHint,
allowInsecureConnections: getAllowInsecureConnections(options),
preferEphemeralSession: getPreferEphemeralSession(options),
state: request.state,
issuer: metadata.issuer?.toString(),
postLogoutRedirectUrl: request.postLogoutRedirectUri?.toString(),
),
);
if (resp == null) {
return null;
}
return OidcEndSessionResponse.fromJson({
if (resp.state != null) OidcConstants_AuthParameters.state: resp.state,
});
}