Skip to content

Conversation

@mlajkim
Copy link
Contributor

@mlajkim mlajkim commented Jun 9, 2025

Background

The current GItHubActionInstanceProvider does not allow multiple GitHub Action environments with one Athenz ZTS Server.

What's done?

Allows ZTS owner to set multiple GitHub Action environments with config, with issuer as an ID
By setting following:

athenz.zts.github_actions.prop_file_path=/path/to/file/for/the/config.json

With the following:

{
  "props": [
    {
      "provider_dns_suffix": "example-suffix1",
      "enterprise": "enterprise1",
      "audience": "https://audience1.com",
      "issuer": "https://issuer1.com",
      "jwks_uri": "https://issuer1.com/jwks"
    },
    {
      "provider_dns_suffix": "example-suffix3,example-suffix4",
      "enterprise": "enterprise2",
      "audience": "https://audience2.com",
      "issuer": "https://issuer2.com",
      "jwks_uri": "https://issuer2.com/jwks"
    }
  ]
}

Minor Changes

  • Log InstanceGithubActionsProp not initialized added
  • JWT Processor not initialized log modified
    • Into JWT Processor not found for issuer: <issuer_name>
  • Log token issuer is not GitHub Actions: <claim_issuer> removed

Contribution Checklist:

  • The pull request does not introduce any breaking changes
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Attach Screenshots (Optional)

mlajkim added 20 commits June 17, 2025 08:21
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
Signed-off-by: Jeongwoo Kim - jekim <[email protected]>
@mlajkim mlajkim force-pushed the feat/file-configuration-for branch from 2a3a938 to defeea4 Compare June 16, 2025 23:21
@@ -0,0 +1,93 @@
package com.yahoo.athenz.instance.provider.impl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add the Athenz Authors header block (see other files in the repo)

if (issuer == null || providerDnsSuffix == null || audience == null || jwksUri == null) {
throw new IllegalArgumentException("One of the required properties is null");
}
properties.put(issuer, new Prop(providerDnsSuffix, audience, enterprise, jwksUri));
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add a check to see if the issuer is already set or not. otherwise, if the admin makes a mistake and specifies the same issuer in two different blocks, then the second one will override the first one and there would be no indication that it has taken place until the end users complain about their actions not working. e.g. both blocks have the same issuer:

{ "props": [ { "provider_dns_suffix": "example-suffix1,example-suffix2", "enterprise": "enterprise1", "audience": "https://audience1.com", "issuer": "https://issuer1.com", "jwks_uri": "https://issuer1.com/jwks" }, { "provider_dns_suffix": "example-suffix3,example-suffix4", "enterprise": "enterprise2", "audience": "https://audience2.com", "issuer": "https://issuer1.com", "jwks_uri": "https://issuer2.com/jwks" } ] }

also please add a corresponding test case for it.


// Method to add properties
public void addProperties(String issuer, String providerDnsSuffix, String audience, String enterprise, String jwksUri) {
if (issuer == null || providerDnsSuffix == null || audience == null || jwksUri == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we only care about nulls or should we also check for empty strings?

return properties.get(issuer).enterprise;
}

public Boolean hasEnterprise (String issuer) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove the space after the method name


props.addProperties(
githubIssuer,
System.getProperty(GITHUB_ACTIONS_PROP_PROVIDER_DNS_SUFFIX, "github-actions.athenz.io"), // determine the dns suffix. if this is not specified we'll just default to github-actions.athenz.cloud
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's fix the comment to say githib-actions.athenz.io instead of athenz.cloud (the original code had the issue).


githubIssuer = System.getProperty(GITHUB_ACTIONS_PROP_ISSUER, GITHUB_ACTIONS_ISSUER);
jwtProcessor = JwtsHelper.getJWTProcessor(new JwtsSigningKeyResolver(extractGitHubIssuerJwksUri(githubIssuer), null));
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if I like the order of objects here since it kind of creates a somewhat ambiguous set up. I can configure both a file and property settings and they both will be set accordingly which is probably not what we expect. I'd like to have the following order where the preference is given to the file config and the property settings are read only if the file config is not set. So we should have the following logic:

// we should not catch any exceptions and instead any errors
// need to be reported to the caller as failures

initializeFromFilePath();

// at this point if our configuration is set as in we have valid
// entries in our props objects, we're done and nothing else to do

if (!props.isEmpty()) {
return;
}

// otherwise add a new issuer entry based on the configured property values

String githubIssuer = System.getProperty(GITHUB_ACTIONS_PROP_ISSUER, GITHUB_ACTIONS_ISSUER);
.... (like you have the code above).

So with this model there is only a single way to configure the provider - either valid file config or system properties.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So just to follow-up, in the InstanceGithubActionsProp class you need to define a new member method called isEmpty that returns boolean whether or not member field properties hashmap has entries or not.

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

Successfully merging this pull request may close these issues.

2 participants