next-auth
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -115,2 +115,10 @@ /** | ||
}, | ||
remove: (id) => { | ||
return new Promise((resolve, reject) => { | ||
usersCollection.remove({_id: id}, (err) => { | ||
if (err) return reject(err) | ||
return resolve(true) | ||
}) | ||
}) | ||
}, | ||
// Seralize turns the value of the ID key from a User object | ||
@@ -117,0 +125,0 @@ serialize: (user) => { |
{ | ||
"name": "next-auth-examples", | ||
"version": "1.0.0", | ||
"description": "", | ||
"description": "An example of how to use next-auth", | ||
"repository": "https://github.com/iaincollins/next-auth.git", | ||
"main": "", | ||
@@ -9,3 +10,3 @@ "scripts": { | ||
"build": "next build", | ||
"start": "NODE_ENV=production node index.js" | ||
"start": "node index.js" | ||
}, | ||
@@ -20,3 +21,3 @@ "author": "", | ||
"next": "^4.2.3", | ||
"next-auth": "^1.1.0", | ||
"next-auth": "^1.1.1", | ||
"next-auth-client": "^1.1.1", | ||
@@ -31,3 +32,7 @@ "nodemailer": "^4.4.2", | ||
"universal-cookie": "^2.1.2" | ||
}, | ||
"now": { | ||
"name": "next-auth-demo", | ||
"alias": "next-auth-demo.now.sh" | ||
} | ||
} |
{ | ||
"name": "next-auth", | ||
"version": "1.1.1", | ||
"description": "Add oAuth and/or email authentication to Next.js sites", | ||
"version": "1.1.2", | ||
"description": "An authentication library for Next.js projects", | ||
"repository": "https://github.com/iaincollins/next-auth.git", | ||
"main": "index.js", | ||
@@ -6,0 +7,0 @@ "scripts": {}, |
113
README.md
@@ -1,7 +0,112 @@ | ||
# Next Auth | ||
# NextAuth | ||
This package is a placeholder for a in development authenication module intended for use in Next.js apps. | ||
NextAuth is an authenticaton library for Next.js projects. | ||
Documentation and examples will be published soon, once the API has stabilised. | ||
It contains an [example site](https://github.com/iaincollins/next-auth/tree/master/example) that shows how to use it in a simple project. | ||
-- January, 2018. | ||
It's also used in the [nextjs-starter.now.sh](https://nextjs-starter.now.sh) project, which provides a more complete example. | ||
## Example usage | ||
If you have an existing Next.js site, create an `index.js` file in the root of your project containing the following: | ||
````javascript | ||
// Include Next.js, Next Auth and a Next Auth config | ||
const next = require('next') | ||
const nextAuth = require('next-auth') | ||
const nextAuthConfig = require('./next-auth.config') | ||
// Load environment variables from .env | ||
require('dotenv').load() | ||
// Initialize Next.js | ||
const nextApp = next({ | ||
dir: '.', | ||
dev: (process.env.NODE_ENV === 'development') | ||
}) | ||
// Add next-auth to next app | ||
nextApp | ||
.prepare() | ||
.then(() => { | ||
// Load configuration and return config object | ||
return nextAuthConfig() | ||
}) | ||
.then(nextAuthOptions => { | ||
// Pass Next.js App instance and NextAuth options to NextAuth | ||
return nextAuth(nextApp, nextAuthOptions) | ||
}) | ||
.then((response) => { | ||
console.log(`Ready on http://localhost:${process.env.PORT || 3000}`) | ||
}) | ||
.catch(err => { | ||
console.log('An error occurred, unable to start the server') | ||
console.log(err) | ||
}) | ||
```` | ||
Then copy over the example configuration files below (`next-auth.config.js`, `next-auth.functions.js` and `next-auth.providers.js`) into your project. | ||
Add the following to your `package.json` file to start the project: | ||
````json | ||
"scripts": { | ||
"dev": "NODE_ENV=development node index.js", | ||
"build": "next build", | ||
"start": "node index.js" | ||
}, | ||
```` | ||
You can add a `.env file to the root of the project as a place to specify configuration options: | ||
```` | ||
SERVER_URL=http://localhost:3000 | ||
MONGO_URI=mongodb://localhost:27017/my-database | ||
FACEBOOK_ID= | ||
FACEBOOK_SECRET= | ||
GOOGLE_ID= | ||
GOOGLE_SECRET= | ||
TWITTER_KEY= | ||
TWITTER_SECRET= | ||
EMAIL_FROM=username@gmail.com | ||
EMAIL_SERVER=smtp.gmail.com | ||
EMAIL_PORT=465 | ||
EMAIL_USERNAME=username@gmail.com | ||
EMAIL_PASSWORD= | ||
```` | ||
See [AUTHENTICATION.md](https://github.com/iaincollins/next-auth/tree/master/AUTHENTICATION.md) for a guide on how to set up oAuth providers. | ||
## Configuration | ||
NextAuth configuration can be split into into three files, which makes it easier to manage. | ||
### next-auth.config.js | ||
Basic configuration is defined in **next-auth.config.js** | ||
It also where **next-auth.functions.js** and **next-auth.providers.js** are loaded. | ||
### next-auth.functions.js | ||
CRUD methods for user management and sending email are defined in **next-auth.functions.js** | ||
* find({id,email,emailToken,provider}) // Get user | ||
* insert(user) // Create user | ||
* update(user) // Update user | ||
* remove(id) // Remove user | ||
* serialize(user) // Get ID from user | ||
* deserialize(id) // Get user from ID | ||
* sendSigninEmail({email, url}) // Send email | ||
The example configuration is designed to work with Mongo DB, but by defining the behaviour in these functions you can use NextAuth with any database, including a relational database that uses SQL. | ||
### next-auth.providers.js | ||
Configuration for oAuth providers are defined in **next-auth.functions.js** | ||
The example configuration file supports Facebook, Google and Twitter but can be updated to support any oAuth provider. | ||
---- | ||
See the [nextjs-starter.now.sh](https://nextjs-starter.now.sh) project for more complete example and live demo. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
113
29
1
60427
18
1388