-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: disable admin * fix: fix env * fix: fix develop env * fix: fix package.json * feat: implement randomKey method * fix: fix typoe * fix: fix cors * feat: implement api key generate & validation logic * fix: implement config session_key * fix: log signed sid * fix: fix generateAPIKey API * fix: test1 * fix: revert * fix: fix APIs * fix: fix settings * fix: add comment
- Loading branch information
1 parent
a16f49f
commit 1d55410
Showing
12 changed files
with
404 additions
and
339 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
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 @@ | ||
import express, { Request, Response } from "express"; | ||
import { API_KEYS } from "src/loaders/express"; | ||
import { randomKey } from "src/utils/crypto"; | ||
const router = express.Router(); | ||
|
||
router.get("/generate-api-key", (req: Request, res: Response) => { | ||
const key = randomKey(32); | ||
|
||
if (API_KEYS.size >= 10) { | ||
API_KEYS.clear(); | ||
} | ||
|
||
API_KEYS.add(key); | ||
|
||
console.info(`🔑 API Key is generated(${API_KEYS.size}/10): ${key}`); | ||
|
||
const maskedKey = key.slice(0, 4) + "*".repeat(28); | ||
|
||
return res.status(200).send({ | ||
code: "API_KEY_GENERATED", | ||
message: `API key is generated(${maskedKey}); Please check log`, | ||
}); | ||
}); | ||
|
||
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.