Skip to content

Commit

Permalink
fix(matrix): get as_token from headers (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anillc authored Sep 8, 2023
1 parent a459c48 commit 8f9d54a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion adapters/matrix/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export class HttpAdapter extends Adapter.Server<MatrixBot> {
ctx.router.all('/(.*)', (koaCtx, next) => {
const match = this.bots.filter(bot => koaCtx.path.startsWith(bot.config.path + '/'))
if (match.length === 0) return next()
const bots = match.filter(bot => bot.config.hsToken === koaCtx.query.access_token)
// Bearer
const asToken = koaCtx.headers.authorization?.substring(7) || koaCtx.query.access_token
if (!asToken) return next()
const bots = match.filter(bot => bot.config.hsToken === asToken)
if (!bots.length) {
koaCtx.status = 403
koaCtx.body = { errcode: 'M_FORBIDDEN' }
Expand Down

0 comments on commit 8f9d54a

Please sign in to comment.