-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to get auth redirects to work
- Loading branch information
Showing
20 changed files
with
219 additions
and
20 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 |
---|---|---|
|
@@ -104,4 +104,9 @@ dist | |
.tern-port | ||
|
||
# WebStorm | ||
.idea | ||
.idea | ||
|
||
# Emacs (Yes there are still people out there using it) | ||
*~ | ||
\#*\# | ||
\.#* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template> | ||
<div id="login" class=""> | ||
<h2>Login</h2> | ||
<button @click="login" class="">Login</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "AuthView", | ||
methods: { | ||
login: async () => { | ||
const authRequest = new Request("http://localhost:5000/auth/login",{ | ||
method: "GET" | ||
}); | ||
const response = await fetch(authRequest); | ||
console.log(response); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
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
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
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,4 @@ | ||
APP_HOST=null | ||
APP_PORT=null | ||
OAUTH_CLIENT_ID=null | ||
OAUTH_CLIENT_SECRET=null |
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
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,22 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import { Issuer } from "openid-client"; | ||
|
||
export async function init(req: Request, res: Response, next: NextFunction) { | ||
const initialized = !!req.app.authIssuer && req.app.authClient; | ||
if (!initialized) { | ||
const issuer = await Issuer.discover("https://accounts.google.com"); | ||
const client = new issuer.Client({ | ||
client_id: process.env.OAUTH_CLIENT_ID!, | ||
client_secret: process.env.OAUTH_CLIENT_SECRET!, | ||
redirect_uris: [`${getDomain()}/auth/callback`], | ||
response_types: ["code"] | ||
}); | ||
req.app.authIssuer = issuer; | ||
req.app.authClient = client; | ||
} | ||
next(); | ||
} | ||
|
||
export function getDomain(): string { | ||
return `http://${process.env.APP_HOST}:${process.env.APP_PORT}`; | ||
} |
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
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,17 @@ | ||
import express, { Request, Response, Router } from "express"; | ||
|
||
// This is local instance of express' router that is scoped to the current (controller) module. | ||
// It is probably a good idea to crate a singleton in an extra module that can be referenced (imported) by all | ||
// controllers | ||
const router: Router = express.Router(); | ||
|
||
router.get("/login", (req: Request, res: Response) => { | ||
const authUrl = req.app.authClient!.authorizationUrl({ | ||
scope: "openid email profile" | ||
}); | ||
// console.log("REDIRECTING URIS: ", req.app.authClient?.metadata.redirect_uris); | ||
console.log("REDIRECTING TO: ", authUrl); | ||
res.redirect(authUrl); | ||
}); | ||
|
||
export default router; |
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.