-
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.
feat: logout endpoint (clears the session)
* Added /auth/logout route * Misc refactoring and cleanup
- Loading branch information
1 parent
78a186e
commit 6db3663
Showing
16 changed files
with
182 additions
and
143 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
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,5 @@ | ||
@aws | ||
runtime nodejs12.x | ||
# memory 1152 | ||
# timeout 30 | ||
# concurrency 1 |
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 @@ | ||
import logoutHandlerFactory from "@architect/shared/lambda/oauth/handlers/logout" | ||
|
||
export const handler = logoutHandlerFactory() |
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
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 { expectSession } from "../../../../../test/support" | ||
import { createMockRequest } from "../../../../../test/support/lambda" | ||
import logoutHandlerFactory from "./logout" | ||
|
||
it("should redirect", async () => { | ||
const req = createMockRequest() | ||
const handler = logoutHandlerFactory() | ||
|
||
const res = await handler(req) | ||
expect(res).toHaveProperty("statusCode", 302) | ||
}) | ||
|
||
it("should create a browser session", async () => { | ||
const req = createMockRequest() | ||
const handler = logoutHandlerFactory() | ||
|
||
const res = await handler(req) | ||
|
||
expect(res).toHaveProperty("statusCode", 302) | ||
// make sure it created a session | ||
expectSession(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,18 @@ | ||
import { LambdaHttpHandler, LambdaHttpResponse } from "../../lambda" | ||
import { createAnonymousSession, writeSession } from "../../session" | ||
|
||
/** Creates a @see LambdaHttpHandler that handles logout. */ | ||
export default function logoutHandlerFactory(): LambdaHttpHandler { | ||
async function logoutHandler(): Promise<LambdaHttpResponse> { | ||
const res: LambdaHttpResponse = { | ||
statusCode: 302, | ||
headers: { | ||
location: "/", | ||
}, | ||
body: "", | ||
} | ||
writeSession(res, createAnonymousSession()) | ||
return res | ||
} | ||
return logoutHandler | ||
} |
Oops, something went wrong.