Remove the shared directory and move files to server.

This commit is contained in:
Clement Michaud 2019-04-17 00:26:12 +02:00 committed by Clément Michaud
parent 5a195f7ebd
commit 186839d6e5
54 changed files with 48 additions and 55 deletions

View File

@ -1,7 +1,6 @@
client/
server/
test/
shared/
docs/
scripts/
images/

View File

@ -10,7 +10,6 @@ RUN apk --update add --no-cache --virtual \
apk del .build-deps
COPY dist/server /usr/src/server
COPY dist/shared /usr/src/shared
EXPOSE 9091

View File

@ -35,7 +35,6 @@ async function runTests(patterns) {
async function test() {
await runTests([
'server/src/**/*.spec.ts',
'shared/**/*.spec.ts'
]);
}

View File

@ -1,7 +1,7 @@
import { DomainExtractor } from "./DomainExtractor";
import Assert = require("assert");
describe("shared/DomainExtractor", function () {
describe("src/lib/DomainExtractor", function () {
describe("test fromUrl", function () {
it("should return domain from https url", function () {
const domain = DomainExtractor.fromUrl("https://www.example.com/test/abc");

View File

@ -9,7 +9,7 @@ import ExpressMock = require("./stubs/express.spec");
import { IdentityValidableStub } from "./IdentityValidableStub.spec";
import { ServerVariablesMock, ServerVariablesMockBuilder }
from "./ServerVariablesMockBuilder.spec";
import { OPERATION_FAILED } from "../../../shared/UserMessages";
import { OPERATION_FAILED } from "./UserMessages";
describe("IdentityCheckMiddleware", function () {
let req: Express.Request;

View File

@ -10,12 +10,12 @@ import { AuthenticationSessionHandler } from "./AuthenticationSessionHandler";
import { AuthenticationSession } from "../../types/AuthenticationSession";
import { ServerVariables } from "./ServerVariables";
import { IdentityValidable } from "./IdentityValidable";
import * as Constants from "../../../shared/constants";
import * as Constants from "./constants";
import Identity = require("../../types/Identity");
import { IdentityValidationDocument }
from "./storage/IdentityValidationDocument";
import { OPERATION_FAILED } from "../../../shared/UserMessages";
import { OPERATION_FAILED } from "./UserMessages";
import GetHeader from "./utils/GetHeader";
function createAndSaveToken(userid: string, challenge: string,

View File

@ -0,0 +1,3 @@
import Method2FA from "../../../client/src/types/Method2FA";
export default Method2FA;

View File

@ -2,7 +2,6 @@
import Assert = require("assert");
import Sinon = require("sinon");
import nedb = require("nedb");
import express = require("express");
import winston = require("winston");
import speakeasy = require("speakeasy");
import u2f = require("u2f");
@ -10,7 +9,7 @@ import session = require("express-session");
import { Configuration } from "./configuration/schema/Configuration";
import { GlobalDependencies } from "../../types/Dependencies";
import Server from "./Server";
import { LdapjsMock, LdapjsClientMock } from "./stubs/ldapjs.spec";
import { LdapjsMock } from "./stubs/ldapjs.spec";
describe("Server", function () {

View File

@ -11,7 +11,7 @@ import { ServerVariables } from "./ServerVariables";
import { ServerVariablesInitializer } from "./ServerVariablesInitializer";
import { Configurator } from "./web_server/Configurator";
import { GET_VARIABLE_KEY } from "../../../shared/constants";
import { GET_VARIABLE_KEY } from "./constants";
function clone(obj: any) {
return JSON.parse(JSON.stringify(obj));

View File

@ -1,3 +1,3 @@
import { default as Level } from "../../../../shared/AuthenticationLevel";
import { default as Level } from "../AuthenticationLevel";
export { Level };

View File

@ -2,7 +2,6 @@
import MongoDB = require("mongodb");
import { IMongoClient } from "./IMongoClient";
import Bluebird = require("bluebird");
import { AUTHENTICATION_FAILED } from "../../../../../shared/UserMessages";
import { IGlobalLogger } from "../../logging/IGlobalLogger";
import { MongoStorageConfiguration } from "../../configuration/schema/StorageConfiguration";

View File

@ -2,13 +2,13 @@ import BluebirdPromise = require("bluebird");
import express = require("express");
import ErrorReplies = require("../../ErrorReplies");
import { AuthenticationSessionHandler } from "../../AuthenticationSessionHandler";
import UserMessages = require("../../../../../shared/UserMessages");
import UserMessages = require("../../UserMessages");
import { ServerVariables } from "../../ServerVariables";
import { AuthenticationSession } from "../../../../types/AuthenticationSession";
import { GroupsAndEmails } from "../../authentication/backends/GroupsAndEmails";
import { Level } from "../../authentication/Level";
import { Level as AuthorizationLevel } from "../../authorization/Level";
import { BelongToDomain } from "../../../../../shared/BelongToDomain";
import { BelongToDomain } from "../../BelongToDomain";
import { URLDecomposer } from "../..//utils/URLDecomposer";
import { Object } from "../../../lib/authorization/Object";
import { Subject } from "../../../lib/authorization/Subject";

View File

@ -1,7 +1,7 @@
import express = require("express");
import { AuthenticationSessionHandler } from "../../AuthenticationSessionHandler";
import Constants = require("../../../../../shared/constants");
import Constants = require("../../constants");
import { ServerVariables } from "../../ServerVariables";
function getRedirectParam(req: express.Request) {

View File

@ -2,11 +2,10 @@
import express = require("express");
import BluebirdPromise = require("bluebird");
import objectPath = require("object-path");
import exceptions = require("../../../Exceptions");
import { AuthenticationSessionHandler } from "../../../AuthenticationSessionHandler";
import { AuthenticationSession } from "../../../../../types/AuthenticationSession";
import ErrorReplies = require("../../../ErrorReplies");
import UserMessages = require("../../../../../../shared/UserMessages");
import UserMessages = require("../../../UserMessages");
import { ServerVariables } from "../../../ServerVariables";
import Constants = require("./../constants");

View File

@ -1,6 +1,6 @@
import * as Express from "express";
import { ServerVariables } from "../../../ServerVariables";
import Method2FA from "../../../../../../shared/Method2FA";
import Method2FA from "../../../Method2FA";
export default function(vars: ServerVariables) {

View File

@ -2,12 +2,12 @@ import * as Express from "express";
import { ServerVariables } from "../../../ServerVariables";
import { AuthenticationSessionHandler } from "../../../AuthenticationSessionHandler";
import * as ErrorReplies from "../../../ErrorReplies";
import * as UserMessage from "../../../../../../shared/UserMessages";
import * as UserMessage from "../../../UserMessages";
import redirect from "../redirect";
import { Level } from "../../../authentication/Level";
import { DuoPushConfiguration } from "../../../configuration/schema/DuoPushConfiguration";
import GetHeader from "../../../utils/GetHeader";
import { HEADER_X_TARGET_URL } from "../../../../../../shared/constants";
import { HEADER_X_TARGET_URL } from "../../../constants";
const DuoApi = require("@duosecurity/duo_api");
interface DuoResponse {

View File

@ -2,7 +2,7 @@ import * as Express from "express";
import { ServerVariables } from "../../../ServerVariables";
import { AuthenticationSessionHandler } from "../../../AuthenticationSessionHandler";
import * as ErrorReplies from "../../../ErrorReplies";
import * as UserMessage from "../../../../../../shared/UserMessages";
import * as UserMessage from "../../../UserMessages";
export default function(vars: ServerVariables) {

View File

@ -2,7 +2,7 @@ import * as Express from "express";
import { ServerVariables } from "../../../ServerVariables";
import { AuthenticationSessionHandler } from "../../../AuthenticationSessionHandler";
import * as ErrorReplies from "../../../ErrorReplies";
import * as UserMessage from "../../../../../../shared/UserMessages";
import * as UserMessage from "../../../UserMessages";
export default function(vars: ServerVariables) {

View File

@ -5,7 +5,7 @@ import { ServerVariablesMockBuilder }
from "../../ServerVariablesMockBuilder.spec";
import { ServerVariables } from "../../ServerVariables";
import Assert = require("assert");
import { HEADER_X_TARGET_URL } from "../../../../../shared/constants";
import { HEADER_X_TARGET_URL } from "../../constants";
describe("routes/secondfactor/redirect", function() {
let req: Express.Request;

View File

@ -4,7 +4,7 @@ import * as URLParse from "url-parse";
import { ServerVariables } from "../../ServerVariables";
import IsRedirectionSafe from "../../../lib/utils/IsRedirectionSafe";
import GetHeader from "../../utils/GetHeader";
import { HEADER_X_TARGET_URL } from "../../../../../shared/constants";
import { HEADER_X_TARGET_URL } from "../../constants";
export default function (vars: ServerVariables) {

View File

@ -7,7 +7,7 @@ import { IdentityValidable } from "../../../../IdentityValidable";
import Constants = require("../constants");
import ErrorReplies = require("../../../../ErrorReplies");
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import FirstFactorValidator = require("../../../../FirstFactorValidator");
import { IRequestLogger } from "../../../../logging/IRequestLogger";
import { IUserDataStore } from "../../../../storage/IUserDataStore";

View File

@ -6,7 +6,7 @@ import Redirect from "../../redirect";
import ErrorReplies = require("../../../../ErrorReplies");
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import { AuthenticationSession } from "../../../../../../types/AuthenticationSession";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { ServerVariables } from "../../../../ServerVariables";
import { Level } from "../../../../authentication/Level";

View File

@ -7,10 +7,10 @@ import redirect from "../../redirect";
import ErrorReplies = require("../../../../ErrorReplies");
import { ServerVariables } from "../../../../ServerVariables";
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { AuthenticationSession } from "../../../../../../types/AuthenticationSession";
import GetHeader from "../../../../utils/GetHeader";
import * as Constants from "../../../../../../../shared/constants";
import * as Constants from "../../../../constants";
export default function (vars: ServerVariables) {

View File

@ -5,10 +5,10 @@ import U2f = require("u2f");
import ErrorReplies = require("../../../../ErrorReplies");
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import { AuthenticationSession } from "../../../../../../types/AuthenticationSession";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { ServerVariables } from "../../../../ServerVariables";
import GetHeader from "../../../../utils/GetHeader";
import * as Constants from "../../../../../../../shared/constants";
import * as Constants from "../../../../constants";
export default function (vars: ServerVariables) {
function handler(req: express.Request, res: express.Response): BluebirdPromise<void> {

View File

@ -4,7 +4,7 @@ import BluebirdPromise = require("bluebird");
import Assert = require("assert");
import U2FSignPost = require("./post");
import { ServerVariables } from "../../../../ServerVariables";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { ServerVariablesMockBuilder, ServerVariablesMock } from "../../../../ServerVariablesMockBuilder.spec";
import ExpressMock = require("../../../../stubs/express.spec");
import { Level } from "../../../../authentication/Level";

View File

@ -7,11 +7,11 @@ import Redirect from "../../redirect";
import ErrorReplies = require("../../../../ErrorReplies");
import { ServerVariables } from "../../../../ServerVariables";
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { AuthenticationSession } from "../../../../../../types/AuthenticationSession";
import { Level } from "../../../../authentication/Level";
import GetHeader from "../../../../utils/GetHeader";
import * as Constants from "../../../../../../../shared/constants";
import * as Constants from "../../../../constants";
export default function (vars: ServerVariables) {
function handler(req: express.Request, res: express.Response): BluebirdPromise<void> {

View File

@ -4,11 +4,11 @@ import { U2FRegistrationDocument } from "../../../../storage/U2FRegistrationDocu
import exceptions = require("../../../../Exceptions");
import ErrorReplies = require("../../../../ErrorReplies");
import { AuthenticationSessionHandler } from "../../../../AuthenticationSessionHandler";
import UserMessages = require("../../../../../../../shared/UserMessages");
import UserMessages = require("../../../../UserMessages");
import { ServerVariables } from "../../../../ServerVariables";
import { AuthenticationSession } from "../../../../../../types/AuthenticationSession";
import GetHeader from "../../../../utils/GetHeader";
import * as Constants from "../../../../../../../shared/constants";
import * as Constants from "../../../../constants";
export default function (vars: ServerVariables) {
function handler(req: express.Request, res: express.Response): BluebirdPromise<void> {

View File

@ -6,7 +6,7 @@ import { AuthenticationSession } from "../../../../types/AuthenticationSession";
import ExpressMock = require("../../stubs/express.spec");
import { ServerVariables } from "../../ServerVariables";
import { ServerVariablesMockBuilder, ServerVariablesMock } from "../../ServerVariablesMockBuilder.spec";
import { HEADER_X_ORIGINAL_URL } from "../../../../../shared/constants";
import { HEADER_X_ORIGINAL_URL } from "../../constants";
import Get from "./Get";
import { ImportMock } from 'ts-mock-imports';
import * as GetBasicAuth from "./GetBasicAuth";

View File

@ -4,7 +4,7 @@ import ErrorReplies = require("../../ErrorReplies");
import { ServerVariables } from "../../ServerVariables";
import GetSessionCookie from "./GetSessionCookie";
import GetBasicAuth from "./GetBasicAuth";
import Constants = require("../../../../../shared/constants");
import Constants = require("../../constants");
import { AuthenticationSessionHandler }
from "../../AuthenticationSessionHandler";
import { AuthenticationSession }

View File

@ -2,7 +2,7 @@ import * as Express from "express";
import { ServerVariables } from "../../ServerVariables";
import * as ExpressMock from "../../stubs/express.spec";
import { ServerVariablesMockBuilder, ServerVariablesMock } from "../../ServerVariablesMockBuilder.spec";
import { HEADER_X_ORIGINAL_URL } from "../../../../../shared/constants";
import { HEADER_X_ORIGINAL_URL } from "../../constants";
import { Level } from "../../authorization/Level";
import GetBasicAuthModule from "./GetBasicAuth";
import * as CheckAuthorizations from "./CheckAuthorizations";

View File

@ -3,7 +3,7 @@ import { ServerVariables } from "../../ServerVariables";
import { URLDecomposer } from "../../utils/URLDecomposer";
import { Level } from "../../authentication/Level";
import GetHeader from "../../utils/GetHeader";
import { HEADER_PROXY_AUTHORIZATION } from "../../../../../shared/constants";
import { HEADER_PROXY_AUTHORIZATION } from "../../constants";
import setUserAndGroupsHeaders from "./SetUserAndGroupsHeaders";
import CheckAuthorizations from "./CheckAuthorizations";
import RequestUrlGetter from "../../utils/RequestUrlGetter";

View File

@ -1,6 +1,6 @@
import * as ExpressMock from "../../stubs/express.spec";
import * as Assert from "assert";
import { HEADER_REMOTE_USER, HEADER_REMOTE_GROUPS } from "../../../../../shared/constants";
import { HEADER_REMOTE_USER, HEADER_REMOTE_GROUPS } from "../../constants";
import SetUserAndGroupsHeaders from "./SetUserAndGroupsHeaders";
describe("routes/verify/SetUserAndGroupsHeaders", function() {

View File

@ -1,5 +1,5 @@
import * as Express from "express";
import { HEADER_REMOTE_USER, HEADER_REMOTE_GROUPS } from "../../../../../shared/constants";
import { HEADER_REMOTE_USER, HEADER_REMOTE_GROUPS } from "../../constants";
export default function(res: Express.Response, username: string | undefined, groups: string[] | undefined) {
if (username) res.setHeader(HEADER_REMOTE_USER, username);

View File

@ -5,7 +5,7 @@ import { U2FRegistration } from "../../../types/U2FRegistration";
import { TOTPSecret } from "../../../types/TOTPSecret";
import { AuthenticationTraceDocument } from "./AuthenticationTraceDocument";
import { IdentityValidationDocument } from "./IdentityValidationDocument";
import Method2FA from "../../../../shared/Method2FA";
import Method2FA from "../Method2FA";
export interface IUserDataStore {
saveU2FRegistration(userId: string, appId: string, registration: U2FRegistration): BluebirdPromise<void>;

View File

@ -8,7 +8,7 @@ import { U2FRegistration } from "../../../types/U2FRegistration";
import { TOTPSecret } from "../../../types/TOTPSecret";
import { AuthenticationTraceDocument } from "./AuthenticationTraceDocument";
import { IdentityValidationDocument } from "./IdentityValidationDocument";
import Method2FA from "../../../../shared/Method2FA";
import Method2FA from "../Method2FA";
// Constants

View File

@ -8,7 +8,7 @@ import { TOTPSecret } from "../../../types/TOTPSecret";
import { AuthenticationTraceDocument } from "./AuthenticationTraceDocument";
import { IdentityValidationDocument } from "./IdentityValidationDocument";
import { IUserDataStore } from "./IUserDataStore";
import Method2FA from "../../../../shared/Method2FA";
import Method2FA from "../Method2FA";
export class UserDataStoreStub implements IUserDataStore {
saveU2FRegistrationStub: Sinon.SinonStub;

View File

@ -1,7 +1,7 @@
import * as Sinon from "sinon";
import * as Express from "express";
import { GET_VARIABLE_KEY } from "../../../../shared/constants";
import { GET_VARIABLE_KEY } from "../constants";
import { RequestLoggerStub } from "../logging/RequestLoggerStub.spec";
export interface ResponseMock {

View File

@ -1,7 +1,7 @@
import * as Express from "express";
import * as ObjectPath from "object-path";
import { ServerVariables } from "../ServerVariables";
import { GET_VARIABLE_KEY } from "../../../../shared/constants";
import { GET_VARIABLE_KEY } from "../constants";
/**
*

View File

@ -1,4 +1,4 @@
import Constants = require("../../../../shared/constants");
import Constants = require("../constants");
import Express = require("express");
import GetHeader from "./GetHeader";
import HasHeader from "./HasHeader";

View File

@ -25,7 +25,7 @@ import U2FRegisterRequestGet = require("../routes/secondfactor/u2f/register_requ
import ResetPasswordFormPost = require("../routes/password-reset/form/post");
import { ServerVariables } from "../ServerVariables";
import Endpoints = require("../../../../shared/api");
import Endpoints = require("../api");
import { RequireValidatedFirstFactor } from "./middlewares/RequireValidatedFirstFactor";
function setupTotp(app: Express.Application, vars: ServerVariables) {

View File

@ -11,7 +11,6 @@
"paths": {
"*": [
"./types/*",
"../shared/types/*"
]
}
},

View File

@ -1,3 +0,0 @@
import Method2FA from "../client/src/types/Method2FA";
export default Method2FA;

View File

@ -17,7 +17,7 @@ class AutheliaServerWithHotReload implements AutheliaServerInterface {
constructor(configPath: string, watchedPaths: string[]) {
this.configPath = configPath;
const pathsToReload = ['server', 'shared/**/*.ts', 'node_modules',
const pathsToReload = ['server', 'node_modules',
this.AUTHELIA_INTERRUPT_FILENAME, configPath].concat(watchedPaths);
console.log("Authelia will reload on changes of files or directories in " + pathsToReload.join(', '));
this.watcher = Chokidar.watch(pathsToReload, {

View File

@ -1,5 +1,5 @@
import FillLoginPageWithUserAndPasswordAndClick from '../../../helpers/FillLoginPageAndClick';
import {AUTHENTICATION_FAILED} from '../../../../shared/UserMessages';
import {AUTHENTICATION_FAILED} from '../../../../server/src/lib/UserMessages';
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
import { StartDriver, StopDriver } from '../../../helpers/context/WithDriver';

View File

@ -2,7 +2,7 @@ import FillLoginPageWithUserAndPasswordAndClick from '../../../helpers/FillLogin
import ValidateTotp from '../../../helpers/ValidateTotp';
import VerifySecretObserved from "../../../helpers/assertions/VerifySecretObserved";
import LoginAndRegisterTotp from '../../../helpers/LoginAndRegisterTotp';
import { AUTHENTICATION_TOTP_FAILED } from '../../../../shared/UserMessages';
import { AUTHENTICATION_TOTP_FAILED } from '../../../../server/src/lib/UserMessages';
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
import VerifyUrlIs from '../../../helpers/assertions/VerifyUrlIs';