I have a nextjs app that use aws cognito for auth. i was wondering if there is a way to replace the hosted ui provided by aws with my own custom form.
import { Domain } from "@material-ui/icons";
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
export default NextAuth({
providers:[
Providers.Cognito({
clientId:process.env.COGNITO_CLIENT,
clientSecret:process.env.COGNITO_CLIENT_SECRET,
domain: process.env.COGNITO_DOMAIN
})
]
})
I have a nextjs app that use aws cognito for auth. i was wondering if there is a way to replace the hosted ui provided by aws with my own custom form.
import { Domain } from "@material-ui/icons";
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
export default NextAuth({
providers:[
Providers.Cognito({
clientId:process.env.COGNITO_CLIENT,
clientSecret:process.env.COGNITO_CLIENT_SECRET,
domain: process.env.COGNITO_DOMAIN
})
]
})
Share
Improve this question
asked Nov 26, 2021 at 5:51
Nahashon MuriithiNahashon Muriithi
911 silver badge4 bronze badges
3 Answers
Reset to default 9Technically, yes it is possible, but @alexrogo answer is misleading. Amplify, apart from being highly questionable (just look at open tickets on github), doesn't use OpenIDConnect standard. It's doing direct Cognito initiateAuth operation which returns tokens without openid scope. If you try to call e.g. /userinfo endpoint on Cognito, that will fail. Also Amplify keeps tokens in either local storage or cookies depending how you configure it but it's no httponly cookie... That's very troublesome.
But that being said, it is possible to replace HostedUI but beware, as HostedUI is not just a UI! It's a full authorization server. And you have to implement those functionalities yourself if you want to omit its login page. See here for more details: AWS Cognito Authorization code grant flow without using the hosted UI
Yes, this is possible.
You can connect your own UI ponents to Cogntio's APIs. You can store your authentication token in the state or localstorage. Take a look at this Documentation.
There you will find every neccesary function, including Sign Up, Sign In, Log out, Change User Attributes, refreshing tokens.
Just to follow up with @alexrogo Amplify has a whole built in UI connected ponent system, so you don't have to build your custom UI by yourself. This is the getting started guide.
The default flow when you setup a new user pool with Amplify is the USER_SRP_AUTH flow. The Cognito Hosted UI has options for OAuth 2.0 federation and OpenID Connect
With that said, if you prefer, you can setup federated OAuth 2.0 accounts with the Amplify UI, as seen here.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743782844a4506120.html
评论列表(0条)