© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
Justin

How to test custom auth policy?

I am writing a custom auth scheme
CREATE POLICY "asf i5g8hi_1" 
ON storage.objects FOR 
SELECT TO public USING 
(((bucket_id = 'results'::text) AND ((storage.foldername(name))[1] = 'results'::text)
AND (
    ((current_setting('request.headers'::text, true))::json ->> 'blah'::text) = 'bleep'
    )
) );
CREATE POLICY "asf i5g8hi_1" 
ON storage.objects FOR 
SELECT TO public USING 
(((bucket_id = 'results'::text) AND ((storage.foldername(name))[1] = 'results'::text)
AND (
    ((current_setting('request.headers'::text, true))::json ->> 'blah'::text) = 'bleep'
    )
) );


with some Python
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_ANON_KEY")
supabase: Client = create_client(
    url, key, ClientOptions(headers={"blah": "bleep"}))
storage = supabase.storage()
buckets = storage.list_buckets()
results = storage.get_bucket("results")
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_ANON_KEY")
supabase: Client = create_client(
    url, key, ClientOptions(headers={"blah": "bleep"}))
storage = supabase.storage()
buckets = storage.list_buckets()
results = storage.get_bucket("results")


but i am having trouble testing/debugging this.

Is there anyway to view the auth checking logs? Or to debug this at all?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Supabase Auth Password Policy
SupabaseSSupabase / help-and-questions
3y ago
Custom auth
SupabaseSSupabase / help-and-questions
3y ago
How do you test supabase auth locally?
SupabaseSSupabase / help-and-questions
12mo ago
Unable to add a policy to auth.users why ?
SupabaseSSupabase / help-and-questions
5mo ago