Skip to content

Commit

Permalink
feat: support for authType=bearerToken for NPM proxy repository (sona…
Browse files Browse the repository at this point in the history
  • Loading branch information
afrimberger committed Dec 19, 2024
1 parent fc7a257 commit e89ed1d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
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

0 comments on commit e89ed1d

Please sign in to comment.