Skip to content
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

feat: support for authType=bearerToken for NPM proxy repository #541

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private void convertAuthentication(
authenticationConfiguration.set("password", authentication.getPassword());
authenticationConfiguration.set("ntlmHost", authentication.getNtlmHost());
authenticationConfiguration.set("ntlmDomain", authentication.getNtlmDomain());
authenticationConfiguration.set("bearerToken", authentication.getBearerToken());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ protected HttpClientAttributes getHttpClientAttributes(final Repository reposito
String username = authenticationMap.get("username", String.class);
String ntlmHost = authenticationMap.get("ntlmHost", String.class);
String ntlmDomain = authenticationMap.get("ntlmDomain", String.class);
String bearerToken = authenticationMap.get("bearerToken", String.class);

authentication = new HttpClientConnectionAuthenticationAttributes(type, username, null, ntlmHost, ntlmDomain);
authentication = new HttpClientConnectionAuthenticationAttributes(type, username, null, ntlmHost, ntlmDomain, bearerToken);
}

HttpClientConnectionAttributes connection = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,40 @@ public class HttpClientConnectionAuthenticationAttributes
@ApiModelProperty(access = "writeOnly")
protected final String password;

@ApiModelProperty(access = "writeOnly")
protected final String bearerToken;

@ApiModelProperty
protected final String ntlmHost;

@ApiModelProperty
protected final String ntlmDomain;

public HttpClientConnectionAuthenticationAttributes(
@JsonProperty("type") final String type,
@JsonProperty("username") final String username,
@JsonProperty(value = "password", access = Access.WRITE_ONLY) final String password,
@JsonProperty("ntlmHost") final String ntlmHost,
@JsonProperty("ntlmDomain") final String ntlmDomain)
{
this(type, username, password, ntlmHost, ntlmDomain, null);
}

@JsonCreator
public HttpClientConnectionAuthenticationAttributes(
@JsonProperty("type") final String type,
@JsonProperty("username") final String username,
@JsonProperty(value = "password", access = Access.WRITE_ONLY) final String password,
@JsonProperty("ntlmHost") final String ntlmHost,
@JsonProperty("ntlmDomain") final String ntlmDomain)
@JsonProperty("ntlmDomain") final String ntlmDomain,
@JsonProperty(value = "bearerToken", access = Access.WRITE_ONLY) final String bearerToken)
{
this.type = type;
this.username = username;
this.password = password;
this.ntlmHost = ntlmHost;
this.ntlmDomain = ntlmDomain;
this.bearerToken = bearerToken;
}

public String getType() {
Expand All @@ -75,4 +90,8 @@ public String getNtlmHost() {
public String getNtlmDomain() {
return ntlmDomain;
}

public String getBearerToken() {
return bearerToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ public HttpClientConnectionAuthenticationAttributesWithPreemptive(
@JsonProperty("username") final String username,
@JsonProperty(value = "password", access = Access.WRITE_ONLY) final String password,
@JsonProperty("ntlmHost") final String ntlmHost,
@JsonProperty("ntlmDomain") final String ntlmDomain)
@JsonProperty("ntlmDomain") final String ntlmDomain,
@JsonProperty(value = "bearerToken", access = Access.WRITE_ONLY) final String bearerToken)
{
super(type, username, password, ntlmHost, ntlmDomain);
super(type, username, password, ntlmHost, ntlmDomain, bearerToken);
this.preemptive = preemptive;
}

public HttpClientConnectionAuthenticationAttributesWithPreemptive(
final HttpClientConnectionAuthenticationAttributes auth,
final Boolean preemptive)
{
super(auth.getType(), auth.getUsername(), auth.getPassword(), auth.getNtlmHost(), auth.getNtlmDomain());
super(auth.getType(), auth.getUsername(), auth.getPassword(), auth.getNtlmHost(), auth.getNtlmDomain(), auth.getBearerToken());
this.preemptive = preemptive;
}

Expand Down