Skip to content

Commit

Permalink
use clientId when user field is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Nov 29, 2023
1 parent a5cd110 commit 593dee7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function createServer(appVersion) {
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());

// app.use('*', (req, res, next) => {
// console.log(req.headers)
// next()
// })

app.use('/', Security.extractUserFromQuery);
app.use('/', publicRouter);
app.use('/api/plugins', pluginsRouter);
Expand Down
4 changes: 2 additions & 2 deletions server/security/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const otoroshiAuthentication = (req, res, next) => {
if (jwtUser) {
try {
const decodedToken = jwt.verify(jwtUser, secret, { algorithms: ['HS512'] });
req.user = decodedToken.user
req.user = decodedToken.user || decodedToken.apikey.clientId
next()
} catch (err) {
console.log(err)
missingCredentials(res)
}
} else {
console.log(`Missing jwt user ${jwtUser}`)
console.log(`Missing jwt user`, jwtUser)
missingCredentials(res)
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require("fs-extra");
const path = require("path");
const pako = require('pako');

const format = value => value.replace(/[^a-zA-Z ]/g, "");
const format = value => value?.replace(/[^a-zA-Z ]/g, "");

const unzip = (isRustBuild, zipString, outputFolder, rules = []) => {
try {
Expand Down

0 comments on commit 593dee7

Please sign in to comment.