mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
6b78240d39
From this commit on, api endpoints reply with a 401 error code and non api endpoints redirect to /error/40X. This commit also fixes missing restrictions on /loggedin (the "already logged in page). This was not a security issue, though. The change also makes error pages automatically redirect the user after few seconds based on the referrer or the default_redirection_url if provided in the configuration. Warning: The old /verify endpoint of the REST API has moved to /api/verify. You will need to update your nginx configuration to take this change into account.
104 lines
2.7 KiB
TypeScript
104 lines
2.7 KiB
TypeScript
|
|
import sinon = require("sinon");
|
|
import express = require("express");
|
|
|
|
export interface RequestMock {
|
|
app?: any;
|
|
body?: any;
|
|
session?: any;
|
|
headers?: any;
|
|
get?: any;
|
|
query?: any;
|
|
originalUrl: string;
|
|
}
|
|
|
|
export interface ResponseMock {
|
|
send: sinon.SinonStub | sinon.SinonSpy;
|
|
sendStatus: sinon.SinonStub;
|
|
sendFile: sinon.SinonStub;
|
|
sendfile: sinon.SinonStub;
|
|
status: sinon.SinonStub | sinon.SinonSpy;
|
|
json: sinon.SinonStub | sinon.SinonSpy;
|
|
links: sinon.SinonStub;
|
|
jsonp: sinon.SinonStub;
|
|
download: sinon.SinonStub;
|
|
contentType: sinon.SinonStub;
|
|
type: sinon.SinonStub;
|
|
format: sinon.SinonStub;
|
|
attachment: sinon.SinonStub;
|
|
set: sinon.SinonStub;
|
|
header: sinon.SinonStub;
|
|
headersSent: boolean;
|
|
get: sinon.SinonStub;
|
|
clearCookie: sinon.SinonStub;
|
|
cookie: sinon.SinonStub;
|
|
location: sinon.SinonStub;
|
|
redirect: sinon.SinonStub | sinon.SinonSpy;
|
|
render: sinon.SinonStub | sinon.SinonSpy;
|
|
locals: sinon.SinonStub;
|
|
charset: string;
|
|
vary: sinon.SinonStub;
|
|
app: any;
|
|
write: sinon.SinonStub;
|
|
writeContinue: sinon.SinonStub;
|
|
writeHead: sinon.SinonStub;
|
|
statusCode: number;
|
|
statusMessage: string;
|
|
setHeader: sinon.SinonStub;
|
|
setTimeout: sinon.SinonStub;
|
|
sendDate: boolean;
|
|
getHeader: sinon.SinonStub;
|
|
}
|
|
|
|
export function RequestMock(): RequestMock {
|
|
return {
|
|
originalUrl: "/non-api/xxx",
|
|
app: {
|
|
get: sinon.stub()
|
|
},
|
|
headers: {
|
|
"x-forwarded-for": "127.0.0.1"
|
|
},
|
|
session: {}
|
|
};
|
|
}
|
|
export function ResponseMock(): ResponseMock {
|
|
return {
|
|
send: sinon.stub(),
|
|
status: sinon.stub(),
|
|
json: sinon.stub(),
|
|
sendStatus: sinon.stub(),
|
|
links: sinon.stub(),
|
|
jsonp: sinon.stub(),
|
|
sendFile: sinon.stub(),
|
|
sendfile: sinon.stub(),
|
|
download: sinon.stub(),
|
|
contentType: sinon.stub(),
|
|
type: sinon.stub(),
|
|
format: sinon.stub(),
|
|
attachment: sinon.stub(),
|
|
set: sinon.stub(),
|
|
header: sinon.stub(),
|
|
headersSent: true,
|
|
get: sinon.stub(),
|
|
clearCookie: sinon.stub(),
|
|
cookie: sinon.stub(),
|
|
location: sinon.stub(),
|
|
redirect: sinon.stub(),
|
|
render: sinon.stub(),
|
|
locals: sinon.stub(),
|
|
charset: "utf-8",
|
|
vary: sinon.stub(),
|
|
app: sinon.stub(),
|
|
write: sinon.stub(),
|
|
writeContinue: sinon.stub(),
|
|
writeHead: sinon.stub(),
|
|
statusCode: 200,
|
|
statusMessage: "message",
|
|
setHeader: sinon.stub(),
|
|
setTimeout: sinon.stub(),
|
|
sendDate: true,
|
|
getHeader: sinon.stub()
|
|
};
|
|
}
|