Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Updated auth-policies.mdx

DreamInk-Officaldbe5c239b928
diff --git a/apps/docs/pages/learn/auth-deep-dive/auth-policies.mdx b/apps/docs/pages/learn/auth-deep-dive/auth-policies.mdx
index 636eef09903..b79c6e038b7 100644
--- a/apps/docs/pages/learn/auth-deep-dive/auth-policies.mdx
+++ b/apps/docs/pages/learn/auth-deep-dive/auth-policies.mdx
@@ -155,10 +155,23 @@ create policy "Only Blizzard staff can update leaderboard"
Supabase comes with two built-in helper functions: `auth.uid()` and `auth.jwt()`.
+To create your own functions, navigate to the SQL editor and create a a new query.
+```
+create or replace function auth.useragent() returns text as $$
+ select nullif(current_setting('request.headers', true)::json->>'user-agent', '')::text;
+$$ language sql;
+```
+You can access request headers, cookies and JWT claims by reading GUC variables set by PostgREST per request. They are named `request.headers`, `request.cookies` and `request.jwt.claims`.
+
+
+Read more about the http-context here: [https://postgrest.org/en/v10.0/api.html#http-context](https://postgrest.org/en/v10.0/api.html#http-context)
+
See the full PostgreSQL policy docs here: [https://www.postgresql.org/docs/12/sql-createpolicy.html](https://www.postgresql.org/docs/12/sql-createpolicy.html)
You can get as creative as you like with these policies.
+
+
### Resources
- JWT debugger: https://jwt.io​