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:
weiminyu 2018-09-10 13:16:44 -07:00 committed by Ben McIlwain
parent 1b3df82fb3
commit 5c1d9bd5c3
5 changed files with 30 additions and 57 deletions

View file

@ -16,12 +16,10 @@ package google.registry.groups;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.services.groupssettings.Groupssettings;
import com.google.api.services.groupssettings.GroupssettingsScopes;
import com.google.common.collect.ImmutableSet;
import dagger.Module;
import dagger.Provides;
import google.registry.config.CredentialModule.DelegatedCredential;
import google.registry.config.RegistryConfig.Config;
import javax.inject.Named;
/** Dagger module for the Google {@link Groupssettings} service. */
@Module
@ -29,12 +27,9 @@ public final class GroupssettingsModule {
@Provides
static Groupssettings provideDirectory(
@Named("delegatedAdmin") GoogleCredential credential,
@Config("projectId") String projectId) {
@DelegatedCredential GoogleCredential credential, @Config("projectId") String projectId) {
return new Groupssettings.Builder(
credential.getTransport(),
credential.getJsonFactory(),
credential.createScoped(ImmutableSet.of(GroupssettingsScopes.APPS_GROUPS_SETTINGS)))
credential.getTransport(), credential.getJsonFactory(), credential)
.setApplicationName(projectId)
.build();
}