NIFI-13357 Removed APP_INSTALLATION_TOKEN from GitHubFlowRegistryClient (#8923)

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
David Handermann 2024-06-04 10:51:37 -05:00 committed by GitHub
parent 3ef85e3347
commit f5ecb18fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 33 additions and 24 deletions

View File

@ -17,13 +17,40 @@
package org.apache.nifi.github;
import org.apache.nifi.components.DescribedValue;
/**
* Enumeration of authentication types for the GitHub client.
*/
public enum GitHubAuthenticationType {
public enum GitHubAuthenticationType implements DescribedValue {
NONE,
PERSONAL_ACCESS_TOKEN,
APP_INSTALLATION_TOKEN,
APP_INSTALLATION
NONE("None", "Authentication disabled"),
PERSONAL_ACCESS_TOKEN("Personal Access Token", "User-based Personal Access Token"),
APP_INSTALLATION("App Installation", "App-based Installation Token provisioning from a Private Key");
private final String displayName;
private final String description;
GitHubAuthenticationType(final String displayName, final String description) {
this.displayName = displayName;
this.description = description;
}
@Override
public String getValue() {
return name();
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public String getDescription() {
return description;
}
}

View File

@ -106,7 +106,7 @@ public class GitHubFlowRegistryClient extends AbstractFlowRegistryClient {
static final PropertyDescriptor AUTHENTICATION_TYPE = new PropertyDescriptor.Builder()
.name("Authentication Type")
.description("The type of authentication to use for accessing GitHub")
.allowableValues(GitHubAuthenticationType.values())
.allowableValues(GitHubAuthenticationType.class)
.defaultValue(GitHubAuthenticationType.NONE.name())
.required(true)
.build();
@ -120,15 +120,6 @@ public class GitHubFlowRegistryClient extends AbstractFlowRegistryClient {
.dependsOn(AUTHENTICATION_TYPE, GitHubAuthenticationType.PERSONAL_ACCESS_TOKEN.name())
.build();
static final PropertyDescriptor APP_INSTALLATION_TOKEN = new PropertyDescriptor.Builder()
.name("App Installation Token")
.description("The app installation token to use for authentication")
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.required(true)
.sensitive(true)
.dependsOn(AUTHENTICATION_TYPE, GitHubAuthenticationType.APP_INSTALLATION_TOKEN.name())
.build();
static final PropertyDescriptor APP_ID = new PropertyDescriptor.Builder()
.name("App ID")
.description("Identifier of GitHub App to use for authentication")
@ -155,7 +146,6 @@ public class GitHubFlowRegistryClient extends AbstractFlowRegistryClient {
REPOSITORY_PATH,
AUTHENTICATION_TYPE,
PERSONAL_ACCESS_TOKEN,
APP_INSTALLATION_TOKEN,
APP_ID,
APP_PRIVATE_KEY
);
@ -660,7 +650,6 @@ public class GitHubFlowRegistryClient extends AbstractFlowRegistryClient {
.apiUrl(context.getProperty(GITHUB_API_URL).getValue())
.authenticationType(GitHubAuthenticationType.valueOf(context.getProperty(AUTHENTICATION_TYPE).getValue()))
.personalAccessToken(context.getProperty(PERSONAL_ACCESS_TOKEN).getValue())
.appInstallationToken(context.getProperty(APP_INSTALLATION_TOKEN).getValue())
.appId(context.getProperty(APP_ID).getValue())
.appPrivateKey(context.getProperty(APP_PRIVATE_KEY).getValue())
.repoOwner(context.getProperty(REPOSITORY_OWNER).getValue())

View File

@ -86,7 +86,6 @@ public class GitHubRepositoryClient {
switch (authenticationType) {
case PERSONAL_ACCESS_TOKEN -> gitHubBuilder.withOAuthToken(builder.personalAccessToken);
case APP_INSTALLATION_TOKEN -> gitHubBuilder.withAppInstallationToken(builder.appInstallationToken);
case APP_INSTALLATION -> gitHubBuilder.withAuthorizationProvider(getAppInstallationAuthorizationProvider(builder, appPermissions));
}
@ -462,7 +461,6 @@ public class GitHubRepositoryClient {
private String apiUrl;
private GitHubAuthenticationType authenticationType;
private String personalAccessToken;
private String appInstallationToken;
private String repoOwner;
private String repoName;
private String repoPath;
@ -484,11 +482,6 @@ public class GitHubRepositoryClient {
return this;
}
public Builder appInstallationToken(final String appInstallationToken) {
this.appInstallationToken = appInstallationToken;
return this;
}
public Builder repoOwner(final String repoOwner) {
this.repoOwner = repoOwner;
return this;