File tree Expand file tree Collapse file tree
acidify-milky/src/commonMain/kotlin/org/ntqqrev/acidify/milky Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ import org.ntqqrev.acidify.milky.MilkyContext
99context(ctx: MilkyContext )
1010fun Route.apiAuth () = install(createRouteScopedPlugin(" ApiAuth" ) {
1111 onCall { call ->
12+ val logger = ctx.bot.createLogger(" ApiAuthPlugin" )
1213 if (call.request.headers[" Authorization" ] != " Bearer ${ctx.httpAccessToken} " ) {
14+ logger.i { " ${call.request.local.remoteAddress} 未携带正确的 access token,拒绝访问" }
1315 call.respond(HttpStatusCode .Unauthorized )
1416 return @onCall
1517 }
Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ import org.ntqqrev.acidify.milky.MilkyContext
99context(ctx: MilkyContext )
1010fun Route.eventAuth () = install(createRouteScopedPlugin(" EventAuth" ) {
1111 onCall { call ->
12+ val logger = ctx.bot.createLogger(" ApiAuthPlugin" )
1213 if (
1314 call.request.headers[" Authorization" ] != " Bearer ${ctx.httpAccessToken} " &&
1415 call.request.queryParameters[" access_token" ] != ctx.httpAccessToken
1516 ) {
17+ logger.i { " ${call.request.local.remoteAddress} 未携带正确的 access token,拒绝访问" }
1618 call.respond(HttpStatusCode .Unauthorized )
1719 return @onCall
1820 }
You can’t perform that action at this time.
0 commit comments