From 82e15f6d7923e12729f7635d8137c01da660625a Mon Sep 17 00:00:00 2001 From: Anillc Date: Thu, 31 Aug 2023 01:32:23 +0800 Subject: [PATCH] fix(matrix): get as_token from headers --- adapters/matrix/src/http.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adapters/matrix/src/http.ts b/adapters/matrix/src/http.ts index c9762134..d15803f0 100644 --- a/adapters/matrix/src/http.ts +++ b/adapters/matrix/src/http.ts @@ -14,7 +14,10 @@ export class HttpAdapter extends Adapter.Server { 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' }