getEndSessionResponse method

  1. @override
Future<OidcEndSessionResponse?> getEndSessionResponse(
  1. OidcProviderMetadata metadata,
  2. OidcEndSessionRequest request,
  3. OidcPlatformSpecificOptions options,
  4. 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,
  });
}