Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Let users enable FIPS mode instead of default AWS endpoints for API calls #583

Closed
juliedavila opened this issue Apr 3, 2018 · 16 comments
Labels
Auth Related to Auth components/category feature-request Request a new feature

Comments

@juliedavila
Copy link

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Skimming through the code and looking through the docs, there doesn't seem to be a way to overwrite the endpoint used by amplify for a given thing. For example, I need to use endpoints with FIPS validated TLS which can be found here https://aws.amazon.com/compliance/fips/. But there is no clean way for me to leverage this.

What is the expected behavior?

My desire would be for the Config settings to allow custom endpoint options or a toggle to use fips. For example, with cognito it would be

cognito-sync-fips.us-east-1.amazonaws.com

cognito-identity-fips.us-east-1.amazonaws.com

cognito-idp-fips.us-east-1.amazonaws.com

<your_user_pool_domain>.auth-fips.us-east-1.amazoncognito.com

A possible interface could be something like

Amplify.configure({
  Auth: {
    identityPoolId: 'us-east-1:42xxxxbc2b',
    fips_enabled: true,
    region: 'us-east-1',
    userPoolId: 'us-east-1_xxhLcN',
    userPoolWebClientId: 'p1moxxxx3i9xxxxvh',
    mandatorySignIn: false,
    cookieStorage: {
      domain: document.domain,
      path: '/',
      expires: 30,
      secure: true
    }
  }

i'm happy to help contribute this, but would want to get a green-light on design. I think the path of least resistance would be to implement a fips toggle rather than to allow any custom endpoint.

@mlabieniec mlabieniec added feature-request Request a new feature Auth Related to Auth components/category labels Apr 3, 2018
@yuntuowang
Copy link
Contributor

Hi @defionscode, we already have service endpoints with FIPS deployed to all regions. Exactly as you mentioned, you can try:
cognito-sync-fips.us-east-1.amazonaws.com

cognito-identity-fips.us-east-1.amazonaws.com

cognito-idp-fips.us-east-1.amazonaws.com

<your_user_pool_domain>.auth-fips.us-east-1.amazoncognito.com

@juliedavila
Copy link
Author

well yes, but how do you ensure that aws-amplify leverages those endpoints

@yuntuowang
Copy link
Contributor

@mlabieniec, does aws-amplify Auth leverage these endpoints?

@juliedavila
Copy link
Author

To clarify my request, while my desire is for Auth, this enhancement should ideally be implemented for the other things like Storage, etc. Any amplify thing that also has FIPS endpoints available under the hood.

@yuntuowang it is not currently implemented since amplify just uses the implicit default endpoint for aws APIs. For example, take a look here:
https://github.com/aws/aws-amplify/blob/393ca50/packages/aws-amplify/src/Auth/Auth.ts#L81-L120

Notice how it calls theCognitoUserPool constructor. It creates the object by passing in userPoolData which is defined as

            const userPoolData: ICognitoUserPoolData = {
                UserPoolId: userPoolId,
                ClientId: userPoolWebClientId,
            };
            if (cookieStorage) {
                userPoolData.Storage = new CookieStorage(cookieStorage);
}

Now take a look at the actual definition of that constructor here https://github.com/aws/aws-amplify/blob/297c0b5c286d095d895a9a14191cfe7b2fee44c8/packages/amazon-cognito-identity-js/es/CognitoUserPool.js#L38-L58

Notice how endpoint is an attribute that is configurable, however, amplify's api currently doesn't facilitate modifying how userPoolData is created so using FIPS endpoints is not currently possible.

I hope this helps. Like I said, I'm happy to contribute this feature. The two design paths can be to make simple boolean flag in config which would automatically setup fips endpoints OR a bit more complex would be to allow for fully customizable endpoints for all underlying api calls might make for some ugly mapping for users that wish to leverage it.

I suppose both things could be implemented independent of each other too.

@juliedavila
Copy link
Author

oh and to be clear, no aws does not implicitly use endpoints with fips validated encryption

@mlabieniec
Copy link
Contributor

mlabieniec commented Apr 3, 2018

@defionscode I think what you are proposing makes sense, i.e. make a simple boolean flag in config which would automatically setup fips endpoints. I think it would be good to add this to the url generation within the section you outlined there that generates the URL. It looks like we can similarly use the region generated and the prefixes. Feel free to submit the pr for review and thank you.

@juliedavila
Copy link
Author

juliedavila commented Apr 3, 2018 via email

@mlabieniec
Copy link
Contributor

mlabieniec commented Apr 3, 2018

I think that's the simplest way to start here and support the feature without needing to do to much refactoring on the existing functionality. Only thing I'd note is that the config values are generally camelCased so instead of fips_enabled perhaps just fipsEnabled or fipsEndpointsEnabled

@juliedavila
Copy link
Author

juliedavila commented Apr 3, 2018 via email

@juliedavila
Copy link
Author

Just an update. This is still on our roadmap to tackle but it's taken a backseat for the time being. I still plan to have this contributed.

@stale
Copy link

stale bot commented Jun 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@sammartinez
Copy link
Contributor

@defionscode I am going to close this FR since the last update from yourself was April of 2018. We are still open to a PR! Please feel free to reopen once a PR is created for this or you are still looking for this use case. Thanks ahead of time

@juliedavila
Copy link
Author

I'm still looking for this use case. :)

@slashinski
Copy link
Contributor

slashinski commented Jan 29, 2020

Updating here for the changes I would like to contribute, following the suggested approach above, to have a fips flag set so that the cognito-idp-fips endpoint is called. Use case is that through a security check, the man-in-the-middle attack could possibly downgrade the call to cognito-idp endpoint as cognito still allows version TLS 1.0 protocol.

Suggested changes would be as follows:

  • packages/amazon-cognito-identity-js/index.d.ts: add fipsEnabled boolean
    export interface ICognitoUserPoolData { UserPoolId: string; ClientId: string; endpoint?: string; fipsEnabled?: boolean; Storage?: ICognitoStorage; }

  • packages/amazon-cognito-identity-js/src/Client.js: client accept fipsEnabled value
    constructor(region, endpoint, fipsEnabled) { if (fipsEnabled) { this.endpoint = https://cognito-idp-fips.${region}.amazonaws.com/`;
    } else {
    this.endpoint =
    endpoint || https://cognito-idp.${region}.amazonaws.com/;
    }`

  • packages/amazon-cognito-identity-js/src/CognitoUserPool.js: constructor has fipsEnabled variable and passes fipsEnabled value to client
    const { UserPoolId, ClientId, endpoint, fipEnabled, AdvancedSecurityDataCollectionFlag, } = data || {};
    .......
    this.client = new Client(region, endpoint, fipEnabled);

  • packages/auth/src/Auth.ts: auth interface for cognito user pool sets config value for fipsEnabled
    const userPoolData: ICognitoUserPoolData = { UserPoolId: userPoolId, ClientId: userPoolWebClientId, fipsEnabled: this._config.fipsEnabled, };

  • packages/auth/src/types/Auth.ts: auth types authOptions has fipsEnabled variable
    export interface AuthOptions { authenticationFlowType?: string; identityPoolRegion?: string; clientMetadata?: any; fipsEnabled?: boolean; }

I have tested the above changes locally and was able to see that by setting the fipsEnabled to true via the config options in a project, that the FIPS endpoint was called.
A couple of questions:

  1. Does more need to be done to be able to set the cognito-idp endpoint to FIPS?
  2. If a call is made to the cognito-idp-fips endpoint, is there somewhere that a modification needs to happen to make sure the cognito-identity endpoint is also being made to reflect the FIPS endpoint (cognito-identity-fips)?

@zoonman
Copy link

zoonman commented Sep 15, 2020

@sammartinez Is there any update planned to properly integrate GovCloud support across the platform?

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

6 participants