diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-05-02 19:50:07 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-05-02 19:50:07 +0200 |
commit | 5c79256b9b9dff7cfe475f135500637e44c417a6 (patch) | |
tree | 6ed41e2bc268d9106fcef192d0eba68f1921a36a /config | |
parent | a6866fbcabaf75494fd14ed106ff249183e98523 (diff) | |
parent | c7c9f38d01938963a8cdf7f5a3bd12ea53e22e59 (diff) | |
download | gitlab-ce-5c79256b9b9dff7cfe475f135500637e44c417a6.tar.gz |
Merge branch 'master' into 33697-pipelines-json-endpoint
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/session_store.rb | 26 | ||||
-rw-r--r-- | config/initializers/warden.rb | 12 | ||||
-rw-r--r-- | config/karma.config.js | 77 | ||||
-rw-r--r-- | config/routes/profile.rb | 1 | ||||
-rw-r--r-- | config/webpack.config.js | 3 |
5 files changed, 88 insertions, 31 deletions
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index f2fde1e0048..da24881885e 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -15,19 +15,15 @@ cookie_key = if Rails.env.development? "_gitlab_session" end -if Rails.env.test? - Gitlab::Application.config.session_store :cookie_store, key: "_gitlab_session" -else - sessions_config = Gitlab::Redis::SharedState.params - sessions_config[:namespace] = Gitlab::Redis::SharedState::SESSION_NAMESPACE +sessions_config = Gitlab::Redis::SharedState.params +sessions_config[:namespace] = Gitlab::Redis::SharedState::SESSION_NAMESPACE - Gitlab::Application.config.session_store( - :redis_store, # Using the cookie_store would enable session replay attacks. - servers: sessions_config, - key: cookie_key, - secure: Gitlab.config.gitlab.https, - httponly: true, - expires_in: Settings.gitlab['session_expire_delay'] * 60, - path: Rails.application.config.relative_url_root.nil? ? '/' : Gitlab::Application.config.relative_url_root - ) -end +Gitlab::Application.config.session_store( + :redis_store, # Using the cookie_store would enable session replay attacks. + servers: sessions_config, + key: cookie_key, + secure: Gitlab.config.gitlab.https, + httponly: true, + expires_in: Settings.gitlab['session_expire_delay'] * 60, + path: Rails.application.config.relative_url_root.nil? ? '/' : Gitlab::Application.config.relative_url_root +) diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index ee034d21eae..bf079f8e1a7 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -6,4 +6,16 @@ Rails.application.configure do |config| Warden::Manager.before_failure do |env, opts| Gitlab::Auth::BlockedUserTracker.log_if_user_blocked(env) end + + Warden::Manager.after_authentication do |user, auth, opts| + ActiveSession.cleanup(user) + end + + Warden::Manager.after_set_user only: :fetch do |user, auth, opts| + ActiveSession.set(user, auth.request) + end + + Warden::Manager.before_logout do |user, auth, opts| + ActiveSession.destroy(user || auth.user, auth.request.session.id) + end end diff --git a/config/karma.config.js b/config/karma.config.js index 691cda98861..3eb220eed99 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -1,8 +1,16 @@ -var path = require('path'); -var webpack = require('webpack'); -var argumentsParser = require('commander'); -var webpackConfig = require('./webpack.config.js'); -var ROOT_PATH = path.resolve(__dirname, '..'); +const path = require('path'); +const glob = require('glob'); +const chalk = require('chalk'); +const webpack = require('webpack'); +const argumentsParser = require('commander'); +const webpackConfig = require('./webpack.config.js'); + +const ROOT_PATH = path.resolve(__dirname, '..'); + +function fatalError(message) { + console.error(chalk.red(`\nError: ${message}\n`)); + process.exit(1); +} // remove problematic plugins if (webpackConfig.plugins) { @@ -15,33 +23,70 @@ if (webpackConfig.plugins) { }); } -var testFiles = argumentsParser +const specFilters = argumentsParser .option( '-f, --filter-spec [filter]', 'Filter run spec files by path. Multiple filters are like a logical OR.', - (val, memo) => { - memo.push(val); + (filter, memo) => { + memo.push(filter, filter.replace(/\/?$/, '/**/*.js')); return memo; }, [] ) .parse(process.argv).filterSpec; -webpackConfig.plugins.push( - new webpack.DefinePlugin({ - 'process.env.TEST_FILES': JSON.stringify(testFiles), - }) -); +if (specFilters.length) { + const specsPath = /^(?:\.[\\\/])?spec[\\\/]javascripts[\\\/]/; + + // resolve filters + let filteredSpecFiles = specFilters.map(filter => + glob + .sync(filter, { + root: ROOT_PATH, + matchBase: true, + }) + .filter(path => path.endsWith('spec.js')) + ); + + // flatten + filteredSpecFiles = Array.prototype.concat.apply([], filteredSpecFiles); + + // remove duplicates + filteredSpecFiles = [...new Set(filteredSpecFiles)]; + + if (filteredSpecFiles.length < 1) { + fatalError('Your filter did not match any test files.'); + } + + if (!filteredSpecFiles.every(file => specsPath.test(file))) { + fatalError('Test files must be located within /spec/javascripts.'); + } + + const newContext = filteredSpecFiles.reduce((context, file) => { + const relativePath = file.replace(specsPath, ''); + context[file] = `./${relativePath}`; + return context; + }, {}); + + webpackConfig.plugins.push( + new webpack.ContextReplacementPlugin( + /spec[\\\/]javascripts$/, + path.join(ROOT_PATH, 'spec/javascripts'), + newContext + ) + ); +} -webpackConfig.devtool = process.env.BABEL_ENV !== 'coverage' && 'cheap-inline-source-map'; +webpackConfig.entry = undefined; +webpackConfig.devtool = 'cheap-inline-source-map'; // Karma configuration module.exports = function(config) { process.env.TZ = 'Etc/UTC'; - var progressReporter = process.env.CI ? 'mocha' : 'progress'; + const progressReporter = process.env.CI ? 'mocha' : 'progress'; - var karmaConfig = { + const karmaConfig = { basePath: ROOT_PATH, browsers: ['ChromeHeadlessCustom'], customLaunchers: { diff --git a/config/routes/profile.rb b/config/routes/profile.rb index bcfc17a5f66..a9ba5ac2c0b 100644 --- a/config/routes/profile.rb +++ b/config/routes/profile.rb @@ -30,6 +30,7 @@ resource :profile, only: [:show, :update] do put :revoke end end + resources :active_sessions, only: [:index, :destroy] resources :emails, only: [:index, :create, :destroy] do member do put :resend_confirmation_instructions diff --git a/config/webpack.config.js b/config/webpack.config.js index 39e9fbbd530..b9d098ff9b9 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -69,6 +69,9 @@ const config = { test: /\.js$/, exclude: /(node_modules|vendor\/assets)/, loader: 'babel-loader', + options: { + cacheDirectory: path.join(ROOT_PATH, 'tmp/cache/babel-loader'), + }, }, { test: /\.vue$/, |