Skip to content

Commit bbc0fe9

Browse files
authored
Merge pull request #2 from stackabletech/feature/secret-op-lockdown
Lock down AD rights granted to secret-operator
2 parents 1669305 + d1e6802 commit bbc0fe9

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

roles/ad-dc/tasks/main.yaml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
enabled: true
2626
identity: CN=stackable-secret-operator,CN=Users,DC=sble,DC=test
2727
upn: "{{ secret_operator_principal }}"
28-
groups:
29-
add:
30-
- Domain Admins
28+
register: secret_operator_user
3129
- name: Create Secret-Operator Keytab
3230
ansible.windows.win_command:
3331
cmd: ktpass /princ {{ secret_operator_principal }} /out secret-op.kt +rndPass /ptype KRB5_NT_PRINCIPAL /mapuser {{ secret_operator_principal }} /crypto AES256-SHA1
@@ -37,6 +35,36 @@
3735
dest: target/
3836
flat: true
3937

38+
- name: Create SDP Organizational Unit
39+
microsoft.ad.ou:
40+
name: SDP
41+
register: sdp_ou
42+
- name: Grant permissions on SDP Organizational Unit
43+
ansible.windows.win_shell: |
44+
# In theory this could be done declaratively by setting the nTSecurityDescriptor before, but that turned out to be a mess...
45+
Import-Module ActiveDirectory
46+
$ou_path = "AD:{{ sdp_ou.distinguished_name }}"
47+
$secretop = [System.Security.Principal.SecurityIdentifier]::New("{{ secret_operator_user.sid }}")
48+
$acl = Get-ACL -Path $ou_path
49+
$user_schema_guid = "bf967aba-0de6-11d0-a285-00aa003049e2"
50+
$password_reset_right_guid = "00299570-246d-11d0-a768-00aa006e0529"
51+
$ou_create_children_rule = [System.DirectoryServices.ActiveDirectoryAccessRule]::New(
52+
$secretop,
53+
[System.DirectoryServices.ActiveDirectoryRights]::CreateChild,
54+
[System.Security.AccessControl.AccessControlType]::Allow,
55+
$user_schema_guid,
56+
[System.DirectoryServices.ActiveDirectorySecurityInheritance]::None
57+
)
58+
$ou_reset_passwords_rule = [System.DirectoryServices.ExtendedRightAccessRule]::New(
59+
$secretop,
60+
[System.Security.AccessControl.AccessControlType]::Allow,
61+
$password_reset_right_guid,
62+
[System.DirectoryServices.ActiveDirectorySecurityInheritance]::Children
63+
)
64+
$acl.AddAccessRule($ou_create_children_rule)
65+
$acl.AddAccessRule($ou_reset_passwords_rule)
66+
Set-ACL -Path $ou_path -AclObject $acl
67+
4068
- name: Install AD Certificate Services
4169
ansible.windows.win_feature:
4270
name:

roles/connect-k8s/tasks/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@
8888
passwordCacheSecret:
8989
namespace: default
9090
name: secret-operator-ad-passwords
91-
userDistinguishedName: CN=Users,DC=sble,DC=test
91+
userDistinguishedName: OU=SDP,DC=sble,DC=test
9292
schemaDistinguishedName: CN=Schema,CN=Configuration,DC=sble,DC=test

0 commit comments

Comments
 (0)