-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add additional configuration to control the return pathname #9
Conversation
import { authkitMiddleware } from './middleware.js'; | ||
import { getUser } from './session.js'; | ||
import { getSignInUrl, signOut } from './auth.js'; | ||
import { Impersonation } from './impersonation.js'; | ||
|
||
export { | ||
authkitCallbackRoute, | ||
handleAuth, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kinda breaks backwards compatibility right? Wonder if that means we should release a major version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically I think that's fine given we're in the 0.x range.
From SemVer:
Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
return async function GET(request: NextRequest) { | ||
const code = request.nextUrl.searchParams.get('code'); | ||
const state = request.nextUrl.searchParams.get('state'); | ||
const returnPathname = state ? JSON.parse(atob(state)).returnPathname : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should happen if state
doesn't contain valid JSON?
Right now it will throw, which is probably fine if the state
was tampered with (maliciously or not), but wanted to point it out in case anyone had other preferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's fine for now considering it would only be an issue if tampered with.
This PR handles a couple things:
ensureSignedIn
istrue
ingetUser()
Fixes #11