Skip to content

Commit 15dbab7

Browse files
remcoykemaJeroenBL
andauthored
Zenya permission reference fix (#19)
* fixed_permission_reference * updated changelog * Fix formatting and minor logic in group permissions scripts Cleaned up whitespace, improved formatting, and fixed minor issues in grantPermission.ps1 and permissions.ps1. Removed extra parentheses in group display names. --------- Co-authored-by: Jeroen Blaauw <72070984+JeroenBL@users.noreply.github.com>
1 parent 2ff8bc9 commit 15dbab7

8 files changed

Lines changed: 58 additions & 1057 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
44

5+
## [3.1.0] 2026-01-22
6+
### Changed
7+
- Fix: In version 3.0.0 the permission reference field name was accidentally renamed (from ".Id" to .Reference). This has been rolled back.
58

69
## [3.0.0] 2026-01-15
7-
810
### Added
911
- Added permission import script for groups
1012
### Changed

permissions/grantPermission.ps1

Lines changed: 0 additions & 205 deletions
This file was deleted.

permissions/groups/grantPermission.ps1

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function Get-AuthToken {
9696

9797
$body = @{
9898
client_id = $ClientID
99-
client_secret = $ClientSecret
99+
client_secret = $ClientSecret
100100
grant_type = 'client_credentials'
101101
}
102102

@@ -109,43 +109,43 @@ function Get-AuthToken {
109109
#endregion functions
110110

111111
try {
112-
#region Verify account reference
113-
112+
#region Verify account reference
113+
114114
if ([string]::IsNullOrEmpty($($actionContext.References.Account.id))) {
115115
throw "The account reference could not be found"
116116
}
117-
#endregion Verify account reference
117+
#endregion Verify account reference
118118
$splatScimToken = @{
119119
ClientId = $actionContext.Configuration.ScimClientId
120120
ClientSecret = $actionContext.Configuration.scimclientSecret
121-
TokenUri = "$($ActionContext.Configuration.ScimBaseUrl)/oauth/token"
122-
}
121+
TokenUri = "$($ActionContext.Configuration.ScimBaseUrl)/oauth/token"
122+
}
123123
$scimToken = Get-AuthToken @splatScimToken
124124

125-
$splatApiToken = @{
125+
$splatApiToken = @{
126126
clientId = $actionContext.Configuration.ApiClientId
127127
clientSecret = $actionContext.Configuration.ApiClientSecret
128-
TokenUri = "$($ActionContext.Configuration.ApiBaseUrl)/api/oauth/token"
128+
TokenUri = "$($ActionContext.Configuration.ApiBaseUrl)/api/oauth/token"
129129
}
130130
$apiToken = Get-AuthToken @splatApiToken
131131

132-
#endregion Create access token
132+
#endregion Create access token
133133

134134
#region Create headers
135-
$ScimHeaders = @{
136-
"Content-Type" = "application/json;charset=utf-8"
137-
}
138-
$scimHeaders['Authorization'] = "$($scimToken.token_type) $($scimToken.access_token)"
139-
135+
$ScimHeaders = @{
136+
"Content-Type" = "application/json;charset=utf-8"
137+
}
138+
$scimHeaders['Authorization'] = "$($scimToken.token_type) $($scimToken.access_token)"
139+
140140
$apiHeaders = @{
141141
"Accept" = "application/json"
142142
"Content-Type" = "application/json;charset=utf-8"
143143
"X-Api-Version" = 5
144-
}
145-
$apiHeaders['Authorization'] = "$($apiToken.token_type) $($apiToken.access_token)"
144+
}
145+
$apiHeaders['Authorization'] = "$($apiToken.token_type) $($apiToken.access_token)"
146146
#endregion Create headers
147147

148-
148+
149149
Write-Information 'Verifying if a Zenya account exists'
150150
$splatGetUser = @{
151151
Uri = "$($actionContext.Configuration.ScimBaseUrl)/scim/Users/$($actionContext.References.Account.id)"
@@ -162,26 +162,26 @@ try {
162162
}
163163

164164
switch ($action) {
165-
'GrantPermission' {
166-
167-
165+
'GrantPermission' {
166+
167+
168168
$grantPermissionBody = @{
169169
"add_user_ids" = @($($actionContext.References.Account.Id))
170170
}
171171

172172
$splatGrantGroupMember = @{
173-
Uri = "$($actionContext.Configuration.ApiBaseUrl)/api/user_groups/$($actionContext.References.Permission.Reference)"
173+
Uri = "$($actionContext.Configuration.ApiBaseUrl)/api/user_groups/$($actionContext.References.Permission.Id)"
174174
Method = "PATCH"
175-
Body = ($grantPermissionBody | ConvertTo-Json -Depth 10)
175+
Body = ($grantPermissionBody | ConvertTo-Json -Depth 10)
176176
Headers = $apiHeaders
177177
}
178178

179179
if (-not($actionContext.DryRun -eq $true)) {
180-
Write-Information "Granting Zenya permission: [$($actionContext.PermissionDisplayName)] - [$($actionContext.References.Permission.Reference)]"
181-
$null = Invoke-RestMethod @splatGrantGroupMember
180+
Write-Information "Granting Zenya permission: [$($actionContext.PermissionDisplayName)] - [$($actionContext.References.Permission.Id)]"
181+
$null = Invoke-RestMethod @splatGrantGroupMember
182182
}
183183
else {
184-
Write-Information "[DryRun] Grant Zenya permission: [$($actionContext.PermissionDisplayName)] - [$($actionContext.References.Permission.Reference)], will be executed during enforcement"
184+
Write-Information "[DryRun] Grant Zenya permission: [$($actionContext.PermissionDisplayName)] - [$($actionContext.References.Permission.Id)], will be executed during enforcement"
185185
}
186186

187187
$outputContext.Success = $true
@@ -227,4 +227,3 @@ catch {
227227

228228

229229

230-

0 commit comments

Comments
 (0)