SteemPro x NextAuth

in Steem Dev6 months ago

Hello devs,

Setting the high-security login method was a tough task in SteemPro. Today I completed the authentication logic. The hurdle was to get the login username during the server-side rendering. I did some research and decided to implement the Next Auth with a custom credentials login.

image.png

Only the sign-in option is required. So I add to login to Next Auth only with the username. Encrypted Private was not added to the auth as it's sensitive information even if it is encrypted. So I decided to keep the encrypted private key to local storage and use the Next auth login session to get the username on the server-side rendering.

Server-side rendering is used in NextJs to set the metadata and also to improve the overall performance of the app. Today I also covered the error boundary and loading states.

here is the simple implementation of the Next Auth.

import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials"
const handler = NextAuth({
session: {
strategy: 'jwt',
},
providers: [
CredentialsProvider({
name: 'SteemPro Authenticator',
credentials: {
username: {},
},
async authorize(credentials, req) {
if (credentials) {
return {
id: credentials.username,
name: credentials.username,
};
}
return null
}
})
],
});
export { handler as GET, handler as POST };


Cc: @blacks
Cc: @rme
Cc: @hungry-griffin
Cc: @steemchiller
Cc: @steemcurator01
Cc: @pennsif
Cc: @future.witness
Cc: @stephenkendal
Cc: @justyy
Cc: @upvu
Cc: @h4lab


VOTE @faisalamin as witness

🇸‌🇹‌🇪‌🇪‌🇲‌🇵‌🇷‌🇴‌


Sort:  

Upvoted! Thank you for supporting witness @jswit.

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64689.90
ETH 3450.92
USDT 1.00
SBD 2.50