Skip to content

feat: support Flow Secret for embedded flows#9

Closed
Malith-19 wants to merge 1 commit into
thunder-id:mainfrom
Malith-19:fix/flow-secret-support
Closed

feat: support Flow Secret for embedded flows#9
Malith-19 wants to merge 1 commit into
thunder-id:mainfrom
Malith-19:fix/flow-secret-support

Conversation

@Malith-19

@Malith-19 Malith-19 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Purpose

The Flow Execution API (/flow/execute) requires a Flow-Secret header when an application enforces it, but the Android SDK had no way to supply one — FlowExecutionClient never set the header and ThunderIDConfig had no field for it. This caused registration/sign-in via the embedded flow to fail with 400 Invalid request for applications that enforce a flow secret.

Also fixes stale setup docs in the quickstart sample: the README told users to create a .env file, but the Gradle build (build.gradle.kts) actually reads from config.properties.env was dead, unused, and untracked-example-less (.env.example never existed in the repo).

Approach

  • Add ThunderIDConfig.flowSecret: String?
  • Add an optional headers param to HttpClient.post/request
  • FlowExecutionClient sends Flow-Secret on initiate/submit when configured
  • Wire config.flowSecret through ThunderIDClient.initialize
  • Update the quickstart sample (build.gradle.kts, MainActivity.kt, config.properties.example) to read/pass THUNDERID_FLOW_SECRET
  • Remove the unused samples/quickstart/.env
  • Update samples/quickstart/README.md:
    • Point setup at config.properties (the file the build actually reads) instead of the nonexistent .env.example
    • Document THUNDERID_FLOW_SECRET and where to find it (Applications → app → General, shown once at creation)
    • Note clientId is only needed for the redirect-based OAuth flow, not the embedded Flow Execution API this sample uses
    • Note the emulator needs https://10.0.2.2:8090, not https://localhost:8090
    • Document that self-registration must be enabled in both the application settings and the assigned user type, or registration fails with self_reg_disabled_for_user_type

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified. (ran quickstart sample against a local ThunderID instance on an emulator — sign-in and registration both work end-to-end)
  • Documentation provided.
  • Tests provided.
    • Unit Tests
    • Integration Tests
  • Breaking changes.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Added support for configuring a Flow Secret for applications using protected flow execution.
    • Flow execution requests now include the configured secret when required.
    • Added support for custom HTTP headers in POST requests.
  • Documentation

    • Updated the Android Quickstart setup instructions, configuration values, credentials guidance, emulator/device networking notes, and self-registration prerequisites.
    • Added the Flow Secret to the sample configuration template.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Malith-19, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cab84cfb-af2b-4607-a38b-318f8f4b7016

📥 Commits

Reviewing files that changed from the base of the PR and between 58a7a5f and 01faa3d.

📒 Files selected for processing (8)
  • samples/quickstart/README.md
  • samples/quickstart/build.gradle.kts
  • samples/quickstart/config.properties.example
  • samples/quickstart/src/main/kotlin/dev/thunderid/quickstart/MainActivity.kt
  • src/main/kotlin/dev/thunderid/android/ThunderIDClient.kt
  • src/main/kotlin/dev/thunderid/android/ThunderIDConfig.kt
  • src/main/kotlin/dev/thunderid/android/auth/FlowExecutionClient.kt
  • src/main/kotlin/dev/thunderid/android/http/HttpClient.kt
📝 Walkthrough

Walkthrough

The SDK adds optional Flow Execution API secret support. The secret is read from quickstart configuration, passed through ThunderIDConfig and ThunderIDClient, and sent as a Flow-Secret HTTP header for flow execution requests.

Changes

Flow secret support

Layer / File(s) Summary
Custom HTTP header transport
src/main/kotlin/dev/thunderid/android/http/HttpClient.kt
HTTP POST and request methods now accept and apply caller-provided headers.
Flow secret request propagation
src/main/kotlin/dev/thunderid/android/ThunderIDConfig.kt, src/main/kotlin/dev/thunderid/android/ThunderIDClient.kt, src/main/kotlin/dev/thunderid/android/auth/FlowExecutionClient.kt
The optional flow secret is passed into flow execution and emitted as a Flow-Secret header when present.
Quickstart flow secret configuration
samples/quickstart/config.properties.example, samples/quickstart/build.gradle.kts, samples/quickstart/src/main/kotlin/dev/thunderid/quickstart/MainActivity.kt, samples/quickstart/README.md
Quickstart configuration, BuildConfig injection, app setup, and setup instructions now include the flow secret.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant ThunderIDClient
  participant FlowExecutionClient
  participant HttpClient
  participant FlowExecutionAPI
  App->>ThunderIDClient: initialize ThunderIDConfig with flowSecret
  ThunderIDClient->>FlowExecutionClient: create with flowSecret
  FlowExecutionClient->>HttpClient: POST /flow/execute with Flow-Secret
  HttpClient->>FlowExecutionAPI: send flow request
Loading

Suggested reviewers: brionmario

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Flow Secret support for embedded flows.
Description check ✅ Passed The PR description follows the template well, covering purpose, approach, checklist, security checks, and testing notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@samples/quickstart/README.md`:
- Around line 11-34: Specify the properties language on the fenced configuration
block in the quickstart documentation by changing its opening fence to use
properties, while leaving the configuration values and surrounding instructions
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d9d6491-d669-48e0-9ae6-ac256abbcb98

📥 Commits

Reviewing files that changed from the base of the PR and between e22131a and 58a7a5f.

📒 Files selected for processing (8)
  • samples/quickstart/README.md
  • samples/quickstart/build.gradle.kts
  • samples/quickstart/config.properties.example
  • samples/quickstart/src/main/kotlin/dev/thunderid/quickstart/MainActivity.kt
  • src/main/kotlin/dev/thunderid/android/ThunderIDClient.kt
  • src/main/kotlin/dev/thunderid/android/ThunderIDConfig.kt
  • src/main/kotlin/dev/thunderid/android/auth/FlowExecutionClient.kt
  • src/main/kotlin/dev/thunderid/android/http/HttpClient.kt

Comment thread samples/quickstart/README.md
@Malith-19
Malith-19 force-pushed the fix/flow-secret-support branch 2 times, most recently from 35312a4 to 941a372 Compare July 14, 2026 11:09
@Malith-19
Malith-19 requested a review from brionmario July 14, 2026 11:12
@Malith-19
Malith-19 force-pushed the fix/flow-secret-support branch from 941a372 to 0a93a46 Compare July 15, 2026 04:34
Flow Execution API calls require a Flow-Secret header when an
application enforces it, but the SDK had no way to send one. Wire
ThunderIDConfig.flowSecret through to FlowExecutionClient and add
sample app + docs guidance for setting it up locally.
@Malith-19
Malith-19 force-pushed the fix/flow-secret-support branch from 0a93a46 to 01faa3d Compare July 15, 2026 18:18
## Setup

Copy `.env.example` to `.env` and add your ThunderID credentials:
Copy `config.properties.example` to `config.properties` (gitignored) and add your ThunderID credentials:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we double check changes done to readme?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to use the config.properties file and using .env didn't worked for me. That's why this update.

cc: @brionmario can you confirm this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in the repo we don't have env.example file too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.properties is the right approach. I think README wasn't updated.

THUNDERID_APPLICATION_ID=your-application-id
THUNDERID_AFTER_SIGN_IN_URL=
THUNDERID_AFTER_SIGN_OUT_URL=
THUNDERID_FLOW_SECRET=your-flow-secret

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a meaning of flow secret for a mobile client?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is when they not using attestation. In that case they have to go with the secret.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once they configure the attestation, secret will be skipped and attestation will be validated.

@brionmario brionmario Jul 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just mention something like THUNDERID_ATTESTATION or THUNDERID_ATTESTATION_KEY?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean instead of FLOW_SECRET value? If yes, in the attestation case we need to have some more parameters here (This will be sent via separate PR). So having a common name for both attestation and secret will confuse users IMO.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public clients usually can't securely hold a secret. My concern is, calling this THUNDERID_FLOW_SECRET is a bit misleading because it implies the app should embed a secret.

@Malith-19

Copy link
Copy Markdown
Member Author

Closing — we've decided to proceed without requiring a Flow Secret for mobile apps, so this isn't needed. A new PR for Play Integrity support is coming instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants