@pgpm/jwt-claims 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -24
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -279,30 +279,6 @@ SELECT * FROM status_public.steps_required('newbie');
|
|
|
279
279
|
-- Uses jwt_public.current_user_id() internally
|
|
280
280
|
```
|
|
281
281
|
|
|
282
|
-
### With @pgpm/default-roles
|
|
283
|
-
|
|
284
|
-
Combine JWT claims with role-based access:
|
|
285
|
-
|
|
286
|
-
```sql
|
|
287
|
-
-- Set role based on JWT claim
|
|
288
|
-
CREATE FUNCTION set_user_role()
|
|
289
|
-
RETURNS void AS $$
|
|
290
|
-
DECLARE
|
|
291
|
-
user_role text;
|
|
292
|
-
BEGIN
|
|
293
|
-
user_role := current_setting('jwt.claims.role', true);
|
|
294
|
-
|
|
295
|
-
IF user_role = 'admin' THEN
|
|
296
|
-
SET LOCAL ROLE administrator;
|
|
297
|
-
ELSIF user_role = 'user' THEN
|
|
298
|
-
SET LOCAL ROLE authenticated;
|
|
299
|
-
ELSE
|
|
300
|
-
SET LOCAL ROLE anonymous;
|
|
301
|
-
END IF;
|
|
302
|
-
END;
|
|
303
|
-
$$ LANGUAGE plpgsql;
|
|
304
|
-
```
|
|
305
|
-
|
|
306
282
|
## Error Handling
|
|
307
283
|
|
|
308
284
|
All functions include error handling for invalid claim values:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/jwt-claims",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "JWT claim handling and validation functions",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"pgpm": "^1.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pgpm/types": "0.15.
|
|
28
|
-
"@pgpm/verify": "0.15.
|
|
27
|
+
"@pgpm/types": "0.15.2",
|
|
28
|
+
"@pgpm/verify": "0.15.2"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "92a241bab64c7b20e85e55a7bd314089907fabba"
|
|
39
39
|
}
|