Skip to content

feat: support for oidc credential /test endpoint#16370

Draft
fincamd wants to merge 1 commit intoansible:develfrom
fincamd:AAP-67727-oidc-vault-creds-testing
Draft

feat: support for oidc credential /test endpoint#16370
fincamd wants to merge 1 commit intoansible:develfrom
fincamd:AAP-67727-oidc-vault-creds-testing

Conversation

@fincamd
Copy link
Contributor

@fincamd fincamd commented Mar 25, 2026

SUMMARY
ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • API
STEPS TO REPRODUCE AND EXTRA INFO

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4192ca14-6fc6-4382-b90e-f22f23371bbf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

)
backend_kwargs['workload_identity_token'] = workload_identity_token
from jwt import decode as _jwt_decode
response_body['sent_jwt_payload'] = _jwt_decode(workload_identity_token, algorithms=["RS256"], options={"verify_signature": False})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the conversation we had around the PoC we were thinking about nesting sent_jwt_payload under something more generic:

{
    "details": {
         "sent_jwt_payload": "..."
    }
}

This pattern is followed some lines above, but not here. Was this intentional?

return Response({'detail': _('Job template ID is required.')}, status=status.HTTP_400_BAD_REQUEST)
job_template = models.JobTemplate.objects.get(id=int())
if not request.user.can_access(models.JobTemplate, 'read', job_template):
raise PermissionDenied(_(f'You do not have access to job template with id: {job_template.id}.'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in this case? Do we get a 500 HTTP error? Or something else? Shouldn't we be returning another HTTP_400_BAD_REQUEST here, instead of raising an exception?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +2945 to +2955
# If workload identity token field exists, add job_template to metadata
if found_wit_field:
metadata = value['inputs'].get('metadata', [])
metadata.append({
"id": "job_template_id",
"label": "ID of a Job Template",
"type": "string",
"help_text": "Job template ID to use when generating a token."
})
value['inputs']['metadata'] = metadata

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about making this a dynamic input in the UI instead of making it a dynamic field in the backend.

Both solutions are ugly, but my personal take is that the UI workaround is less ugly. Please take a look that the drafted PR linked in AAP-64624 (the corresponding UI change). Thoughts?

Copy link
Contributor

@dleehr dleehr Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that it's less ugly for the UI to special-case the inclusion of job_template_id when performing a test. This just came up on Slack and I said the same thing 😄 . So I think we can delete 2945-2955

Copy link
Contributor

@dleehr dleehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos to @matoval for testing this with the UI. Some early feedback:

  1. Both CredentialExternalTest and CredentialTypeExternalTest views need to implement the new behavior. Right now it's just happening in CredentialExternalTest
  2. Calling the API with a job_template_id fails because the plugin's backend function doesn't expect this argument. Matthew suggested to .pop() the job template id instead of .get(). I don't remember running into this problem in my PoC 🤔, but we obviously don't want it to fail.
  3. The test operation re-uses retrieve_workload_identity_jwt function from jobs.py to get a JWT, but that's intended for jobs not templates and isn't working. We'll need to do something different there - we can't use that function as-is with job templates, it's meant for jobs.

raise PermissionDenied(_(f'You do not have access to job template with id: {job_template.id}.'))

# Get a Workload Identity Token
workload_identity_token = retrieve_workload_identity_jwt(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Credit to @matoval but this function expects a job, not a job template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants