3

We are using Cognito Hosted UI with Local Account login and few SAML providers. There is an option to customize some styling but I am looking for couple of additional things.

  1. Adding a custom text and link to an external site - like terms and conditions
  2. SAML provider name do not take a space. I cannot show something like "Login with X".

Is there a way to customize the Hosted UI to do these things? Thanks.

user1868744
  • 963
  • 1
  • 13
  • 27
  • 1
    Currently, the Cognito Hosted UI only supports [style customizations](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-app-ui-customization.html) such as CSS and image banner. There is no option to add/remove text from the Hosted UI. If you need greater flexibility with the sign-in screen, you would need to build your own hosted UI or use something like [Amplify](https://docs.amplify.aws/lib/auth/customui/q/platform/js). – Decaf-Math Jun 04 '20 at 22:40
  • 2
    https://www.customizecognito.com/ can be used to help prototype some styling of the form – Meeses Oct 28 '20 at 00:14
  • @Decaf-Math we are having the same problem, want to continue with the AWS cognito services and want to use our own UI instead of AWS UI, Is there a way to implement the same? – chetan mekha Jul 29 '22 at 10:36
  • @chetanmekha the answer is the same as it was in my comment from 2020. The AWS Amplify SDK directly integrates with Cognito, so the recommended answer would be to use Amplify. You can use the [Authenticator component](https://ui.docs.amplify.aws/react/connected-components/authenticator) since it's extensible and easily customizable, or call the underlying methods like [`Auth.signIn(...)`](https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js/#sign-in) directly from your application code. – Decaf-Math Jul 30 '22 at 12:10

1 Answers1

0

You would be better off not using Cognito provided UI, and only use Cognito for authentication and authorization.

My react web application interact with Cognito, without using any of its provided UI components. Only through this way, you are able to have absolute control of your frontend.

You can refer below sample code, and use it for your web application.

Sample code

The sample code shows you how to signin by calling Cognito with using amazon-cognito-identity-js. Or some other reference: Implementing AWS-Cognito in Angular 2 and Using AWS Cognito in a Lambda function with npm


import {
  CognitoUserPool,
  CognitoUser,
  CognitoUserSession,
  CognitoUserAttribute,
  AuthenticationDetails,
} from "amazon-cognito-identity-js";


export function signIn(email: string, password: string) {
  var authenticationData = {
    Username: email,
    Password: password,
  };
  const cognitoUser = new CognitoUser({
    Username: email,
    Pool: getPool(
      process.env.REACT_APP_BUSINESS_ACCOUNT_USER_POOL_ID!,
      process.env.REACT_APP_BUSINESS_ACCOUNT_USER_POOL_CLIENT_ID!
    ),
  });
  var authenticationDetails = new AuthenticationDetails(authenticationData);
  return new Promise((resolve, reject) => {
    cognitoUser.authenticateUser(authenticationDetails, {
      onSuccess: (result) => resolve(result),
      onFailure: (error) => reject(error),
      newPasswordRequired: (userAttributes, requiredAttributes) => {
        resolve({ needResetPassword: true, cognitoUser, userAttributes });
      },
    });
  });
}


Yang Liu
  • 541
  • 9
  • 26