Cognito multi-tenant user pools - amazon-cognito

My Angular application needs to support multiple tenants as well as social logins like Facebook and Google. We are using AWS Cognito with Amplify. When setting up Cognito's app client, we can enter multiple sign-in and sign-out URLs used in the authentication flow between my app and federated providers like Facebook and Google.
I'm anticipating each tenant will have a unique URL - something like https://tenantA.my-app.com and https://tenantB.my-app.com.
How do you configure Cognito's sign-in and sign-out URLs to support multi-tenants, each with a different URL? Surely there's a better way then to keep sign-in and sign-out URLs configuration up-to-date with all valid tenant URLs?
With Angular, I can configure amplify with dynamic values for oauth.redirectSignIn and oauth.redirectSignOut. I'm unsure how to make Cognito's user pool reflect dynamic URLs representing each tenant.
Is it possible to have a 'clearing-house' url which Facebook and Google return to after authentication then this 'clearing-house' destination would redirect authenticated user to the correct tenant? I'm grasping at straws.
Thank you for your time.

Related

Auth0 - OAuth login with dynamic callback

I want to secure my Web-App with Auth0 in React. This means a user can login on my page and use the resulting Access Token to make requests to services behind AWS API Gateway.
But Auth0 requires that all possible Callback URLs are defined in the Dashboard.
This works well as long as the Application is hosted on a domain owned by me.
In my case the React App will be distributed as a Plugin (Shopify, Woocommerce). My users will install this Plugin and use my App through their shopsystem-UI. Which means that requests from the browser are made from their domain.
How should I securely access my Services through this client which is distributed on Domains which i don't know beforehead?
As my research shows, one solution would be Dynamic Application Registration. But with this I would end up with one Auth0 Application per user and Auth0 Limits that to 100 Applications.
How should I handle my case instead?

Amazon Cognito SSO - how to logout from all apps once logged out one of them

I'm using Amazon Cognito Google sign-in in order to have a common login across multiple subdomains. Login works as expected I'm getting tokens after login. But I'm not sure how to logout the user from all portals once it is signed out from one of them. I can check https://domain.auth.<regin>.amazoncognito.com/oauth2/userInfo endpoint for each request, but I think it will affect performance significantly. Is there any other way to achieve this?
I would appreciate any other SSO solution that good fit my case.
I figured out the answer by myself. The idea behind SSO it that access token should be verified on each request by SSO server - Cognito in my case.
I decided to create my own service for authentication which will share a cookie with JWT token between subdomains. Any of the services will be redirected to the auth service and sign in there once couldn't find the dedicated cookie

AWS Cognito use custom auth flow with external identity provider

is it possible to use AWS Cognito that has a custom authentication flow enabled, while also using an external identity provider like Facebook or Google? I've tried this with Facebook and the Cognito Hosted UI, but my DefineAuthChallenge-trigger was not hit.
I contacted AWS Support and they pointed me to the Cognito documentation here where a note says that
The Amazon Cognito hosted sign-in web page does not support the custom authentication flow.
As an alternative, this solution was proposed:
Alternatively, if you would like to use custom authentication flow with an external identity provider, you will have to write your own custom login flow using one of Cognito's SDKs and use Facebook as a way of login.
My idea is that you can probably do this by defining a custom challenge, that asks, which identity provider you want to use, as the first, initial challenge. If Cognito is chosen, the user needs to provide their SRP-stuff or username and password, if that is enabled. If Facebook is chosen for example, you would probably need to send an auth challenge to the client saying that you want a token or code from them, which can only be gotten, if the client shows the website with the Facebook login. The challenge response to the server would then be the gotten auth token from Facebook or code or some other answer that the server can then use to authenticate the user within Cognito, where the Facebook app is connected and is registered as an external identity provider
This is my idea of how I would go about to do this, but I haven't actually implemented this. I hope this helps someone trying to do this though.

AWS Cognito Mobile Hub

I need to login users via Instagram for my mobile application so I can make calls to Instagram API and get some information from the Instagram. Simply, my application will ask user to authorize Instagram access and able to get access token for API calls. Application should not ask user to login again once the user is authorized. I already setup my Instagram client-app to implement server-side authentication flow.
My challenge is I want to do this on by using AWS mobile services. I already setup custom authentication from MobileHub and came to point where I need to define my custom authentication flow (in this case it is Instagram authentication flow). Under AWS Cognito app when I go to Triggers tab, I see different options for defining lambda functions associated with my authentication (such as pre/post auth or define / create / verify auth challenge). I am not sure how to align Instagram Authentication flow with these functions. Or should I use something else. Also I am not clear how does AWS Cognito manages authentication flow: I don't want my users to go through authorization process every time they start my application. I believe AWS Cognito link users from my custom flow to some Cognito identity and able to authenticate when they use my application. I really appreciate any suggestions, or even code sample (if available).
Check this Document for Cognito Identity. Instagram is not there by default. So you have to use External Identity Provider, most probably using Open ID Connect Providers.

Firebase access token using getAuth()

I am wondering if firebase function getAuth() somehow checks if the the website link to which the token was initially issued is the one that is requesting for the authorization status.
I am concerned that if a malicious website somehow had access to my Firebase.io link, and runs a simple getAuth() in the same browser as my Firebase based backend website, it will be able to access the Firebase token issued to the user of my website.
Any thoughts on it would be greatly appreciated.
Note: I work at Firebase
Firebase Authentication sessions are stored using LocalStorage accessible only to your domain. This means that the sessions are not accessible from domains outside of your control.
If you're using OAuth (Google, Facebook, Twitter, or GitHub login), then authentication is further restricted to your domain via our OAuth configuration in your Firebase dashboard, where you must explicitly authorize domains for access.
Users of email / password authentication can authenticate from any source, provided that the user has access to the password. In short, we ensure that the sessions stored for your domain are not accessible elsewhere. Our top priorities for this product are data security and making that security available to you (as the developer) easily and as the default.
If you have additional concerns that are sensitive for any reason, don't hesitate to reach out to me rob at firebase.com.