Skip to content

Commit 9244f44

Browse files
committed
Add CLIENT_POLICY parameter for AUTHENTICATION_POLICY object type
1 parent 05e9efb commit 9244f44

File tree

7 files changed

+57
-0
lines changed

7 files changed

+57
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Added `DECFLOAT` data type. You should never find yourself using it, but it exists nonetheless.
66
- Renamed `SNAPSHOT_POLICY`, `SNAPSHOT_SET` object types to `BACKUP_POLICY`, `BACKUP_SET`. Config paths should be updated from `snapshot_*` to `backup_*`.
7+
- Added parameter `CLIENT_POLICY` for authentication policies.
78

89
## [0.60.0] - 2025-11-11
910

snowddl/blueprint/blueprint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class AuthenticationPolicyBlueprint(SchemaObjectBlueprint):
8989
mfa_enrollment: Optional[str] = None
9090
mfa_policy: Optional[Dict[str, Union[bool, float, int, str, list]]] = None
9191
client_types: Optional[List[str]] = None
92+
client_policy: Optional[Dict[str, Dict[str, Union[bool, float, int, str, list]]]] = None
9293
security_integrations: Optional[List[str]] = None
9394
pat_policy: Optional[Dict[str, Union[bool, float, int, str, list]]] = None
9495
workload_identity_policy: Optional[Dict[str, Union[bool, float, int, str, list]]] = None

snowddl/parser/authentication_policy.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
},
3737
"minItems": 1
3838
},
39+
"client_policy": {
40+
"type": "object",
41+
"additionalProperties": {
42+
"type": "object",
43+
"additionalProperties": {
44+
"type": ["array", "boolean", "number", "string"]
45+
}
46+
}
47+
},
3948
"security_integrations": {
4049
"type": "array",
4150
"items": {
@@ -78,10 +87,22 @@ def process_authentication_policy(self, f: ParsedFile):
7887
mfa_enrollment=f.params.get("mfa_enrollment").upper() if f.params.get("mfa_enrollment") else None,
7988
mfa_policy=self.normalise_params_dict(f.params.get("mfa_policy")),
8089
client_types=self.normalise_params_list(f.params.get("client_types")),
90+
client_policy=self._normalise_client_policy(f.params.get("client_policy")),
8191
security_integrations=self.normalise_params_list(f.params.get("security_integrations")),
8292
pat_policy=self.normalise_params_dict(f.params.get("pat_policy")),
8393
workload_identity_policy=self.normalise_params_dict(f.params.get("workload_identity_policy")),
8494
comment=f.params.get("comment"),
8595
)
8696

8797
self.config.add_blueprint(bp)
98+
99+
def _normalise_client_policy(self, client_policy):
100+
if client_policy is None:
101+
return None
102+
103+
result = {}
104+
105+
for k, v in client_policy.items():
106+
result[k.upper()] = self.normalise_params_dict(v)
107+
108+
return result

snowddl/resolver/authentication_policy.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,30 @@ def _build_common_authentication_policy_sql(self, bp: AuthenticationPolicyBluepr
158158
},
159159
)
160160

161+
if bp.client_policy:
162+
query.append_nl("CLIENT_POLICY = (")
163+
164+
for client_name, client_params in bp.client_policy.items():
165+
query.append(
166+
"{client_name:r} = (",
167+
{
168+
"client_name": client_name,
169+
}
170+
)
171+
172+
for param_name, param_value in client_params.items():
173+
query.append(
174+
"{param_name:r} = {param_value:dp}",
175+
{
176+
"param_name": param_name,
177+
"param_value": param_value,
178+
}
179+
)
180+
181+
query.append(")")
182+
183+
query.append(")")
184+
161185
if bp.security_integrations:
162186
query.append_nl(
163187
"SECURITY_INTEGRATIONS = ({security_integrations})",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
authentication_methods: [PASSWORD, SAML]
22
mfa_enrollment: REQUIRED
33
client_types: [ALL]
4+
client_policy:
5+
python_driver:
6+
minimum_version: 4.0.0
7+
jdbc_driver:
8+
minimum_version: 3.20.0
49
security_integrations: [ALL]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
authentication_methods: [ALL]
22
mfa_enrollment: REQUIRED
33
client_types: [ALL]
4+
client_policy:
5+
python_driver:
6+
minimum_version: 4.1.0
47
security_integrations: [ALL]

test/authentication_policy/aup002.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def test_step1(helper):
44
assert params["AUTHENTICATION_METHODS"]["value"] == "[PASSWORD, SAML]"
55
assert params["MFA_ENROLLMENT"]["value"] == "REQUIRED"
66
assert params["CLIENT_TYPES"]["value"] == "[ALL]"
7+
assert params["CLIENT_POLICY"]["value"] == "{JDBC_DRIVER={MINIMUM_VERSION=3.20.0}, PYTHON_DRIVER={MINIMUM_VERSION=4.0.0}}"
78
assert params["SECURITY_INTEGRATIONS"]["value"] == "[ALL]"
89

910

@@ -13,6 +14,7 @@ def test_step2(helper):
1314
assert params["AUTHENTICATION_METHODS"]["value"] == "[ALL]"
1415
assert params["MFA_ENROLLMENT"]["value"] == "REQUIRED"
1516
assert params["CLIENT_TYPES"]["value"] == "[ALL]"
17+
assert params["CLIENT_POLICY"]["value"] == "{PYTHON_DRIVER={MINIMUM_VERSION=4.1.0}}"
1618
assert params["SECURITY_INTEGRATIONS"]["value"] == "[ALL]"
1719

1820

0 commit comments

Comments
 (0)