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

Feature: datasource changes for api key auth, bearer token auth, combine config. #4683

Merged
Prev Previous commit
Next Next commit
move constants to Authentication.java
  • Loading branch information
sumitsum committed May 27, 2021
commit 8e0207ccd6b664d113001882bde0312e8d9bc1c6
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Authentication {
public static final String AUTHORIZATION_URL = "authorization_url";
public static final String ACCESS_TOKEN_URL = "access_token_url";
public static final String RESPONSE_TYPE = "response_type";
public static final String API_KEY_PARAM = "api_key";

// Request parameter values
public static final String AUTHORIZATION_CODE = "authorization_code";
Expand All @@ -35,4 +36,7 @@ public class Authentication {

// Header names
public static final String AUTHORIZATION_HEADER = "Authorization";

// Other constants
public static final String BEARER = "Bearer";
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

import java.net.URI;

import static com.appsmith.external.constants.Authentication.API_KEY_PARAM;

@Setter
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ApiKeyAuthentication extends APIConnection{
private final String PARAM_NAME = "api_key";
private String key;

public static Mono<ApiKeyAuthentication> create(ApiKeyAuth apiKeyAuth) {
Expand Down Expand Up @@ -61,7 +62,7 @@ private URI appendApiKeyParamToUrl(URI oldUrl) {

private String appendApiKeyParamToQuery(String oldQuery) {
sumitsum marked this conversation as resolved.
Show resolved Hide resolved
return StringUtils.isEmpty(oldQuery) ?
PARAM_NAME + "=" + this.key :
oldQuery + "&" + PARAM_NAME + "=" + this.key;
API_KEY_PARAM + "=" + this.key :
oldQuery + "&" + API_KEY_PARAM + "=" + this.key;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import reactor.core.publisher.Mono;

import static com.appsmith.external.constants.Authentication.AUTHORIZATION_HEADER;
import static com.appsmith.external.constants.Authentication.BEARER;

@Setter
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class BearerTokenAuthentication extends APIConnection {
private final String HEADER_PREFIX = "Bearer";
private String bearerToken;

public static Mono<BearerTokenAuthentication> create(BearerTokenAuth bearerTokenAuth) {
Expand All @@ -43,7 +43,6 @@ public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next)
}

private String getHeaderValue() {
return HEADER_PREFIX + " " + this.bearerToken;
return BEARER + " " + this.bearerToken;
}

}