Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(static): 增添普通用户对COS upload的下载权限 #1284

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/routes/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const generalActions = [
"name/cos:DeleteObject",
"name/cos:GetBucket",
];
const viewActions = [
"name/cos:HeadObject",
"name/cos:GetObject",
"name/cos:GetBucket",
]

router.get("/team_code", async (req, res) => {
try{
Expand Down Expand Up @@ -153,7 +158,6 @@ router.get("/chat_record", async (req, res) => {
//General Template
router.get("/", async (req, res) => {
try{
const action = generalActions;
const authHeader = req.get("Authorization");
if (!authHeader) {
return res.status(401).send("401 Unauthorized: Missing token");
Expand All @@ -168,10 +172,13 @@ router.get("/", async (req, res) => {
}
const payload = decoded as JwtPayload;
if (payload.role == 'counselor' || payload.role == 'root' || payload.role == 'admin') {
const sts = await getSTS(action, "*");
const sts = await getSTS(generalActions, "*");
return res.status(200).send(sts);
}
else {
const sts = await getSTS(viewActions, "upload/*");
return res.status(200).send(sts);
}
else return res.status(401).send("401 Unauthorized");
} catch (err) {
return res.status(500).send(err);
}
Expand Down
Loading