Added secrets and secretized secure config options
This commit is contained in:
parent
70db5a8428
commit
27fa78e2a8
@ -23,6 +23,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation 'org.xerial:sqlite-jdbc:3.36.0.2'
|
||||
implementation 'org.postgresql:postgresql:42.2.24'
|
||||
implementation 'com.github.Kaaz:ConfigurationBuilder:0.4'
|
||||
implementation 'org.javacord:javacord:3.3.2'
|
||||
implementation 'com.vdurmont:emoji-java:5.1.1'
|
||||
@ -32,8 +33,13 @@ dependencies {
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.5.4'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.4'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4'
|
||||
|
||||
implementation platform('com.google.cloud:libraries-bom:23.0.0')
|
||||
implementation 'com.google.cloud:google-cloud-secretmanager'
|
||||
|
||||
|
||||
testImplementation group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
||||
|
||||
|
@ -15,16 +15,13 @@ import java.nio.file.Paths;
|
||||
|
||||
public class BotConfig {
|
||||
@ConfigurationOption
|
||||
public static String TOKEN = "token-goes-here";
|
||||
public static String DB_ADDR = "SQLite connection address here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String DB_ADDR = "fsbot.db";
|
||||
public static String DB_NAME = "SQLite database name here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String DB_NAME = "fsbot";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String DEFAULT_PREFIX = "~";
|
||||
public static String DEFAULT_PREFIX = "default prefix here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String BOT_OWNER = "owner's id here";
|
||||
@ -68,12 +65,6 @@ public class BotConfig {
|
||||
@ConfigurationOption
|
||||
public static String MEMBER_ROLE = "member role id here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String IMGUR_ID = "imgur_id_here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String IMGUR_BEARER = "imgur bearer here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String DEFAULT_REACTION = ":heartpulse:";
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package dev.salmonllama.fsbot.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
|
||||
|
||||
public enum SecretManager {
|
||||
DISCORD_TOKEN ("projects/fashionscapers-212707/secrets/fs_discord_token/versions/1"),
|
||||
IMGUR_ID ("projects/fashionscapers-212707/secrets/fs_imgur_client_id/versions/1"),
|
||||
IMGUR_BEARER ("projects/fashionscapers-212707/secrets/fs_imgur_bearer_token/versions/1")
|
||||
;
|
||||
|
||||
private final String resourceId;
|
||||
|
||||
private SecretManager(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public String getPlainText() {
|
||||
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
|
||||
return client.accessSecretVersion(this.resourceId).getPayload().getData().toStringUtf8();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1); // Secrets are integral to full operation, crash if not retrieved properly.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user