@pgpm/jwt-claims 0.12.0 → 0.12.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.
Files changed (28) hide show
  1. package/deploy/schemas/ctx/procedures/ip_address.sql +2 -1
  2. package/deploy/schemas/ctx/procedures/origin.sql +2 -1
  3. package/deploy/schemas/ctx/procedures/security_definer.sql +1 -0
  4. package/deploy/schemas/ctx/procedures/user_agent.sql +2 -1
  5. package/deploy/schemas/ctx/procedures/user_id.sql +2 -1
  6. package/deploy/schemas/ctx/schema.sql +1 -0
  7. package/deploy/schemas/jwt_private/procedures/current_token_id.sql +1 -0
  8. package/deploy/schemas/jwt_public/procedures/current_origin.sql +2 -1
  9. package/launchql-jwt-claims.control +2 -2
  10. package/package.json +3 -3
  11. package/pgpm.plan +10 -2
  12. package/revert/schemas/ctx/procedures/ip_address.sql +1 -0
  13. package/revert/schemas/ctx/procedures/origin.sql +1 -0
  14. package/revert/schemas/ctx/procedures/security_definer.sql +2 -0
  15. package/revert/schemas/ctx/procedures/user_agent.sql +1 -0
  16. package/revert/schemas/ctx/procedures/user_id.sql +1 -0
  17. package/revert/schemas/ctx/schema.sql +1 -0
  18. package/revert/schemas/jwt_private/procedures/current_token_id.sql +1 -0
  19. package/revert/schemas/jwt_public/procedures/current_origin.sql +1 -0
  20. package/sql/launchql-jwt-claims--0.9.0.sql +49 -1
  21. package/verify/schemas/ctx/procedures/ip_address.sql +1 -0
  22. package/verify/schemas/ctx/procedures/origin.sql +1 -0
  23. package/verify/schemas/ctx/procedures/security_definer.sql +2 -0
  24. package/verify/schemas/ctx/procedures/user_agent.sql +1 -0
  25. package/verify/schemas/ctx/procedures/user_id.sql +1 -0
  26. package/verify/schemas/ctx/schema.sql +2 -1
  27. package/verify/schemas/jwt_private/procedures/current_token_id.sql +1 -0
  28. package/verify/schemas/jwt_public/procedures/current_origin.sql +1 -0
@@ -11,4 +11,5 @@ AS $$
11
11
  $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
- COMMIT;
14
+ COMMIT;
15
+
@@ -11,4 +11,5 @@ AS $$
11
11
  $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
- COMMIT;
14
+ COMMIT;
15
+
@@ -21,3 +21,4 @@ GRANT EXECUTE ON FUNCTION ctx.security_definer() TO PUBLIC;
21
21
  GRANT EXECUTE ON FUNCTION ctx.is_security_definer() TO PUBLIC;
22
22
 
23
23
  COMMIT;
24
+
@@ -11,4 +11,5 @@ AS $$
11
11
  $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
- COMMIT;
14
+ COMMIT;
15
+
@@ -11,4 +11,5 @@ AS $$
11
11
  $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
- COMMIT;
14
+ COMMIT;
15
+
@@ -13,3 +13,4 @@ GRANT EXECUTE ON FUNCTIONS
13
13
  TO authenticated;
14
14
 
15
15
  COMMIT;
16
+
@@ -12,3 +12,4 @@ $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
14
  COMMIT;
15
+
@@ -11,4 +11,5 @@ AS $$
11
11
  $$
12
12
  LANGUAGE 'sql' STABLE;
13
13
 
14
- COMMIT;
14
+ COMMIT;
15
+
@@ -2,7 +2,7 @@
2
2
  comment = 'launchql-jwt-claims extension'
3
3
  default_version = '0.9.0'
4
4
  module_pathname = '$libdir/launchql-jwt-claims'
5
- requires = 'plpgsql,uuid-ossp,launchql-verify'
5
+ requires = 'plpgsql,uuid-ossp,launchql-types,launchql-verify'
6
6
  relocatable = false
7
7
  superuser = false
8
-
8
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/jwt-claims",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "JWT claim handling and validation functions",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -24,7 +24,7 @@
24
24
  "pgpm": "^0.2.0"
25
25
  },
26
26
  "dependencies": {
27
- "@pgpm/types": "0.12.0",
27
+ "@pgpm/types": "0.12.2",
28
28
  "@pgpm/verify": "0.12.0"
29
29
  },
30
30
  "repository": {
@@ -35,5 +35,5 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/launchql/pgpm-modules/issues"
37
37
  },
38
- "gitHead": "b106c3afcb5152f177f411bf89bbef392fbd2375"
38
+ "gitHead": "880c1b99631ac536288584ace0ac3dd40300f17e"
39
39
  }
package/pgpm.plan CHANGED
@@ -2,10 +2,18 @@
2
2
  %project=launchql-jwt-claims
3
3
  %uri=launchql-jwt-claims
4
4
 
5
+ schemas/ctx/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/schema
6
+ schemas/ctx/procedures/ip_address [schemas/ctx/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/procedures/ip_address
7
+ schemas/ctx/procedures/origin [schemas/ctx/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/procedures/origin
8
+ schemas/ctx/procedures/user_agent [schemas/ctx/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/procedures/user_agent
9
+ schemas/ctx/procedures/user_id [schemas/ctx/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/procedures/user_id
10
+ schemas/ctx/procedures/security_definer [schemas/ctx/schema] 2021-04-20T04:04:08Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/ctx/procedures/security_definer
5
11
  schemas/jwt_public/schema 2020-12-17T06:47:29Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/schema
6
- schemas/jwt_private/schema 2020-12-17T06:47:34Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/schema
7
12
  schemas/jwt_public/procedures/current_user_id [schemas/jwt_public/schema] 2020-12-17T06:48:56Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_user_id
8
13
  schemas/jwt_public/procedures/current_ip_address [schemas/jwt_public/schema] 2020-12-17T23:19:17Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_ip_address
9
14
  schemas/jwt_public/procedures/current_user_agent [schemas/jwt_public/schema] 2020-12-17T23:20:04Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_user_agent
10
- schemas/jwt_private/procedures/current_database_id [schemas/jwt_private/schema] 2020-12-17T23:22:28Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/procedures/current_database_id
15
+ schemas/jwt_public/procedures/current_origin [schemas/jwt_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/jwt_public/procedures/current_origin
11
16
  schemas/jwt_public/procedures/current_group_ids [schemas/jwt_public/schema] 2020-12-17T23:30:50Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_group_ids
17
+ schemas/jwt_private/schema 2020-12-17T06:47:34Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/schema
18
+ schemas/jwt_private/procedures/current_database_id [schemas/jwt_private/schema] 2020-12-17T23:22:28Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/procedures/current_database_id
19
+ schemas/jwt_private/procedures/current_token_id [schemas/jwt_private/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/jwt_private/procedures/current_token_id
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION ctx.ip_address;
6
6
 
7
7
  COMMIT;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION ctx.origin;
6
6
 
7
7
  COMMIT;
8
+
@@ -3,5 +3,7 @@
3
3
  BEGIN;
4
4
 
5
5
  DROP FUNCTION ctx.security_definer;
6
+ DROP FUNCTION ctx.is_security_definer;
6
7
 
7
8
  COMMIT;
9
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION ctx.user_agent;
6
6
 
7
7
  COMMIT;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION ctx.user_id;
6
6
 
7
7
  COMMIT;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP SCHEMA ctx;
6
6
 
7
7
  COMMIT;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION jwt_private.current_token_id;
6
6
 
7
7
  COMMIT;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  DROP FUNCTION jwt_public.current_origin;
6
6
 
7
7
  COMMIT;
8
+
@@ -1,4 +1,11 @@
1
1
  \echo Use "CREATE EXTENSION launchql-jwt-claims" to load this file. \quit
2
+ CREATE SCHEMA ctx;
3
+
4
+ GRANT USAGE ON SCHEMA ctx TO authenticated, anonymous;
5
+
6
+ ALTER DEFAULT PRIVILEGES IN SCHEMA ctx
7
+ GRANT EXECUTE ON FUNCTIONS TO authenticated;
8
+
2
9
  CREATE SCHEMA jwt_public;
3
10
 
4
11
  GRANT USAGE ON SCHEMA jwt_public TO authenticated, anonymous;
@@ -13,6 +20,39 @@ GRANT USAGE ON SCHEMA jwt_private TO authenticated, anonymous;
13
20
  ALTER DEFAULT PRIVILEGES IN SCHEMA jwt_private
14
21
  GRANT EXECUTE ON FUNCTIONS TO authenticated;
15
22
 
23
+ CREATE FUNCTION ctx.ip_address() RETURNS inet AS $EOFCODE$
24
+ SELECT nullif(current_setting('jwt.claims.ip_address', true), '')::inet;
25
+ $EOFCODE$ LANGUAGE sql STABLE;
26
+
27
+ CREATE FUNCTION ctx.origin() RETURNS origin AS $EOFCODE$
28
+ SELECT nullif(current_setting('jwt.claims.origin', true), '')::origin;
29
+ $EOFCODE$ LANGUAGE sql STABLE;
30
+
31
+ CREATE FUNCTION ctx.user_agent() RETURNS text AS $EOFCODE$
32
+ SELECT nullif(current_setting('jwt.claims.user_agent', true), '');
33
+ $EOFCODE$ LANGUAGE sql STABLE;
34
+
35
+ CREATE FUNCTION ctx.user_id() RETURNS uuid AS $EOFCODE$
36
+ SELECT nullif(current_setting('jwt.claims.user_id', true), '')::uuid;
37
+ $EOFCODE$ LANGUAGE sql STABLE;
38
+
39
+ DO $LQLMIGRATION$
40
+ DECLARE
41
+ BEGIN
42
+ EXECUTE format('CREATE FUNCTION ctx.security_definer() returns text as $FUNC$
43
+ SELECT ''%s'';
44
+ $FUNC$
45
+ LANGUAGE ''sql'';', current_user);
46
+ EXECUTE format('CREATE FUNCTION ctx.is_security_definer() returns bool as $FUNC$
47
+ SELECT ''%s'' = current_user;
48
+ $FUNC$
49
+ LANGUAGE ''sql'';', current_user);
50
+ END;
51
+ $LQLMIGRATION$;
52
+
53
+ GRANT EXECUTE ON FUNCTION ctx.security_definer() TO PUBLIC;
54
+ GRANT EXECUTE ON FUNCTION ctx.is_security_definer() TO PUBLIC;
55
+
16
56
  CREATE FUNCTION jwt_public.current_user_id() RETURNS uuid AS $EOFCODE$
17
57
  DECLARE
18
58
  v_identifier_id uuid;
@@ -53,6 +93,10 @@ BEGIN
53
93
  END;
54
94
  $EOFCODE$ LANGUAGE plpgsql STABLE;
55
95
 
96
+ CREATE FUNCTION jwt_public.current_origin() RETURNS origin AS $EOFCODE$
97
+ SELECT nullif(current_setting('jwt.claims.origin', TRUE), '')::origin;
98
+ $EOFCODE$ LANGUAGE sql STABLE;
99
+
56
100
  CREATE FUNCTION jwt_public.current_user_agent() RETURNS text AS $EOFCODE$
57
101
  DECLARE
58
102
  v_uagent text;
@@ -93,6 +137,10 @@ BEGIN
93
137
  END;
94
138
  $EOFCODE$ LANGUAGE plpgsql STABLE;
95
139
 
140
+ CREATE FUNCTION jwt_private.current_token_id() RETURNS uuid AS $EOFCODE$
141
+ SELECT nullif(current_setting('jwt.claims.token_id', TRUE), '')::uuid;
142
+ $EOFCODE$ LANGUAGE sql STABLE;
143
+
96
144
  CREATE FUNCTION jwt_public.current_group_ids() RETURNS uuid[] AS $EOFCODE$
97
145
  DECLARE
98
146
  v_identifier_ids uuid[];
@@ -111,4 +159,4 @@ BEGIN
111
159
  RETURN ARRAY[]::uuid[];
112
160
  END IF;
113
161
  END;
114
- $EOFCODE$ LANGUAGE plpgsql STABLE;
162
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('ctx.ip_address');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('ctx.origin');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -3,5 +3,7 @@
3
3
  BEGIN;
4
4
 
5
5
  SELECT verify_function ('ctx.security_definer');
6
+ SELECT verify_function ('ctx.is_security_definer');
6
7
 
7
8
  ROLLBACK;
9
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('ctx.user_agent');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('ctx.user_id');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -1,7 +1,8 @@
1
- -- Verify schemas/ctx/schema on pg
1
+ -- Verify schemas/ctx/schema on pg
2
2
 
3
3
  BEGIN;
4
4
 
5
5
  SELECT verify_schema ('ctx');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('jwt_private.current_token_id');
6
6
 
7
7
  ROLLBACK;
8
+
@@ -5,3 +5,4 @@ BEGIN;
5
5
  SELECT verify_function ('jwt_public.current_origin');
6
6
 
7
7
  ROLLBACK;
8
+