Skip to content

Conversation

jan-tennert
Copy link
Collaborator

@jan-tennert jan-tennert commented Oct 11, 2025

What kind of change does this PR introduce?

Feature

What is the new behavior?

  • Adds a new option (AuthConfig#checkSessionOnRequest) to check any request made with the current user session and if the session is expired try to force a refresh or let the request fail.
  • Adds a new config option to Realtime, Functions, Postgrest, Storage to require a session to make requests from this plugin (aka disable using the api key as a fallback option)

@jan-tennert jan-tennert added the enhancement New feature or request label Oct 11, 2025
@github-actions github-actions bot added the auth label Oct 11, 2025
package io.github.jan.supabase.auth.exception

//TODO: Add actual message and docs
class TokenExpiredException: Exception("The token has expired") No newline at end of file

Check warning

Code scanning / detekt

Public classes, interfaces and objects require documentation. Warning

TokenExpiredException is missing required documentation.
@jan-tennert jan-tennert changed the title Add session failsafe Add session failsafe and option to require a session for requests Oct 12, 2025
@jan-tennert jan-tennert linked an issue Oct 12, 2025 that may be closed by this pull request
2 tasks
object SessionNetworkInterceptor: NetworkInterceptor.Before {

override suspend fun call(builder: HttpRequestBuilder, supabase: SupabaseClient) {
val authHeader = builder.headers[HttpHeaders.Authorization]?.replace("Bearer ", "")

Check warning

Code scanning / detekt

Property is unused and should be removed. Warning

Private property authHeader is unused.
@SupabaseExperimental
var checkSessionOnRequest: Boolean = true

var requireValidSession: Boolean = false

Check warning

Code scanning / detekt

Public properties require documentation. Warning

The property requireValidSession is missing documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request]: A method to require requests to be authenticated

1 participant