Configure client id and client secret in the config file

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224158599
This commit is contained in:
jianglai 2018-12-05 08:30:23 -08:00
parent 6352b8a01a
commit 5f9aad90fc
10 changed files with 41 additions and 82 deletions

View file

@ -1258,15 +1258,18 @@ public final class RegistryConfig {
return "/tos";
}
/**
* Returns the name of the OAuth2 client secrets file.
*
* <p>This is the name of a resource relative to the root of the class tree.
*/
/** OAuth client ID used by the nomulus tool. */
@Provides
@Config("clientSecretFilename")
public static String provideClientSecretFilename(RegistryConfigSettings config) {
return config.registryTool.clientSecretFilename;
@Config("toolsClientId")
public static String provideToolsClientId(RegistryConfigSettings config) {
return config.registryTool.clientId;
}
/** OAuth client secret used by the nomulus tool. */
@Provides
@Config("toolsClientSecret")
public static String provideToolsClientSecret(RegistryConfigSettings config) {
return config.registryTool.clientSecret;
}
@Provides
@ -1551,12 +1554,6 @@ public final class RegistryConfig {
return Duration.standardDays(CONFIG_SETTINGS.get().registryPolicy.contactAutomaticTransferDays);
}
/** Provided for testing. */
@VisibleForTesting
public static String getClientSecretFilename() {
return CONFIG_SETTINGS.get().registryTool.clientSecretFilename;
}
/**
* Memoizes loading of the {@link RegistryConfigSettings} POJO.
*

View file

@ -182,6 +182,7 @@ public class RegistryConfigSettings {
/** Configuration options for the registry tool. */
public static class RegistryTool {
public String clientSecretFilename;
public String clientId;
public String clientSecret;
}
}

View file

@ -257,8 +257,8 @@ oAuth:
- https://www.googleapis.com/auth/userinfo.email
# OAuth client IDs that are allowed to authenticate and communicate with
# backend services, e. g. nomulus tool, EPP proxy, etc. All client_id values
# used in client_secret.json files for associated tooling should be included
# backend services, e. g. nomulus tool, EPP proxy, etc. The client_id value
# used in registryTool.clientId field for associated tooling should be included
# in this list. Client IDs are typically of the format
# numbers-alphanumerics.apps.googleusercontent.com
allowedOauthClientIds: []
@ -388,5 +388,7 @@ keyring:
# Configuration options relevant to the "nomulus" registry tool.
registryTool:
# Name of the client secret file used for authenticating with App Engine.
clientSecretFilename: /google/registry/tools/resources/client_secret.json
# OAuth client Id used by the tool.
clientId: YOUR_CLIENT_ID
# OAuth client secret used by the tool.
clientSecret: YOUR_CLIENT_SECRET