protected TenantDetails createUserPoolClient()

in services/shared-services/tenant-registration-service/src/main/java/com/amazonaws/saas/eks/TenantRegistrationService.java [474:531]


	protected TenantDetails createUserPoolClient(TenantDetails tenant) {
		AWSCognitoIdentityProvider cognitoIdentityProvider = AWSCognitoIdentityProviderClientBuilder.defaultClient();

		String url = "https://" + tenant.getTenantId() + "." + tenant.getCustomDomain();
		LoggingManager.logInfo(tenant.getTenantId(), "URL=>" + url);

		CreateUserPoolClientRequest createUserPoolClientRequest = new CreateUserPoolClientRequest();
		createUserPoolClientRequest.setClientName(tenant.getTenantId());
		createUserPoolClientRequest.setUserPoolId(tenant.getUserPoolId());

		createUserPoolClientRequest.setAllowedOAuthFlowsUserPoolClient(true);

		List<String> allowedOAuthFlows = new ArrayList<String>();
		allowedOAuthFlows.add("code");
		allowedOAuthFlows.add("implicit");
		createUserPoolClientRequest.setAllowedOAuthFlows(allowedOAuthFlows);

		List<String> allowedOAuthScopes = new ArrayList<String>();
		allowedOAuthScopes.add("phone");
		allowedOAuthScopes.add("email");
		allowedOAuthScopes.add("openid");
		allowedOAuthScopes.add("profile");
		createUserPoolClientRequest.setAllowedOAuthScopes(allowedOAuthScopes);

		List<String> callbackURLs = new ArrayList<String>();
		callbackURLs.add(url + "/dashboard");
		createUserPoolClientRequest.setCallbackURLs(callbackURLs);

		createUserPoolClientRequest.setDefaultRedirectURI(url + "/dashboard");

		List<String> explicitAuthFlows = new ArrayList<String>();
		explicitAuthFlows.add("ALLOW_ADMIN_USER_PASSWORD_AUTH");
		explicitAuthFlows.add("ALLOW_CUSTOM_AUTH");
		explicitAuthFlows.add("ALLOW_USER_SRP_AUTH");
		explicitAuthFlows.add("ALLOW_REFRESH_TOKEN_AUTH");
		createUserPoolClientRequest.setExplicitAuthFlows(explicitAuthFlows);

		createUserPoolClientRequest.setGenerateSecret(false);

		List<String> logoutURLs = new ArrayList<String>();
		logoutURLs.add(url + "/logoff");
		createUserPoolClientRequest.setLogoutURLs(logoutURLs);

		createUserPoolClientRequest.setPreventUserExistenceErrors("ENABLED");
		createUserPoolClientRequest.setRefreshTokenValidity(30);

		List<String> supportedIdentityProviders = new ArrayList<String>();
		supportedIdentityProviders.add("COGNITO");
		createUserPoolClientRequest.setSupportedIdentityProviders(supportedIdentityProviders);

		CreateUserPoolClientResult result = cognitoIdentityProvider.createUserPoolClient(createUserPoolClientRequest);

		LoggingManager.logInfo(tenant.getTenantId(), "Create User Pool Client Successful.");

		tenant.setClientId(result.getUserPoolClient().getClientId());

		return tenant;
	}