forked from nextauthjs/next-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor JWT, Sessions and add allowSignin() method (nextauthjs#223)
## Database - [x] Databases are now optional - useful with OAuth + JWT if you only need access control - [x] Updated documentation and added example code for custom database adapters ## JWT - [x] JWT option is now an object that groups JWT related options together (was a boolean) - [X] Refactored JWT lib and add AES encryption / decryption as well as signing / verification - [x] Allows JWT encode/decode methods to be overridden as options - [x] Contents of JWT can easily customised - without needing to use custom encode/decode - [x] Exported JWT methods so they can be called from custom API routes - [x] Updated documentation for new JWT options ## Sessions - [x] All session options (eg. `maxAge`, `updateAge`) now grouped under single `session` option - [x] Using JWT for sessions is now enabled from session object (`session.jwt: true`) - [x] All options involving time now use seconds (instead of milliseconds) for consistency - [x] Added option to customise the Session object that is returned from `/api/auth/session` - [x] Update documentation for new Session options ## Other improvements - [x] Added `allowSignin()` option to control what users / accounts are allowed to sign in - [x] Refactored `callbackUrlHandler()` - this option is now called `allowCallbackUrl()` - [x] Minor improvements to NextAuth.js client API methods - [x] Minor to NextAuth.js API routes - [x] Minor improvements to built-in error pages - [x] Refactored database models All tables now include a `created` column for each row which contains the `datetime` of when the row (e.g. User / Account / Session) was created. Additionally, sessions now use the name 'expiry' for the expiry `datetime` value for consistency with other models.
- Loading branch information
1 parent
35123f0
commit 0d825bb
Showing
33 changed files
with
874 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/lib/jwt').default |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "next-auth", | ||
"version": "2.0.0-beta.62", | ||
"version": "2.0.0-beta.67", | ||
"description": "An authentication library for Next.js", | ||
"repository": "https://github.com/iaincollins/next-auth.git", | ||
"author": "Iain Collins <[email protected]>", | ||
|
@@ -30,6 +30,7 @@ | |
], | ||
"license": "ISC", | ||
"dependencies": { | ||
"crypto-js": "^4.0.0", | ||
"jsonwebtoken": "^8.5.1", | ||
"jwt-decode": "^2.2.0", | ||
"nodemailer": "^6.4.6", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
const Adapter = (config, options = {}) => { | ||
async function getAdapter (appOptions) { | ||
// Display debug output if debug option enabled | ||
function _debug (...args) { | ||
if (appOptions.debug) { | ||
console.log('[next-auth][debug]', ...args) | ||
} | ||
} | ||
|
||
async function createUser (profile) { | ||
_debug('createUser', profile) | ||
return null | ||
} | ||
|
||
async function getUser (id) { | ||
_debug('getUser', id) | ||
return null | ||
} | ||
|
||
async function getUserByEmail (email) { | ||
_debug('getUserByEmail', email) | ||
return null | ||
} | ||
|
||
async function getUserByProviderAccountId (providerId, providerAccountId) { | ||
_debug('getUserByProviderAccountId', providerId, providerAccountId) | ||
return null | ||
} | ||
|
||
async function getUserByCredentials (credentials) { | ||
_debug('getUserByCredentials', credentials) | ||
return null | ||
} | ||
|
||
async function updateUser (user) { | ||
_debug('updateUser', user) | ||
return null | ||
} | ||
|
||
async function deleteUser (userId) { | ||
_debug('deleteUser', userId) | ||
return null | ||
} | ||
|
||
async function linkAccount (userId, providerId, providerType, providerAccountId, refreshToken, accessToken, accessTokenExpires) { | ||
_debug('linkAccount', userId, providerId, providerType, providerAccountId, refreshToken, accessToken, accessTokenExpires) | ||
return null | ||
} | ||
|
||
async function unlinkAccount (userId, providerId, providerAccountId) { | ||
_debug('unlinkAccount', userId, providerId, providerAccountId) | ||
return null | ||
} | ||
|
||
async function createSession (user) { | ||
_debug('createSession', user) | ||
return null | ||
} | ||
|
||
async function getSession (sessionToken) { | ||
_debug('getSession', sessionToken) | ||
return null | ||
} | ||
|
||
async function updateSession (session, force) { | ||
_debug('updateSession', session) | ||
return null | ||
} | ||
|
||
async function deleteSession (sessionToken) { | ||
_debug('deleteSession', sessionToken) | ||
return null | ||
} | ||
|
||
async function createVerificationRequest (identifer, url, token, secret, provider) { | ||
_debug('createVerificationRequest', identifer) | ||
return null | ||
} | ||
|
||
async function getVerificationRequest (identifer, token, secret, provider) { | ||
_debug('getVerificationRequest', identifer, token) | ||
return null | ||
} | ||
|
||
async function deleteVerificationRequest (identifer, token, secret, provider) { | ||
_debug('deleteVerification', identifer, token) | ||
return null | ||
} | ||
|
||
return Promise.resolve({ | ||
createUser, | ||
getUser, | ||
getUserByEmail, | ||
getUserByProviderAccountId, | ||
getUserByCredentials, | ||
updateUser, | ||
deleteUser, | ||
linkAccount, | ||
unlinkAccount, | ||
createSession, | ||
getSession, | ||
updateSession, | ||
deleteSession, | ||
createVerificationRequest, | ||
getVerificationRequest, | ||
deleteVerificationRequest | ||
}) | ||
} | ||
|
||
return { | ||
getAdapter | ||
} | ||
} | ||
|
||
export default { | ||
Adapter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.