added config for google auth
This commit is contained in:
6
.env
6
.env
@@ -1,2 +1,6 @@
|
||||
AUTH_SECRET=Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
|
||||
MONGODB_URI=mongodb://root:example@localhost:27017/
|
||||
MONGODB_URI=mongodb://root:example@localhost:27017/
|
||||
|
||||
GOOGLE_ID=355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
|
||||
GOOGLE_SECRET=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
|
||||
NEXT_AUTH_SECRET=Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* infinite scroll
|
||||
* https://stackoverflow.com/questions/67624601/how-to-implement-infinite-scroll-in-next-js
|
||||
* authentication with Google
|
||||
* https://www.telerik.com/blogs/how-to-implement-google-authentication-nextjs-app-using-nextauth* multi-user support
|
||||
* https://www.telerik.com/blogs/how-to-implement-google-authentication-nextjs-app-using-nextauth
|
||||
* multi-user support
|
||||
* bill amount entry
|
||||
* monthly bill amount summery
|
||||
* build & deploy via docker
|
||||
|
||||
17
auth.config.google.ts
Normal file
17
auth.config.google.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import NextAuth, { NextAuthConfig } from 'next-auth';
|
||||
import GoogleProvider from 'next-auth/providers/google';
|
||||
|
||||
export const authConfig:NextAuthConfig = {
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_ID,
|
||||
clientSecret: process.env.GOOGLE_SECRET,
|
||||
}),
|
||||
],
|
||||
session: {
|
||||
// Use JSON Web Tokens for session instead of database sessions.
|
||||
// This option can be used with or without a database for users/accounts.
|
||||
// Note: `jwt` is automatically set to `true` if no database is specified.
|
||||
strategy: 'jwt'
|
||||
},
|
||||
};
|
||||
2
auth.ts
2
auth.ts
@@ -4,7 +4,7 @@
|
||||
* @exports exports `auth`, `signIn`, `signOut` actions
|
||||
*/
|
||||
import NextAuth from 'next-auth';
|
||||
import { authConfig } from './auth.config';
|
||||
import { authConfig } from './auth.config.db';
|
||||
import Credentials from 'next-auth/providers/credentials';
|
||||
import { z } from 'zod';
|
||||
// import bcrypt from 'bcrypt';
|
||||
|
||||
16
client_secret.apps.googleusercontent.com.json
Normal file
16
client_secret.apps.googleusercontent.com.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"web": {
|
||||
"client_id": "355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com",
|
||||
"project_id": "evidencija-rezija",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_secret": "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",
|
||||
"redirect_uris": [
|
||||
"http://localhost:3000/api/auth/callback/google"
|
||||
],
|
||||
"javascript_origins": [
|
||||
"http://localhost:3000"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import NextAuth from 'next-auth';
|
||||
import { authConfig } from './auth.config';
|
||||
import { authConfig } from './auth.config.db';
|
||||
|
||||
export default NextAuth(authConfig).auth;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user