From fa187bb76623dbe64b832b8a26e21ab6223e0fda Mon Sep 17 00:00:00 2001 From: lily Date: Thu, 24 Apr 2025 13:07:50 -0400 Subject: [PATCH] feat: configuration comments and getters --- .../oauthfabric/OAuthFabricConfig.java | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/lilyvex/oauthfabric/OAuthFabricConfig.java b/src/main/java/dev/lilyvex/oauthfabric/OAuthFabricConfig.java index 580e90f..c6f4b17 100644 --- a/src/main/java/dev/lilyvex/oauthfabric/OAuthFabricConfig.java +++ b/src/main/java/dev/lilyvex/oauthfabric/OAuthFabricConfig.java @@ -49,12 +49,41 @@ public class OAuthFabricConfig { // Which database to use (SQLite is currently the only supported database). private String database; + public String getProvider() { + return provider; + } + + public String getClientId() { + return client_id; + } + + public String getClientSecret() { + return client_secret; + } + + public String getRedirectUri() { + return redirect_uri; + } + + public String getDatabase() { + return database; + } + public void load() { - this.config.getOrElse("provider", DEFAULT_PROVIDER); - this.config.getOrElse("client_id", DEFAULT_CLIENT_ID); - this.config.getOrElse("client_secret", DEFAULT_CLIENT_SECRET); - this.config.getOrElse("redirect_uri", DEFAULT_REDIRECT_URI); - this.config.getOrElse("database", DEFAULT_DATABASE); + this.config.setComment("provider", "URL to the OAuth provider (e.g. accounts.google.com, discord.com/oauth2)"); + this.config.set("provider", DEFAULT_PROVIDER); + + this.config.setComment("client_id", "ID of the OAuth client. This is usually defined when creating the OAuth application."); + this.config.set("client_id", DEFAULT_CLIENT_ID); + + this.config.setComment("client_secret", ""); + this.config.set("client_secret", DEFAULT_CLIENT_SECRET); + + this.config.setComment("redirect_uri", "URI to redirect to. Ensure that this URI is listed in the allowed redirect URIs section of your OAuth provider."); + this.config.set("redirect_uri", DEFAULT_REDIRECT_URI); + + this.config.setComment("database", "Which database to use (SQLite is currently the only supported database)."); + this.config.set("database", DEFAULT_DATABASE); try { this.loadFromFile(true);