-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new table for auth to make way for common auth
Signed-off-by: Saad Khan <[email protected]>
- Loading branch information
Showing
12 changed files
with
208 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
create table IF NOT EXISTS kruize_datasources (version varchar(255), name varchar(255), provider varchar(255), serviceName varchar(255), namespace varchar(255), url varchar(255), authentication jsonb, primary key (name)); | ||
create table IF NOT EXISTS kruize_datasources (version varchar(255), name varchar(255), provider varchar(255), serviceName varchar(255), namespace varchar(255), url varchar(255), authentication_id serial, FOREIGN KEY (authentication_id) REFERENCES kruize_authentication(id), primary key (name)); | ||
create table IF NOT EXISTS kruize_dsmetadata (id serial, version varchar(255), datasource_name varchar(255), cluster_name varchar(255), namespace varchar(255), workload_type varchar(255), workload_name varchar(255), container_name varchar(255), container_image_name varchar(255), primary key (id)); | ||
alter table kruize_experiments add column experiment_type varchar(255), add column metadata_id bigint references kruize_dsmetadata(id), alter column datasource type varchar(255); | ||
create table IF NOT EXISTS kruize_metric_profiles (api_version varchar(255), kind varchar(255), metadata jsonb, name varchar(255) not null, k8s_type varchar(255), profile_version float(53) not null, slo jsonb, primary key (name)); | ||
alter table kruize_recommendations add column experiment_type varchar(255); | ||
create table IF NOT EXISTS kruize_authentication (id serial, credentials jsonb, service_type varchar(255), primary key (id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.autotune.common.auth; | ||
|
||
public enum AuthType { | ||
BASIC, BEARER, API_KEY, OAUTH2, NONE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 49 additions & 59 deletions
108
src/main/java/com/autotune/common/auth/Credentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,98 @@ | ||
package com.autotune.common.auth; | ||
|
||
public class Credentials { | ||
private String grantType; // OAuth2 | ||
private String clientId; // OAuth2 | ||
private String clientSecret; // OAuth2 | ||
private String username; // Basic auth | ||
private String password; // Basic auth | ||
private String tokenEndpoint; // OAuth2 | ||
private String tokenFilePath; // Bearer token | ||
private String apiKey; // API key | ||
private String headerName; // API key header name | ||
|
||
public Credentials(String username, String password) { | ||
this.username = username; | ||
this.password = password; | ||
} | ||
|
||
public Credentials() { | ||
} | ||
public abstract class Credentials { | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
class OAuth2Credentials extends Credentials { | ||
private String grantType; | ||
private String clientId; | ||
private String clientSecret; | ||
private String tokenEndpoint; | ||
|
||
public String getGrantType() { | ||
return grantType; | ||
} | ||
|
||
public String getClientSecret() { | ||
return clientSecret; | ||
public void setGrantType(String grantType) { | ||
this.grantType = grantType; | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public String getTokenEndpoint() { | ||
return tokenEndpoint; | ||
} | ||
|
||
public String getHeaderName() { | ||
return headerName; | ||
public void setClientId(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
|
||
public String getApiKey() { | ||
return apiKey; | ||
public String getClientSecret() { | ||
return clientSecret; | ||
} | ||
|
||
public String getTokenFilePath() { | ||
return tokenFilePath; | ||
public void setClientSecret(String clientSecret) { | ||
this.clientSecret = clientSecret; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
public String getTokenEndpoint() { | ||
return tokenEndpoint; | ||
} | ||
|
||
public void setGrantType(String grantType) { | ||
this.grantType = grantType; | ||
public void setTokenEndpoint(String tokenEndpoint) { | ||
this.tokenEndpoint = tokenEndpoint; | ||
} | ||
} | ||
|
||
public void setClientId(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
class BasicAuthCredentials extends Credentials { | ||
private String username; | ||
private String password; | ||
|
||
public void setClientSecret(String clientSecret) { | ||
this.clientSecret = clientSecret; | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
} | ||
|
||
public void setTokenEndpoint(String tokenEndpoint) { | ||
this.tokenEndpoint = tokenEndpoint; | ||
class BearerTokenCredentials extends Credentials { | ||
private String tokenFilePath; | ||
|
||
public String getTokenFilePath() { | ||
return tokenFilePath; | ||
} | ||
|
||
public void setTokenFilePath(String tokenFilePath) { | ||
this.tokenFilePath = tokenFilePath; | ||
} | ||
} | ||
|
||
class ApiKeyCredentials extends Credentials { | ||
private String apiKey; | ||
private String headerName; | ||
|
||
public String getApiKey() { | ||
return apiKey; | ||
} | ||
|
||
public void setApiKey(String apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
|
||
public void setHeaderName(String headerName) { | ||
this.headerName = headerName; | ||
public String getHeaderName() { | ||
return headerName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Credentials{" + | ||
"grantType='" + grantType + '\'' + | ||
", clientId='" + clientId + '\'' + | ||
", clientSecret='" + clientSecret + '\'' + | ||
", username='" + username + '\'' + | ||
", password='" + password + '\'' + | ||
", tokenEndpoint='" + tokenEndpoint + '\'' + | ||
", tokenFilePath='" + tokenFilePath + '\'' + | ||
", apiKey='" + apiKey + '\'' + | ||
", headerName='" + headerName + '\'' + | ||
'}'; | ||
public void setHeaderName(String headerName) { | ||
this.headerName = headerName; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.