-
-
Notifications
You must be signed in to change notification settings - Fork 72
Add session failsafe and option to require a session for requests #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jan-tennert
wants to merge
6
commits into
master
Choose a base branch
from
session-failsafe
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d355a40
Initial commit
jan-tennert d54902a
add exception and improve http client
jan-tennert 10e756a
Initial commit
jan-tennert c17da2b
Merge branch 'require-session' into session-failsafe
jan-tennert 96d034f
add option to disable key as fallback
jan-tennert ed9951a
separate methods which are not used authenticated
jan-tennert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/AuthDependentPluginConfig.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package io.github.jan.supabase.auth | ||
|
|
||
| import io.github.jan.supabase.SupabaseClient | ||
| import io.github.jan.supabase.auth.user.UserSession | ||
|
|
||
| /** | ||
| * TODO | ||
| */ | ||
| interface AuthDependentPluginConfig { | ||
|
|
||
| /** | ||
| * Whether to require a valid [UserSession] in the [Auth] plugin to make any request with this plugin. The [SupabaseClient.supabaseKey] cannot be used as fallback. | ||
| */ | ||
| var requireValidSession: Boolean | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/SessionNetworkInterceptor.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package io.github.jan.supabase.auth | ||
|
|
||
| import io.github.jan.supabase.SupabaseClient | ||
| import io.github.jan.supabase.network.NetworkInterceptor | ||
| import io.ktor.client.request.HttpRequestBuilder | ||
| import io.ktor.http.HttpHeaders | ||
|
|
||
| object SessionNetworkInterceptor: NetworkInterceptor.Before { | ||
|
|
||
| override suspend fun call(builder: HttpRequestBuilder, supabase: SupabaseClient) { | ||
| val authHeader = builder.headers[HttpHeaders.Authorization]?.replace("Bearer ", "") | ||
Check warningCode scanning / detekt Property is unused and should be removed. Warning
Private property authHeader is unused.
|
||
|
|
||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/exception/SessionRequiredException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package io.github.jan.supabase.auth.exception | ||
|
|
||
| /** | ||
| * An exception thrown when trying to perform a request that requires a valid session while no user is logged in. | ||
| */ | ||
| class SessionRequiredException: Exception("You need to be logged in to perform this request") |
4 changes: 4 additions & 0 deletions
4
Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/exception/TokenExpiredException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package io.github.jan.supabase.auth.exception | ||
|
|
||
| //TODO: Add actual message and docs | ||
| class TokenExpiredException: Exception("The token has expired") | ||
Check warningCode scanning / detekt Public classes, interfaces and objects require documentation. Warning
TokenExpiredException is missing required documentation.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / detekt
Public properties require documentation. Warning