-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): Make token auth default (#6305)
**What** - make token auth the default being returned from authentication endpoints in api-v2 - Add `auth/session` to convert token to session based auth - add regex-scopes to authenticate middleware Co-authored-by: Sebastian Rindom <[email protected]>
- Loading branch information
Showing
21 changed files
with
147 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { initDb, useDb } from "../../../../environment-helpers/use-db" | |
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import adminSeeder from "../../../../helpers/admin-seeder" | ||
import { getContainer } from "../../../../environment-helpers/use-container" | ||
import jwt from "jsonwebtoken" | ||
import path from "path" | ||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app" | ||
import { useApi } from "../../../../environment-helpers/use-api" | ||
|
@@ -47,12 +48,14 @@ describe("POST /store/customers", () => { | |
const authService: IAuthModuleService = appContainer.resolve( | ||
ModuleRegistrationName.AUTH | ||
) | ||
const { jwt_secret } = appContainer.resolve("configModule").projectConfig | ||
const authUser = await authService.createAuthUser({ | ||
entity_id: "store_user", | ||
provider_id: "test", | ||
provider: "emailpass", | ||
scope: "store", | ||
}) | ||
const jwt = await authService.generateJwtToken(authUser.id, "store") | ||
|
||
const token = jwt.sign(authUser, jwt_secret) | ||
|
||
const api = useApi() as any | ||
const response = await api.post( | ||
|
@@ -62,7 +65,7 @@ describe("POST /store/customers", () => { | |
last_name: "Doe", | ||
email: "[email protected]", | ||
}, | ||
{ headers: { authorization: `Bearer ${jwt}` } } | ||
{ headers: { authorization: `Bearer ${token}` } } | ||
) | ||
|
||
expect(response.status).toEqual(200) | ||
|
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
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
Oops, something went wrong.