martindonadieu@supabase_auth_apikey
supabase_auth_apikey
Useful extensions for Supabase Auth, Allow API Key authentication for users, with roles and permissions.
The goal is to allow users to authenticate with an API Key, when email/password is not an option. This is useful for IoT devices, CLI tools, and other non-interactive applications.
- Source: https://github.com/Cap-go/pg-extensions/tree/main/supabase_auth_apikey
- Docs: https://github.com/Cap-go/pg-extensions/tree/main/supabase_auth_apikey
- DbDev: https://database.dev/martindonadieu/pg-extensions
Usage
Functions
is_allowed_apikey(((current_setting('request.headers'::text, true))::json ->> 'apikey'::text), '{read,write}')
- check in RLS if the headerapikey
exist and has the correct permissionscreate_apikey(user_id, permissions)
- create an API Key for the user with the given permissions. This is made to use in your backendcreate_apikey(permissions)
- create an API Key for the current user with the given permissions. This is safe to use in Frontenddelete_apikey(user_id, apikey)
- delete the API Key for the user. This is made to use in your backenddelete_apikey(apikey)
- delete the API Key for the current user. This is safe to use in Frontendget_user_id(apikey)
- get the user_id for the given API Key
Installation
dbdev install riderx-supabase_auth_apikey --connection <CONNECTION_STRING>
or
select * from dbdev('riderx-supabase_auth_apikey')
then:
create extension supabase_auth_apikey;
or to install in a separate schema (recommended):
create extension supabase_auth_apikey with schema extensions;
Install
- Install the
dbdev
package manager - Install the package:
select dbdev.install('martindonadieu@supabase_auth_apikey');
create extension "martindonadieu@supabase_auth_apikey"
version '0.0.3';
Downloads
- 37 all time downloads
- 4 downloads in the last 30 days
- 4 downloads in the last 90 days
- 4 downloads in the last 180 days