Skip to content

Update Supabase client provision with context and session - #140

Closed
doanhidm1 wants to merge 2 commits into
anime-vsub:mainfrom
doanhidm1:patch-1
Closed

doanhidm1 wants to merge 2 commits into
anime-vsub:mainfrom
doanhidm1:patch-1

Conversation

@doanhidm1

Copy link
Copy Markdown

Modify Supabase client provision to include context and session management.

Modify Supabase client provision to include context and session management.
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@codesandbox

codesandbox Bot commented May 22, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Enhance Supabase client with session management

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add session management to Supabase client provisioning
• Integrate SharedPreferences for persistent session storage
• Pass application context to Supabase client factory
• Configure SettingsSessionManager with SharedPreferences backend
Diagram
flowchart LR
  A["AppModule.provideSupabaseClient"] -->|"receives Context"| B["SharedPreferences"]
  B -->|"wraps with"| C["SharedPreferencesSettings"]
  C -->|"configures"| D["SettingsSessionManager"]
  D -->|"manages"| E["Auth sessions"]

Loading

File Changes

1. app/src/main/java/git/shin/animevsub/di/AppModule.kt ✨ Enhancement +7/-2

Add session persistence to Supabase client

• Added imports for SettingsSessionManager and SharedPreferencesSettings
• Modified provideSupabaseClient() to accept @ApplicationContext Context parameter
• Configured Auth plugin with SettingsSessionManager using SharedPreferences
• Enabled persistent session storage across app restarts

app/src/main/java/git/shin/animevsub/di/AppModule.kt


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Unencrypted session storage ✓ Resolved 🐞 Bug ⛨ Security
Description
provideSupabaseClient persists Supabase Auth session into plain SharedPreferences
("supabase_session") while the app has android:allowBackup="true", so stored auth session/refresh
credentials can be included in device/cloud backups and read from disk. This increases the risk of
session/token leakage or unintended session transfer when backups are extracted/restored.
Code

app/src/main/java/git/shin/animevsub/di/AppModule.kt[R40-43]

Evidence
The PR configures Supabase Auth to persist its session via SettingsSessionManager backed by a
named SharedPreferences file. The app manifest enables backups (android:allowBackup="true"), so
this stored session data is eligible for backup/restore unless explicitly excluded or encrypted.

app/src/main/java/git/shin/animevsub/di/AppModule.kt[35-44]
app/src/main/AndroidManifest.xml[14-24]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`Auth` is configured to persist its session via `SettingsSessionManager(SharedPreferencesSettings(...))`, which stores the session data in plaintext `SharedPreferences`. Since the app enables `android:allowBackup="true"`, these preferences can be included in system backups unless explicitly excluded, potentially exposing Supabase auth session/refresh credentials.
### Issue Context
- The session store name is hardcoded to `"supabase_session"`.
- The manifest currently allows backup and does not specify a backup exclusion file.
### Fix approach (pick one)
1) **Preferred:** Store the session in an encrypted store.
 - Use `EncryptedSharedPreferences` (AndroidX Security Crypto) as the backing `SharedPreferences` for `SharedPreferencesSettings`.
2) **Additionally/Alternatively:** Exclude the `supabase_session.xml` shared-pref file from backups.
 - Add `android:fullBackupContent` (and for newer Android versions, consider `android:dataExtractionRules`) and exclude `sharedpref/supabase_session.xml`.
### Fix Focus Areas
- app/src/main/java/git/shin/animevsub/di/AppModule.kt[35-44]
- app/src/main/AndroidManifest.xml[14-24]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@codacy-production

codacy-production Bot commented May 22, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…fix token leakage and prevent Keystore BAD_DECRYPT crashes
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.

1 participant