• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / auth / 10601499330
69%

Build:
DEFAULT BRANCH: master
Ran 28 Aug 2024 05:31PM UTC
Jobs 1
Files 128
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Aug 2024 05:26PM UTC coverage: 57.885%. Remained the same
10601499330

push

github

web-flow
fix: hide hook name (#1743)

## What kind of change does this PR introduce?

The HookName is generated from the Postgres URI and used internally to
invoke the hook.

Context:
https://github.com/supabase/auth/issues/1734#issuecomment-2308342232

Since it's for internal use, we don't expose it similar to what we do
with [encryption
key](https://github.com/supabase/auth/compare/j0/hide_hook_name?expand=1#diff-4c28cb40831f3c7614b0f781ffa096505L457)
and other similar fields.

This is fine since we don't marshal the extensibility point.

## Testing setup

We don't marshal the struct so it should be fine but for additional
sanity check ran this locally:
```
GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED="true"
GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="pg-functions://postgres/public/custom_access_token_hook"
```

```
create or replace function public.custom_access_token_hook(event jsonb)
returns jsonb
language plpgsql
as $$
  declare
    claims jsonb;
  begin
   

    -- Proceed only if the user is an admin
      claims := event->'claims';

      -- Check if 'user_metadata' exists in claims
      if jsonb_typeof(claims->'user_metadata') is null then
        -- If 'user_metadata' does not exist, create an empty object
        claims := jsonb_set(claims, '{user_metadata}', '{}');
      end if;

      -- Set a claim of 'admin'
      claims := jsonb_set(claims, '{user_metadata, admin}', 'true');

      -- Update the 'claims' object in the original event
      event := jsonb_set(event, '{claims}', claims);

    -- Return the modified or original event
    return event;
  end;
$$;

grant execute
  on function public.custom_access_token_hook
  to supabase_auth_admin;

revoke execute
  on function public.custom_access_token_hook
  from authenticated, anon, public;

grant usage on schema public to supabase_auth_admin;
```

9140 of 15790 relevant lines covered (57.88%)

55.69 hits per line

Jobs
ID Job ID Ran Files Coverage
1 10601499330.1 28 Aug 2024 05:31PM UTC 128
57.88
GitHub Action Run
Source Files on build 10601499330
  • Tree
  • List 128
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 7e38f4cf on github
  • Prev Build on master (#10588384860)
  • Next Build on master (#10605747677)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc