Package google.registry.config
Class CredentialModule
java.lang.Object
google.registry.config.CredentialModule
Dagger module that provides all
GoogleCredentials
used in the application.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
Dagger qualifier for a credential with delegated admin access for a dasher domain (for Google Workspace) backed by the application default credential (ADC).static @interface
Dagger qualifier for the scope-less Application Default Credential.static @interface
Dagger qualifier for a credential with delegated Email-sending permission for a dasher domain (for Google Workspace) backed by the application default credential (ADC).static @interface
Dagger qualifier for the credential for Google Workspace APIs.static @interface
Dagger qualifier for the local credential used in the nomulus tool.static @interface
Dagger qualifier for the JSON string used to create the local credential. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic GoogleCredentialsBundle
createSelfSignedDelegatedCredential
(com.google.common.collect.ImmutableList<String> defaultScopes, com.google.common.collect.ImmutableList<String> delegationScopes, GoogleCredentialsBundle credentialsBundle, String gSuiteUserEmailAddress, Duration tokenRefreshDelay, Clock clock) static GoogleCredentialsBundle
Provides aGoogleCredentialsBundle
backed by the application default credential from the Google Cloud Runtime.static GoogleCredentialsBundle
provideGSuiteDriveCredential
(GoogleCredentialsBundle applicationDefaultCredential, com.google.common.collect.ImmutableList<String> requiredScopes) Provides aGoogleCredentialsBundle
for accessing Google Workspace APIs, such as Drive and Sheets.static GoogleCredentialsBundle
provideSelfSignedAdminDelegatedCredential
(com.google.common.collect.ImmutableList<String> defaultScopes, com.google.common.collect.ImmutableList<String> delegationScopes, GoogleCredentialsBundle credentialsBundle, String gSuiteAdminAccountEmailAddress, Duration tokenRefreshDelay, Clock clock) Provides aGoogleCredentialsBundle
with delegated access to Google Workspace APIs for the application default credential user.static GoogleCredentialsBundle
provideSelfSignedGmailDelegatedCredential
(com.google.common.collect.ImmutableList<String> defaultScopes, com.google.common.collect.ImmutableList<String> delegationScopes, GoogleCredentialsBundle credentialsBundle, String gSuiteOutgoingEmailAddress, Duration tokenRefreshDelay, Clock clock) Provides aGoogleCredentialsBundle
for sending emails through Google Workspace.
-
Constructor Details
-
CredentialModule
public CredentialModule()
-
-
Method Details
-
provideApplicationDefaultCredential
@ApplicationDefaultCredential @Provides @Singleton public static GoogleCredentialsBundle provideApplicationDefaultCredential()Provides aGoogleCredentialsBundle
backed by the application default credential from the Google Cloud Runtime. This credential may be used to access GCP APIs that are NOT part of the Google Workspace.The credential returned by the Cloud Runtime depends on the runtime environment:
- On App Engine, returns a scope-less
ComputeEngineCredentials
for PROJECT_ID@appspot.gserviceaccount.com - On Compute Engine, returns a scope-less
ComputeEngineCredentials
for PROJECT_NUMBER-compute@developer.gserviceaccount.com - On end user host, this returns the credential downloaded by gcloud. Please refer to Cloud SDK documentation for details.
- On App Engine, returns a scope-less
-
provideGSuiteDriveCredential
@GoogleWorkspaceCredential @Provides @Singleton public static GoogleCredentialsBundle provideGSuiteDriveCredential(@ApplicationDefaultCredential GoogleCredentialsBundle applicationDefaultCredential, @Config("defaultCredentialOauthScopes") com.google.common.collect.ImmutableList<String> requiredScopes) Provides aGoogleCredentialsBundle
for accessing Google Workspace APIs, such as Drive and Sheets. -
provideSelfSignedAdminDelegatedCredential
@AdcDelegatedCredential @Provides @Singleton public static GoogleCredentialsBundle provideSelfSignedAdminDelegatedCredential(@Config("defaultCredentialOauthScopes") com.google.common.collect.ImmutableList<String> defaultScopes, @Config("delegatedCredentialOauthScopes") com.google.common.collect.ImmutableList<String> delegationScopes, @ApplicationDefaultCredential GoogleCredentialsBundle credentialsBundle, @Config("gSuiteAdminAccountEmailAddress") String gSuiteAdminAccountEmailAddress, @Config("tokenRefreshDelay") Duration tokenRefreshDelay, Clock clock) Provides aGoogleCredentialsBundle
with delegated access to Google Workspace APIs for the application default credential user.The Workspace domain must grant delegated admin access to the default service account user (project-id@appspot.gserviceaccount.com on AppEngine) with all scopes in
defaultScopes
anddelegationScopes
. -
provideSelfSignedGmailDelegatedCredential
@GmailDelegatedCredential @Provides @Singleton public static GoogleCredentialsBundle provideSelfSignedGmailDelegatedCredential(@Config("defaultCredentialOauthScopes") com.google.common.collect.ImmutableList<String> defaultScopes, @Config("delegatedCredentialOauthScopes") com.google.common.collect.ImmutableList<String> delegationScopes, @ApplicationDefaultCredential GoogleCredentialsBundle credentialsBundle, @Config("gSuiteNewOutgoingEmailAddress") String gSuiteOutgoingEmailAddress, @Config("tokenRefreshDelay") Duration tokenRefreshDelay, Clock clock) Provides aGoogleCredentialsBundle
for sending emails through Google Workspace.The Workspace domain must grant delegated admin access to the default service account user (project-id@appspot.gserviceaccount.com on AppEngine) with all scopes in
defaultScopes
anddelegationScopes
. In addition, the usergSuiteOutgoingEmailAddress
must have the permission to send emails. -
createSelfSignedDelegatedCredential
public static GoogleCredentialsBundle createSelfSignedDelegatedCredential(com.google.common.collect.ImmutableList<String> defaultScopes, com.google.common.collect.ImmutableList<String> delegationScopes, GoogleCredentialsBundle credentialsBundle, String gSuiteUserEmailAddress, Duration tokenRefreshDelay, Clock clock)
-