feat: Fetch service account OIDC data#402
Conversation
3b7a3c1 to
741ab5e
Compare
| } | ||
|
|
||
| // GetOIDCIdentities queries all OIDC identities for the provided service account ID | ||
| func GetOIDCIdentities(client newclient.Client, query OIDCIdentityQuery) (*resources.Resources[*OIDCIdentity], error) { |
There was a problem hiding this comment.
I don't think this function has ever worked. I'm considering removing it but would like another opinion on whether to fix or remove
There was a problem hiding this comment.
Since this is a library being used by customers, we should try to fix it rather than delete. We aren't the only users of this library.
Log an issue if you can determine how it is broken.
|
|
||
| return res, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm guessing you've tested these with terraform. But is there a reason its difficult to have tests in go as well? Is it because of the difficulty of creating a service account for it? Is a service account the account you have with an auth application? so you'd need to simmulate an account with an external application?
There was a problem hiding this comment.
Yes, I've tested manually, both using the client directly and via terraform. There are no existing tests for OIDC identities to work from and the setup looks fairly complex
| type OIDCIdentityQuery struct { | ||
| Skip int `uri:"skip,omitempty" url:"skip,omitempty"` | ||
| Take int `uri:"take,omitempty" url:"take,omitempty"` | ||
| ServiceAccountId string `uri:"serviceAccountId" url:"serviceAccountId"` |
There was a problem hiding this comment.
Would adding this field break old usages of the query if they were wotking?
There was a problem hiding this comment.
If there were working usages of this query, adding ServiceAccountId would not break them since it would default to empty string, but this query was only used for the GetOIDCIdentities function which was calling api/serviceaccounts//oidcidentities/v1{?skip,take} when the service account ID was not provided (note the double forward slash) and that endpoint does not exist on Octopus server.
The correct endpoint is api/serviceaccounts/{serviceAccountId}/oidcidentities/v1{?skip,take} where service account ID, Skip and Take are all required
There was a problem hiding this comment.
Maybe if someone had used the query to build a custom request so that they could bypass the broken function, there could be a working use of this and I guess we can't exactly predict whether the changes could break custom code. I still think this is a worthwhile change, but could release it as a potentially breaking change
There was a problem hiding this comment.
Yeah makes sense. Seems like the custom code situation would be super edge case
Rose-Northey
left a comment
There was a problem hiding this comment.
thanks for answering my questions
This reverts commit 53933a6.
This reverts commit fac8f8c.
Background
[SC-136951]
For the terraform changes in this PR OctopusDeploy/terraform-provider-octopusdeploy#176, the client needs to return the service account external ID so that it can be used as an output by terraform. The Octopus API returns this information via the
/api/serviceaccounts/Users-83/oidcidentities/v1?skip=0&take=1endpoint which theGetOIDCIdentitiesfunction was attempting to call but there were a few problems:api/serviceaccounts/{serviceAccountId}/oidcidentities/v1{?skip,take}) requiresserviceAccountIdbut that was not being provided either as a method parameter or part of the query object.I've added the serviceAccountID to the query object so the original function can hit the correct endpoint now, however the response mapping is still broken.
Testing
Go snippet for testing:
Results
The
GetOIDCIdentitiesfails to map the response correctly so returns no data. The ExternalId and OIDC Identities are successfully returned by the new function.