Skip to content
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

Use additional headers from SupabaseClient into GotrueClient. #218

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

tartard
Copy link
Contributor

@tartard tartard commented Jul 22, 2021

What kind of change does this PR introduce?

Feature

What is the current behavior?

When we instantiate SupabaseClient it is possible to specify additional headers to use in any API request :

* @param options.headers Any additional headers to send with each network request.

These headers don't seem to be actually used at all.

Gotrue allows to specify the audience of the users during requests, by setting a header 'X-JWT-AUD' containing the audience, but we cannot use this feature yet because when SupabaseClient instantiates the GotrueClient, it doesn't forwards the custom headers to it.

What is the new behavior?

When SupabaseClient instantiates the GotrueClient, it forwards the custom additional headers to the GotrueClient. It is now possible to set the 'X-JWT-AUD' header in every request to Gotrue.

@kiwicopple
Copy link
Member

Nice work @tartard - this is great. We are about to do a Launch Week so won't be able to test/merge this until August, but this is definitely something we want to support

@dabarrell
Copy link

dabarrell commented Aug 16, 2021

@tartard I was just looking at making a very similar change when I found this PR. Would you be able to expand it to also add the headers to instantiation of the PostgrestClient, SupabaseStorageClient and SupabaseQueryBuilder? These are the other three places headers are used but the settings.headers aren't actually passed in.

If you're not able to make that change let me know and I'll open another PR.

Related to #166

@tartard
Copy link
Contributor Author

tartard commented Aug 17, 2021

@dabarrell I anticipated this need but it wasn't in my use case, and less easy to implement so I didn't implement it.
When I was thinking about it I was wondering if every client should receive only their expected headers or not. For example, should Postgrest client also receive the X-JWT-AUD header which is intended only to Gotrue client ? I think that filtering would be nicer, but it would also be more development and maintenance work so maybe it is not worth.

But currently I don't have time to work on this, so if you have an idea of how to implement it, yes feel free to open another PR.

@soedirgo
Copy link
Member

Thanks for the PR @tartard!

@dabarrell if you'd like to open another PR for the other components, that'd be cool - then we can close #166.

@soedirgo soedirgo merged commit bbe9a55 into supabase:master Aug 19, 2021
@kiwicopple
Copy link
Member

🎉 This PR is included in version 1.22.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants