-
Notifications
You must be signed in to change notification settings - Fork 5
Set-TppPermission validatescript regex #126
Comments
Interesting, I never thought a domain name could have a space in it so wouldn't have expected that to fail. Your fix definitely gets the job done and what I'll implement in lieu of researching what's allowed for AD domain names and limiting to that which probably isn't needed. |
The actual domain doesn't have a space in it (the real name has been obfuscated), but the provider name that comes back for prefixeduniversalid is based on a friendly name of "Domain Identity Store" so "Initech Identity Store" is basically what it looks like just replace Initech with a real domain value. So someone gave it that name way back when. We have other friendly names with descriptive titles as well that are required to match as the provider. |
Thanks for this. I forget it's technically the 'provider' and not domain name. Update is taking a bit longer than expected as I went down a rabbit hole and cleaning up the entire 'Identity' part of the module. I'd be appreciative if you were able to provide any feedback on the code thus far, https://github.com/gdbarron/VenafiTppPS/compare/issue-126. Still have help updates to do, but much of the code is there. Let me know what you think! |
Sounds great, I'll pull an update and check it out and provide feedback |
Thanks! Quick rundown of updates:
|
Ok, took longer to take a look than I expected. The core issue is fixed for sure for my provider with the space. And while I saw new params in the branch , I kept the code to where it was at before to see if I needed to do any updates and if the aliases will work as is. I can update the code with the new param values, but here's the examples of the errors I get if I keep it "as is". Get-TPPIdentityAttribute $certdeets.approver is in prefixeduniversalid format
Error Get-TppIdentityAttribute : Cannot bind argument to parameter 'IdentityId' because it is null. Get-TppPermission Code Snippet Error _Get-TppPermission : A parameter cannot be found that matches parameter name 'Attribute'.
Set-TppPermission Code Snippet
Error Set-TppPermission : Cannot validate argument on parameter 'IdentityId'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. |
Thanks for all the feedback. The |
The values were not null and they work if I go against the other branch (with my local update for the regex for set-tpppermission). I'll use the new params and test and report back (though might not be til tonight). |
Appreciate any feedback as I'm only able to repro on either branch with null or empty values. Also, was thinking it would be better to keep the attribute param as is and add a warning it will be deprecated so nothing breaks. |
Ok, I do like the richer info that comes back here with identity info on some of the permission functions . Actually might save time here since you can grab more info in one shot. For my purposes, as this is a new script, it's not a big deal to switch it out to new params, but for someone with an existing codebase , I think keeping the various params and deprecating it makes sense. I was able to incorporate the new param values and got it working same as the previous commit branch. The only item to note was on Get-TppPermission is that GUID doesn't seem to work anymore. It seemed like it showed up as a param though still. It seems like it requires path for sure (which isn't really a big deal..)
$GUID equals {02128cf9-f038-4bc5-a275-8ef0aeb057ef} get-tpppermission : Couldn't obtain list of permissions for . "404 Not Found: The remote server returned an error: (404) Not Found. At line:1 char:1 + get-tpppermission -guid $GUID |
|
Awesome news and glad to help, also glad this module is out there ! |
v2.2 released. @DadsVacayShorts, thanks again and let me know of any issues. |
Environment
Steps to reproduce
When using Set-TppPermission in 2.1.1, there appears to be a validation error. with PrefixedUniversalId that is not present when using raw api calls like this
$SetPerms = Invoke-RestMethod -Method POST -Uri "https://$vtp_host/vedsdk/Permissions/object/$GUID/AD/$Addprovname/$IDApproverUUID"
-Body $AddPermsJSON -Headers $headers -ContentType 'application/json' -ErrorVariable RestError`Expected behavior
I'm expecting that I can take a permissions object and set it to a cert guid for a specific prefixeduniversalid
Set-TppPermission -guid '6874ee6d-9efa-4cf2-9037-7db09f94b6df' -PrefixedUniversalId $item2.PrefixedUniversalId -Permission $item2.ExplicitPermissions
Actual behavior
When I use the above code I get a validation error
Looking at the set-tpppermission script the validation script has this regex.
I think that is failing because the provider name in my case is going to be a combination of white space and alpha and I think the \S expects the value before the : to have only white space but regex is always a tricky beast so don't quote me on it :).
If I update the regex to this to match any character after (AD|Ldap): with a +. (which is a brute force test here)
$_ -match '(AD|LDAP)+.+:\w{32}$' -or $_ -match 'local:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$'
, then I can run the function and it applies the permissions object correctly and there are no errors.
Hope that helps.
Screenshots
The text was updated successfully, but these errors were encountered: