Support legacy auth on account endpoints

This commit is contained in:
Travis Ralston 2019-07-10 18:40:30 -06:00
parent 852e737e33
commit 7d54948d7e
2 changed files with 6 additions and 1 deletions

View File

@ -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.");

View File

@ -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) {