Skip to content

Commit

Permalink
Allow setting of WDK secret key directly (rather than from interpreti…
Browse files Browse the repository at this point in the history
…ng a file)
  • Loading branch information
ryanrdoherty committed Aug 12, 2024
1 parent 33c15fa commit 5492811
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Model/lib/rng/wdkModel-config.rng
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<optional>
<attribute name="secretKeyFile" />
</optional>
<optional>
<attribute name="secretKey" />
</optional>
<optional>
<attribute name="adminEmail" />
</optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public String getName() {
private final Path _wdkTempDir;

public ModelConfig(String modelName, String projectId, Path gusHome, boolean caching, boolean useWeights,
String paramRegex, Optional<Path> secretKeyFile, Path wdkTempDir, String webServiceUrl, String assetsUrl,
String paramRegex, Optional<Path> secretKeyFile, String secretKey, Path wdkTempDir, String webServiceUrl, String assetsUrl,
String smtpServer, String supportEmail, List<String> adminEmails, String emailSubject,
String emailContent, ModelConfigUserDB userDB, ModelConfigAppDB appDB,
ModelConfigUserDatasetStore userDatasetStoreConfig, QueryMonitor queryMonitor,
Expand All @@ -163,6 +163,7 @@ public ModelConfig(String modelName, String projectId, Path gusHome, boolean cac
// file locations
_wdkTempDir = wdkTempDir;
_secretKeyFile = secretKeyFile;
_secretKey = secretKey;

// network locations
_webServiceUrl = webServiceUrl;
Expand Down Expand Up @@ -295,6 +296,8 @@ public ModelConfigAppDB getAppDB() {
* configured secret key file. If the configured filename is null or the contents
* of the file cannot be read for any reason, null is returned.
*
* Note: as of 8/12/24, you can alternatively directly set the secretKey in model-config.xml
*
* @return secret key
*/
public String getSecretKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ModelConfigBuilder {

// file locations
private String _secretKeyFile;
private String _secretKey;
private String _wdkTempDir = "/tmp";

// network locations
Expand Down Expand Up @@ -107,6 +108,7 @@ public ModelConfig build() throws WdkModelException {

// file locations
secretKeyFile,
_secretKey,
wdkTempDir,

// network locations
Expand Down Expand Up @@ -253,6 +255,14 @@ public void setSecretKeyFile(String secretKeyFile) {
_secretKeyFile = secretKeyFile;
}

/**
* @param secretKeyFile
* the secretKeyFile to set
*/
public void setSecretKey(String secretKey) {
_secretKey = secretKey;
}

/**
* @param authenticationMethod configured authentication method
*/
Expand Down

0 comments on commit 5492811

Please sign in to comment.