Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-AccessToken does not decrypt supplied PSCredential #19

Closed
wilddev65 opened this issue Jul 21, 2021 · 2 comments
Closed

-AccessToken does not decrypt supplied PSCredential #19

wilddev65 opened this issue Jul 21, 2021 · 2 comments

Comments

@wilddev65
Copy link
Collaborator

VenafiTppPS version: 20.4
PowerShell version: 5.1


# Steps to reproduce

$AccessToken = New-Object System.Management.Automation.PSCredential('AccessToken', ($token.AccessToken | ConvertTo-SecureString -AsPlainText -Force))
Revoke-TppToken -AuthServer $AuthUrl -AccessToken $AccessToken

# Expected behavior

Token is revoked in TPP

# Actual behavior

StatusCode        : 202
StatusDescription : Invalid token format
Content           : {}
RawContent        : HTTP/1.1 202 Invalid token format
                    Access-Control-Allow-Origin: *
                    X-Frame-Options: SAMEORIGIN
                    X-Content-Type-Options: nosniff
                    Strict-Transport-Security: max-age=31536000; includeSubDomains
                    Content...
Headers           : {[Access-Control-Allow-Origin, *], [X-Frame-Options, SAMEORIGIN], [X-Content-Type-Options, nosniff], [Strict-Transport-Security,     
                    max-age=31536000; includeSubDomains]...}
RawContentLength  : 0

# Fix

Revoke-TppToken, line 98
-$params.Header = @{'Authorization' = 'Bearer {0}' -f $AccessToken }
+$params.Header = @{'Authorization' = 'Bearer {0}' -f $AccessToken.GetNetworkCredential().password }
@gdbarron
Copy link
Collaborator

@wilddev65, since it's not being stored and security isn't an issue, would it make more sense for -AccessToken to accept a string instead of a credential? I think the original idea was to have a mechanism to revoke a token if it was obtained from another source and converting it to a credential in this case is probably not needed. Thoughts?

Out of curiosity, what is $token.AccessToken in your steps to reproduce, not from New-TppToken?

@wilddev65
Copy link
Collaborator Author

Sorry, $token.AccessToken is just a token string to feed Revoke-Token a PSCredential object. Should have been more clear about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants