© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
2 replies
Deleted User

Custom claims package

Hi everyone, I'm using this package here for authorization and storing some additional metadata: https://github.com/supabase-community/supabase-custom-claims

The way it is set up it allows users with the
claims_admin
claims_admin
claim change claims. Now what I want to do is also let my service role update claims. Currently the function looks like this:

    BEGIN
      IF NOT is_claims_admin() THEN
          RETURN 'error: access denied';
      ELSE        
        update auth.users set raw_app_meta_data = 
          raw_app_meta_data || 
            json_build_object(claim, value)::jsonb where id = uid;
        return 'OK';
      END IF;
    END;
    BEGIN
      IF NOT is_claims_admin() THEN
          RETURN 'error: access denied';
      ELSE        
        update auth.users set raw_app_meta_data = 
          raw_app_meta_data || 
            json_build_object(claim, value)::jsonb where id = uid;
        return 'OK';
      END IF;
    END;


I want something like this but I don't know how to achieve it:

    BEGIN
      IF NOT is_claims_admin() OR **SERVICE_ROLE** THEN
          RETURN 'error: access denied';
      ELSE        
        update auth.users set raw_app_meta_data = 
          raw_app_meta_data || 
            json_build_object(claim, value)::jsonb where id = uid;
        return 'OK';
      END IF;
    END;
    BEGIN
      IF NOT is_claims_admin() OR **SERVICE_ROLE** THEN
          RETURN 'error: access denied';
      ELSE        
        update auth.users set raw_app_meta_data = 
          raw_app_meta_data || 
            json_build_object(claim, value)::jsonb where id = uid;
        return 'OK';
      END IF;
    END;


Sorry for tagging you @Mark Burggraf but you seem to be the maintainer of that package.
GitHub
GitHub - supabase-community/supabase-custom-claims: How to implemen...
How to implement custom claims with Supabase. Contribute to supabase-community/supabase-custom-claims development by creating an account on GitHub.
GitHub - supabase-community/supabase-custom-claims: How to implemen...
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Custom claims hooks refuses to work
SupabaseSSupabase / help-and-questions
13mo ago
Forcing JWT refresh after setting custom claims
SupabaseSSupabase / help-and-questions
4y ago
how to add data in custom claims of jwt
SupabaseSSupabase / help-and-questions
2w ago
JWT custom claims: Am I making the right choice?
SupabaseSSupabase / help-and-questions
4w ago