-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d600ea
commit 87f52c6
Showing
11 changed files
with
704 additions
and
3,353 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,5 @@ | ||
import { setupChallenge } from "../utils/setupChallenge"; | ||
|
||
export const createClient = () => { | ||
console.log(createClient); | ||
}; |
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 @@ | ||
export const SESSION_PREFIX = "pkce-verifier"; |
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,10 @@ | ||
import { login } from "./login"; | ||
|
||
export default function handler(req, res) { | ||
const { kindeAuth: route } = req.query; | ||
|
||
switch (route) { | ||
case "login": | ||
return login(req, res); | ||
} | ||
} |
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 @@ | ||
export { default as handleAuth } from "./handleAuth"; |
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,8 @@ | ||
import { setupChallenge } from "../utils/setupChallenge"; | ||
|
||
export const login = (req, res) => { | ||
// setupChallenge(); | ||
console.log("log in"); | ||
console.log("req", req); | ||
console.log("res", res); | ||
}; |
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 +1,2 @@ | ||
export { KindeProvider, AuthContext, useAuth } from "./frontend/index"; | ||
export { handleAuth } from "./handlers/index"; |
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,3 @@ | ||
const crypto = require("crypto"); | ||
|
||
export const randomString = () => crypto.randomBytes(28).toString("hex"); |
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,16 @@ | ||
import { randomString } from "./randomString"; | ||
import { SESSION_PREFIX } from "../config/sessionPrefix"; | ||
var cookie = require("cookie"); | ||
|
||
export const setupChallenge = () => { | ||
const state = randomString(); | ||
const code_verifier = randomString(); // the secret | ||
// Hash and base64-urlencode the secret to use as the challenge | ||
const code_challenge = "await pkceChallengeFromVerifier(code_verifier)"; | ||
|
||
cookie.parse(`${SESSION_PREFIX}-${state}`, code_verifier); | ||
|
||
// Build and encode the authorisation request url | ||
const url = new URL(config.authorization_endpoint); | ||
return { state, code_challenge, url }; | ||
}; |