-
Notifications
You must be signed in to change notification settings - Fork 165
feat: Add GetTokens, GetTokensByID, RevokeTokenByID methods #1255
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
Conversation
…GetTokenByID tests
README.md
Outdated
| Username: "admin", // Filter by username | ||
| Refreshable: utils.Pointer(true), // Filter by refreshable status | ||
| TokenId: "token-id", // Filter by specific token ID | ||
| OrderBy: "issued_at", // Order by field (issued_at, expires_at, etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Order by field (created,token_id,owner,subject,expiry)
https://jfrog.com/help/r/jfrog-rest-apis/get-tokens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right — the information was inaccurate. I'll correct it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the correction!
access/services/accesstoken.go
Outdated
| } | ||
| if params.LastUsed != nil { | ||
| queryParams.Add("last_used", strconv.FormatInt(*params.LastUsed, 10)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last_used should be removed as it is not supported by the backend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I look at the document below, it suggests in a Note that the last_used parameter is available under certain conditions — is that not correct?
https://jfrog.com/help/r/jfrog-rest-apis/get-tokens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Note holds true for the response payload. But its not supported as query param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I've made the correction, so please take a look.
access/services/accesstoken.go
Outdated
| if err != nil { | ||
| return err | ||
| } | ||
| return errorutils.CheckResponseStatusWithBody(resp, body, http.StatusOK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add http.StatusNoContent as well.API will return 204 incase if token doesn't exist or already revoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it!
* Add retry to POST build scan trigger if needed * retry err as suffix * build name can be not alphabet * fix regex number * use retry * add debug log * fix tests
* Xray Remediation Service * add remediation service to xray manager * rename facade method * start adding tests for new API * switch to new API * start fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * add content type * fix attribs in resp struct * CR changes
* Removed repo field in AQL query * Updated test case
…#1265) * Fix an issue that evidence encoded url twice resulting in a wrong url * Add evidence client mock in order to make evidence APIs more accurate in evidence tests
* Xray Get Violations API * change upload log to debug * fix log remove file * add NewWatchRepositoryByName * fix create watch body * format * CR changes * add LineNumber to API
Co-authored-by: remib <[email protected]>
* Fix application details resolution from api * Add new fields for criticality and maturity to README
* added git integration post request * added function to XscService interface * added SendGitIntegrationEvent to xsc inner service * after cr
* Fix Remediation after API breaking change * add more changes to the API * fix test
* malicious-code-scanner * malicious-code-scanner
* updated CC structs and comparison file * removing DisplayFixableOnly and MinSeverityToDisplay * setting back ConfigProfileNewSchemaMinXrayVersion
|
The upstream merge ended up in an odd state, so I'll recreate the PR. |
|
@0x01F4 @abhisheksaxena29 I recreated the PR(#1282) to ensure the diff is applied correctly. |

This pull request adds new functionality to manage access tokens more effectively, including retrieving and revoking tokens by ID, as well as filtering and listing tokens. It introduces new methods in the access token service and manager, updates the documentation, and adds comprehensive tests for these features.
New Access Token Management Features:
Added methods to
TokenServiceandAccessServicesManagerfor:GetTokens)GetTokenByID)RevokeTokenByID) [1] [2] [3]Introduced new parameter and response types:
GetTokensParams,TokenInfo, andTokenInfosstructs for handling token queries and responsesDocumentation Updates:
README.mdto document:Testing Enhancements:
testGetTokenstestGetTokenByIDtestRevokeTokenByID[1] [2]These changes make it easier to programmatically manage access tokens, improving both usability and test coverage.