Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added /api/auth/tokens endpoint to return oauth tokens #425

Closed
wants to merge 51 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d17da5b
feat(adapter): Add opinionated prisma adapter
Fumler Jun 22, 2020
a04c03b
fix(prisma): Make sure provider id is a string
Fumler Jun 30, 2020
d7771b6
docs(prisma): Add note about model names and set email to optional
Fumler Jul 4, 2020
cbfd8cf
Add support for hitting cancel if using token id
iaincollins Jun 28, 2020
7749759
feat: Added UserData to ProfileData after return from Apple to get us…
Jul 1, 2020
d4ff56b
Fix linter errors and add comments
iaincollins Jul 4, 2020
1dc26a6
Fix for reading private key in Apple provider
iaincollins Jul 4, 2020
327a3f3
Add provider Vercel-style marquee to docs
ndom91 Jul 6, 2020
8a265f7
Add tutorial on how to use custom typeorm models
tmayr Jul 6, 2020
0687c24
Improve CSRF security for all routes
iaincollins Jul 1, 2020
6541cc6
Fix linting errors and bug in getCsrfToken
iaincollins Jul 1, 2020
805c4de
Refactor redirect handling (WIP)
iaincollins Jul 2, 2020
201335f
Improve client state syncing
iaincollins Jul 2, 2020
77be1b0
Improve client event handling
iaincollins Jul 3, 2020
5373da2
Only invoke setTimeout client side
iaincollins Jul 3, 2020
24c9fed
Update events, callbacks & pages to use camelCase
iaincollins Jul 3, 2020
12cdfb1
Fix linter errors
iaincollins Jul 4, 2020
4578ad7
Update version to 3.0.0-beta.8
iaincollins Jul 4, 2020
014f1c9
Update pages documentation
iaincollins Jul 4, 2020
afc2364
Update version to 3.0.0-beta.9
iaincollins Jul 4, 2020
92ef9ea
Respect existing cookies on a request object
iaincollins Jul 6, 2020
9621856
Fix error merging branches for v3
iaincollins Jul 7, 2020
83b2b67
Refactor to simplify site URL configuration
iaincollins Jul 7, 2020
80873c7
Update TypeORM tutorial
iaincollins Jul 7, 2020
d3722d1
Update adapter documentation
iaincollins Jul 7, 2020
468d33c
fix: marquee icons
ndom91 Jul 7, 2020
d45fb43
Fix bug with NEXTAUTH_URL parsing
iaincollins Jul 8, 2020
b158039
Update version to 3.0.0-beta.13
iaincollins Jul 8, 2020
82762ac
Update homepage
iaincollins Jul 8, 2020
f9e9cb7
Refactor and document state provider option
iaincollins Jul 8, 2020
f9c043a
Disable use of state on Apple provider
iaincollins Jul 8, 2020
1e147dc
Improve homepage
iaincollins Jul 8, 2020
5962432
Update adapters documentation
iaincollins Jul 8, 2020
db41ca5
Tweak CSS on homepage
iaincollins Jul 8, 2020
a236da9
Update homepage and refactor CSS
iaincollins Jul 8, 2020
861b019
Add support for passing appContext to getCsrfToken
iaincollins Jul 8, 2020
5b988e6
Update email provider
iaincollins Jul 8, 2020
7dafa67
Apply datetime transforms on properties in custom models
iaincollins Jul 8, 2020
0676b25
Update documentation
iaincollins Jul 8, 2020
5ed775c
Add provider icons to homepage
iaincollins Jul 9, 2020
d933775
Add FAQ
iaincollins Jul 9, 2020
4cea678
Improve docs site on mobile
iaincollins Jul 9, 2020
e1a186f
Update FAQ
iaincollins Jul 9, 2020
5e16fc8
Bump version to 3.0.0-beta.17
iaincollins Jul 10, 2020
19df05a
Refactor JWT support
iaincollins Jul 9, 2020
1e4f6eb
Update JWT and session docs
iaincollins Jul 10, 2020
8dbe4f2
Enforce HMAC-256 on JWT
iaincollins Jul 10, 2020
6835e90
Update version to 3.0.0-beta.18
iaincollins Jul 10, 2020
457b3b6
added /api/auth/accounts endpoint to return oauth tokens
tomvoss Jul 12, 2020
2f046a0
add /api/auth/token/:provider/:type endpoint
tomvoss Jul 14, 2020
a3211b3
rename token endpoint to tokens and remove accounts endpoint
tomvoss Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for hitting cancel if using token id
When using a provider that uses Token ID option (like Apple) a user hitting cancel with no longer cause the app to crash.

Users who do this will now be taken back to the sign in page.

This was already working for other providers that didn't use this option but wasn't supported for providers that did use it.
  • Loading branch information
iaincollins committed Jul 10, 2020
commit cbfd8cfd244e00389cbcc63fad9eee4bfdee1dbf
13 changes: 12 additions & 1 deletion src/server/lib/oauth/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,23 @@ export default async (req, provider, callback) => {
code,
provider,
(error, accessToken, refreshToken, results) => {
// @TODO Handle error
if (error || results.error) {
logger.error('OAUTH_GET_ACCESS_TOKEN_ERROR', error, results, provider.id, code)
return callback(error || results.error)
}

if (provider.idToken) {

// If we don't have an ID Token most likely the user hit a cancel
// button when signing in (or the provider is misconfigured).
//
// Unfortunately, we can't tell which, so we can't treat it as an
// error, so instead we just returning nothing, which will cause the
// user to be redirected back to the sign in page.
if (!results || !results.id_token) {
return callback()
}

// Support services that use OpenID ID Tokens to encode profile data
_decodeToken(
provider,
Expand Down