mirror of
https://github.com/google/nomulus
synced 2026-08-27 19:37:07 +00:00
Refactor DelegatedCredential provisioning for GSuite domains
Updated the registar contact group management, which is the only use case for this credential. Also updated GSuite domain delegated admin access config in admin dashboard for both sandbox (used by alpha and sandbox) and prod. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=212320157
This commit is contained in:
@@ -79,6 +79,29 @@ public abstract class CredentialModule {
|
||||
return credential;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a {@link GoogleCredential} with delegated admin access for a G Suite domain.
|
||||
*
|
||||
* <p>The G Suite domain must grant delegated admin access to the registry service account with
|
||||
* all scopes in {@code requiredScopes}, including ones not related to G Suite.
|
||||
*/
|
||||
@DelegatedCredential
|
||||
@Provides
|
||||
@Singleton
|
||||
public static GoogleCredential provideDelegatedCredential(
|
||||
@Config("credentialOauthScopes") ImmutableList<String> requiredScopes,
|
||||
@JsonCredential GoogleCredential googleCredential,
|
||||
@Config("gSuiteAdminAccountEmailAddress") String gSuiteAdminAccountEmailAddress) {
|
||||
return new GoogleCredential.Builder()
|
||||
.setTransport(Utils.getDefaultTransport())
|
||||
.setJsonFactory(Utils.getDefaultJsonFactory())
|
||||
.setServiceAccountId(googleCredential.getServiceAccountId())
|
||||
.setServiceAccountPrivateKey(googleCredential.getServiceAccountPrivateKey())
|
||||
.setServiceAccountScopes(requiredScopes)
|
||||
.setServiceAccountUser(gSuiteAdminAccountEmailAddress)
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Dagger qualifier for the Application Default Credential. */
|
||||
@Qualifier
|
||||
public @interface DefaultCredential {}
|
||||
|
||||
@@ -185,10 +185,7 @@ credentialOAuth:
|
||||
- https://www.googleapis.com/auth/drive
|
||||
# View and manage groups on your domain in Directory API.
|
||||
- https://www.googleapis.com/auth/admin.directory.group
|
||||
# Inherited from current code.
|
||||
# TODO(weiminyu): verify if the scope above is sufficient by itself.
|
||||
- https://www.googleapis.com/auth/admin.directory.group.member
|
||||
# View and manage the settings of a Google Apps Group.
|
||||
# View and manage group settings in Group Settings API.
|
||||
- https://www.googleapis.com/auth/apps.groups.settings
|
||||
|
||||
icannReporting:
|
||||
|
||||
Reference in New Issue
Block a user