Skip to content

Commit a148cb0

Browse files
craig[bot]souravcrl
andcommitted
Merge #147272
147272: sql,security: add parsing and validation of PROVISIONSRC role option r=souravcrl a=souravcrl See individual commits. fixes #146060 Epic CRDB-21590 Release note (enterprise change): Added a new PROVISIONSRC role option. This role option should be prefixed with the HBA auth method for provisioning, i.e. `ldap` followed by the IDP uri, for example `ldap:ldap.example.com`. This is intended to be used only internally while user provisioning and is supposed to be view-only when checking set role options for a user. Co-authored-by: souravcrl <[email protected]>
2 parents 510dd40 + 8024695 commit a148cb0

File tree

35 files changed

+523
-21
lines changed

35 files changed

+523
-21
lines changed

docs/generated/sql/bnf/stmt_block.bnf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,7 @@ unreserved_keyword ::=
13921392
| 'PRIVILEGES'
13931393
| 'PROCEDURE'
13941394
| 'PROCEDURES'
1395+
| 'PROVISIONSRC'
13951396
| 'PUBLIC'
13961397
| 'PUBLICATION'
13971398
| 'QUERIES'
@@ -3284,6 +3285,7 @@ role_option ::=
32843285
| password_clause
32853286
| valid_until_clause
32863287
| subject_clause
3288+
| provisionsrc_clause
32873289
| 'REPLICATION'
32883290
| 'NOREPLICATION'
32893291
| 'BYPASSRLS'
@@ -3786,6 +3788,10 @@ subject_clause ::=
37863788
'SUBJECT' string_or_placeholder
37873789
| 'SUBJECT' 'NULL'
37883790

3791+
provisionsrc_clause ::=
3792+
'PROVISIONSRC' string_or_placeholder
3793+
| 'PROVISIONSRC' 'NULL'
3794+
37893795
func_name_no_crdb_extra ::=
37903796
type_function_name_no_crdb_extra
37913797
| prefixed_column_path
@@ -4311,6 +4317,7 @@ bare_label_keywords ::=
43114317
| 'PRIVILEGES'
43124318
| 'PROCEDURE'
43134319
| 'PROCEDURES'
4320+
| 'PROVISIONSRC'
43144321
| 'PUBLIC'
43154322
| 'PUBLICATION'
43164323
| 'QUERIES'

pkg/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ ALL_TESTS = [
338338
"//pkg/security/certmgr:certmgr_test",
339339
"//pkg/security/clientcert:clientcert_test",
340340
"//pkg/security/password:password_test",
341+
"//pkg/security/provisioning:provisioning_test",
341342
"//pkg/security/sessionrevival:sessionrevival_test",
342343
"//pkg/security/username:username_disallowed_imports_test",
343344
"//pkg/security/username:username_test",
@@ -1718,6 +1719,8 @@ GO_TARGETS = [
17181719
"//pkg/security/password:password",
17191720
"//pkg/security/password:password_test",
17201721
"//pkg/security/pprompt:pprompt",
1722+
"//pkg/security/provisioning:provisioning",
1723+
"//pkg/security/provisioning:provisioning_test",
17211724
"//pkg/security/securityassets:securityassets",
17221725
"//pkg/security/securitytest:securitytest",
17231726
"//pkg/security/sessionrevival:sessionrevival",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# LogicTest: !local-mixed-24.3 !local-mixed-25.1 !local-mixed-25.2
2+
# Tests for parsing/validation of the PROVISIONSRC role option.
3+
4+
statement error role "root" cannot have a PROVISIONSRC
5+
ALTER ROLE root PROVISIONSRC 'ldap:ldap.example.com'
6+
7+
statement error pq: PROVISIONSRC "ldap.example.com" was not prefixed with any valid auth methods \["ldap"\]
8+
CREATE ROLE role_with_provisioning PROVISIONSRC 'ldap.example.com'
9+
10+
statement error pq: conflicting role options
11+
CREATE ROLE role_with_provisioning WITH PROVISIONSRC 'ldap:ldap.bar.com' NOSQLLOGIN
12+
13+
statement ok
14+
CREATE ROLE role_with_provisioning PROVISIONSRC 'ldap:ldap.bar.com'
15+
16+
query T
17+
SELECT value FROM system.role_options
18+
WHERE username = 'role_with_provisioning'
19+
AND option = 'PROVISIONSRC'
20+
----
21+
ldap:ldap.bar.com
22+
23+
statement ok
24+
ALTER ROLE role_with_provisioning PROVISIONSRC 'ldap:ldap.example.com'
25+
26+
query T
27+
SELECT value FROM system.role_options
28+
WHERE username = 'role_with_provisioning'
29+
AND option = 'PROVISIONSRC'
30+
----
31+
ldap:ldap.example.com
32+
33+
statement error pq: provided IDP "\[\]!@#%#\^\$&\*" in PROVISIONSRC is non parseable: parse "\[\]!@#%#\^\$&\*": invalid URL escape "%#\^"
34+
ALTER ROLE role_with_provisioning PROVISIONSRC 'ldap:[]!@#%#^$&*'
35+
36+
statement ok
37+
ALTER ROLE role_with_provisioning PROVISIONSRC 'ldap:foo.bar'
38+
39+
query T
40+
SELECT value FROM system.role_options
41+
WHERE username = 'role_with_provisioning'
42+
AND option = 'PROVISIONSRC'
43+
----
44+
ldap:foo.bar
45+

pkg/ccl/logictestccl/tests/3node-tenant/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist-disk/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 35,
15+
shard_count = 36,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist-disk/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist-vec-off/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 35,
15+
shard_count = 36,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist-vec-off/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 36,
15+
shard_count = 37,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)