mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 05:05:53 +00:00
Support legacy auth on account endpoints
This commit is contained in:
parent
852e737e33
commit
7d54948d7e
@ -1,9 +1,10 @@
|
||||
import { GET, Path, POST, QueryParam } from "typescript-rest";
|
||||
import { GET, Path, POST, QueryParam, Security } from "typescript-rest";
|
||||
import { ApiError } from "../ApiError";
|
||||
import { OpenId } from "../../models/OpenId";
|
||||
import { ScalarAccountResponse, ScalarRegisterResponse } from "../../models/ScalarResponses";
|
||||
import { AutoWired, Inject } from "typescript-ioc/es6";
|
||||
import AccountController from "../controllers/AccountController";
|
||||
import { ROLE_MSC_USER } from "../security/MSCSecurity";
|
||||
|
||||
/**
|
||||
* API for the minimum Scalar API we need to implement to be compatible with clients. Used for registration
|
||||
@ -29,6 +30,7 @@ export class ScalarService {
|
||||
|
||||
@GET
|
||||
@Path("account")
|
||||
@Security(ROLE_MSC_USER)
|
||||
public async getAccount(@QueryParam("scalar_token") scalarToken: string, @QueryParam("v") apiVersion: string): Promise<ScalarAccountResponse> {
|
||||
if (apiVersion !== "1.1") {
|
||||
throw new ApiError(401, "Invalid API version.");
|
||||
|
@ -51,6 +51,9 @@ export default class MSCSecurity implements ServiceAuthenticator {
|
||||
token = header.substring("Bearer ".length);
|
||||
} else if (req.query && req.query.access_token) {
|
||||
token = req.query.access_token;
|
||||
} else if (req.query && req.query.scalar_token) {
|
||||
LogService.warn("MSCSecurity", "Request used old scalar_token auth - this will be removed in a future version");
|
||||
token = req.query.scalar_token;
|
||||
}
|
||||
|
||||
if (token) {
|
||||
|
Loading…
Reference in New Issue
Block a user