MaikuB / MaikuB/flutter_appauth

Allow explicitly null state in EndSessionRequest

Open
#646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C
Stars
308
Forks
301
Avg merge
2d 11h
Merged PRs (30d)
5

Description

The OpenID Connect RP-Initiated Logout specification defines the state parameter as OPTIONAL. However, the current Android implementation of `flutter_appauth` makes it effectively mandatory due to the underlying behavior of the plugin's bridge logic with the AppAuth-Android and iOS.

# The Problem:
When calling `endSession` with an IdP that does not support/return the state parameter, the logout flow fails with a exception:
```dart
PlatformException(end_session_failed, Failed to end session: [error: null, description: Response state param did not match request state] ...)
```

## Technical Root Cause:
1. In the AppAuth-Android SDK, the EndSessionRequest.Builder constructor automatically generates a random, secure state string by default.
2. In the `flutter_appauth` Android plugin, the `state` from Dart is only passed to the native builder if it is NOT null.
3. Consequently, passing state `null` from Dart fails to clear the pre-generated state in the native builder. The request is sent with a state, the server returns without one, and AppAuth-Android throws an exception.

# Proposed Change:
Align the Android implementation with the OIDC specification by allowing the state to be explicitly set to null on the native code.

The `flutter_appauth` logic should be updated to ensure that if `null` (or something equivalent, maybe a empty string '' or having an additional boolean flag) is passed from Dart, the native builder.setState(null) is called to override the default generated state.

**NOTE**: The AppAuth-Android SDK explicitly added support for a nullable `state` (see Issue [#615](https://github.com/openid/AppAuth-Android/issues/615)) to support IdP providers that do not echo the _state_ back in the logout redirect. This change would expose that native capability to Flutter developers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Android plugin bridge that maps Dart's endSession state to the AppAuth-Android EndSessionRequest.Builder. Trace how a null state is currently handled and verify the native builder receives an explicit nullable state. Done means a null Dart state can complete logout when the provider omits state, without triggering the state-mismatch exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.