├── .classpath ├── .editorconfig ├── .gitignore ├── .project ├── .travis.yml ├── Procfile ├── README.md ├── pom.xml ├── src ├── main │ ├── frontend │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── README.md │ │ ├── build │ │ │ ├── build.js │ │ │ ├── check-versions.js │ │ │ ├── dev-client.js │ │ │ ├── dev-server.js │ │ │ ├── utils.js │ │ │ ├── vue-loader.conf.js │ │ │ ├── webpack.base.conf.js │ │ │ ├── webpack.dev.conf.js │ │ │ ├── webpack.prod.conf.js │ │ │ └── webpack.test.conf.js │ │ ├── config │ │ │ ├── dev.env.js │ │ │ ├── index.js │ │ │ ├── prod.env.js │ │ │ └── test.env.js │ │ ├── index.html │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── assets │ │ │ │ └── logo.png │ │ │ ├── backend │ │ │ │ └── vue-axios │ │ │ │ │ ├── axios.js │ │ │ │ │ └── index.js │ │ │ ├── components │ │ │ │ ├── Hello.vue │ │ │ │ ├── Home.vue │ │ │ │ ├── Login.vue │ │ │ │ ├── Logout.vue │ │ │ │ └── Navbar.vue │ │ │ ├── main.js │ │ │ ├── models │ │ │ │ └── User.js │ │ │ ├── router │ │ │ │ └── index.js │ │ │ ├── store │ │ │ │ ├── auth.js │ │ │ │ ├── index.js │ │ │ │ └── mutation-types.js │ │ │ └── utils │ │ │ │ ├── eventbus.js │ │ │ │ └── remove.js │ │ ├── static │ │ │ └── .gitkeep │ │ └── test │ │ │ └── unit │ │ │ ├── .eslintrc │ │ │ ├── index.js │ │ │ ├── karma.conf.js │ │ │ └── specs │ │ │ └── Hello.spec.js │ ├── java │ │ ├── .gitkeep │ │ └── backend │ │ │ ├── MainVerticle.java │ │ │ ├── ResponseUtil.java │ │ │ ├── SecurityConfig.java │ │ │ └── SockJSBridge.java │ └── resources │ │ └── .gitkeep └── test │ ├── java │ ├── .gitkeep │ └── web │ │ ├── AbstractIntegrationTest.java │ │ └── AbstractIsolatedIntegrationTest.java │ └── resources │ └── .gitkeep ├── test.jks └── vert.x.launch /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.{vue,js,json,html,yml,python}] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.{java,scala}] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse conf file 2 | .settings 3 | .manager 4 | .scala_dependencies 5 | 6 | # idea 7 | .idea 8 | *.iml 9 | 10 | # building 11 | *.class 12 | target 13 | null 14 | tmp* 15 | temp 16 | dist 17 | test-output 18 | build.log 19 | 20 | # other scm 21 | .svn 22 | .CVS 23 | .hg* 24 | 25 | #OSX 26 | target/ 27 | Safari*OLD* 28 | .DS_Store 29 | .metadata 30 | Icon? 31 | 32 | #other 33 | */bin/ 34 | *~ 35 | *.bak 36 | #*.off 37 | *.old 38 | .cache* 39 | *.iml 40 | *.ipr 41 | *.iws 42 | *.prefs 43 | *.db 44 | *.tmproj 45 | *.vertx 46 | src/main/frontend/node_modules 47 | src/main/frontend/node-debug.log 48 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | vertx-vue-keycloak 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | install: mvn clean package -Pfrontend -DskipTests=true 5 | cache: 6 | directories: 7 | - $HOME/.m2 8 | - src/main/frontend/node_modules 9 | deploy: 10 | provider: heroku 11 | api_key: 12 | secure: i4etqyoe27UuYhOGsxj3vrkEYrM7ya03USEo5G4EbgwcVwSULQAwzX6ndLzwaNJ2UHcImmIm9FO6OVR5QS+tRiM2HUo2GsiZ2ittoafjlDfryF+yT7vMpHn2ijQGdFEieUSKmQL+u7VMaWwVUld6Nso6qc5PO9/G7dj1jTF8lQ8NW5jyahkzH3I17bVvsR53NRNMdIZ9oiFcoA3RJB4UxqXnQL/2DqVhR4nBaxO+PtGd6NlYdLINZTVSnQch73SOz5UM8HkI2DLsJuLy8U1zyPR/ZD0B9SE3FqGNLiYAatMHW+7OHu5qJ5DZyDiyE7qh9kZfrNHSn3ovsffU3CXYq8oJjYSlyaOKB5fDy6doLbcjkNPuSyUPDLyfYFVvWONmwudC41yzjVjarayIhiloW57qoLDr0DkXytGCwlHIePRebWjgohzUUX3F+ZeeDSx5Tf3me28OtbmrdKEZfm8Jiq6wicdxbVNjG53N1cWt/2bGp+dynuhj86XS2/Fa1r/q2vNYIxnnuKlheGSQzVtU8krCrHAmV9O2fbGR1aDx4egJKs56FsUPKt/5s/pqQ2shT3jqNqnB4q3YWjCCZzYi8QilbgoFaGBMC6aZzw9L2bY3TO2I2C3zklJr9ulLF5XtPh1FDkvmwRQjewYYHdvBoa0KZsbOauZLrWG2X1whIvA= 13 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Vert.x + VueJS + OAuth2 in 5 steps 3 | This repo holds the source codes for the Medium Article **Vert.x + VueJS + OAuth2 in 5 steps**: 4 | https://medium.com/@thomas.reinecke/vert-x-vuejs-oauth2-in-5-steps-c04ee78475b7 5 | 6 | # Dev env setup 7 | * clone the project 8 | * open eclipse, create a new workspace wherever you want it and import vertx-vue-keycloak as Maven project 9 | * follow Step-1 PrepWork on the article, set up a docker based Keycloak image and configure keycloak 10 | * start the vert.x based backend in eclipse with the provided **vert.x** starter 11 | * on a dedicated cmd, go to /src/main/frontend 12 | * install the frontend dependencies and run the frontend (see details on https://github.com/vertx-stack/vertx-vue-keycloak/tree/master/src/main/frontend) 13 | 14 | Enjoy! 15 | 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.github.parzonka 5 | vertx-examples 6 | 0.0.1-SNAPSHOT 7 | jar 8 | vertx-examples 9 | 10 | UTF-8 11 | 1.8 12 | web.MainVerticle 13 | 14 | 4.13.1 15 | 1.16.10 16 | 3.5.4 17 | 18 | 19 | 20 | org.projectlombok 21 | lombok 22 | ${projectlombok.version} 23 | provided 24 | 25 | 26 | io.vertx 27 | vertx-core 28 | ${vertx.version} 29 | 30 | 31 | io.vertx 32 | vertx-web 33 | ${vertx.version} 34 | 35 | 36 | io.vertx 37 | vertx-auth-oauth2 38 | ${vertx.version} 39 | 40 | 41 | junit 42 | junit 43 | ${junit.version} 44 | test 45 | 46 | 47 | io.vertx 48 | vertx-unit 49 | ${vertx.version} 50 | test 51 | 52 | 53 | 54 | 55 | 56 | maven-compiler-plugin 57 | 3.5.1 58 | 59 | ${java.version} 60 | ${java.version} 61 | 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-surefire-plugin 66 | 2.19.1 67 | 68 | 69 | **/Abstract*.java 70 | 71 | 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-shade-plugin 76 | 2.4.3 77 | 78 | 79 | package 80 | 81 | shade 82 | 83 | 84 | 85 | 87 | 88 | io.vertx.core.Launcher 89 | ${main.verticle} 90 | 91 | 92 | 94 | META-INF/services/io.vertx.core.spi.VerticleFactory 95 | 96 | 97 | 98 | 99 | ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar 100 | 101 | 102 | 103 | 104 | 105 | org.codehaus.mojo 106 | exec-maven-plugin 107 | 1.5.0 108 | 109 | 110 | 111 | run-app 112 | 113 | exec 114 | 115 | 116 | java 117 | 118 | io.vertx.core.Launcher 119 | 120 | run 121 | ${main.verticle} 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | com.versioneye 130 | versioneye-maven-plugin 131 | 3.11.0 132 | 133 | 56d1b132157a69002ea956ed 134 | 135 | 136 | 137 | 138 | 139 | 140 | frontend 141 | 142 | 143 | 144 | com.github.eirslett 145 | frontend-maven-plugin 146 | 1.1 147 | 148 | ${basedir}/src/main/frontend 149 | target 150 | 151 | 152 | 153 | install node and npm 154 | 155 | install-node-and-npm 156 | 157 | 158 | v6.9.1 159 | 3.10.8 160 | 161 | 162 | 163 | npm install 164 | 165 | npm 166 | 167 | 168 | install 169 | 170 | 171 | 172 | npm build 173 | 174 | npm 175 | 176 | 177 | ${basedir}/src/main/frontend 178 | run build 179 | 180 | 181 | 182 | 183 | 184 | maven-resources-plugin 185 | 3.0.1 186 | 187 | 188 | copy-frontend-dist 189 | process-resources 190 | 191 | copy-resources 192 | 193 | 194 | ${basedir}/target/classes/webroot 195 | 196 | 197 | ${basedir}/src/main/frontend/dist 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /src/main/frontend/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["istanbul"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /src/main/frontend/.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /src/main/frontend/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | // allow paren-less arrow functions 21 | 'arrow-parens': 0, 22 | // allow async-await 23 | 'generator-star-spacing': 0, 24 | // allow debugger during development 25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | test/unit/coverage 8 | 9 | # Editor directories and files 10 | .idea 11 | *.suo 12 | *.ntvs* 13 | *.njsproj 14 | *.sln 15 | -------------------------------------------------------------------------------- /src/main/frontend/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserslist" field in package.json 6 | "autoprefixer": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/frontend/README.md: -------------------------------------------------------------------------------- 1 | # vertx-vue-keycloak frontend 2 | 3 | > Frontend for https://github.com/vertx-stack/vertx-vue-keycloak app, built for the medium article https://medium.com/@thomas.reinecke/vert-x-vuejs-oauth2-in-5-steps-c04ee78475b7 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install, or yarn 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev, or yarn dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run all tests 24 | npm test 25 | ``` 26 | 27 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 28 | -------------------------------------------------------------------------------- /src/main/frontend/build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | if (stats.hasErrors()) { 30 | console.log(chalk.red(' Build failed with errors.\n')) 31 | process.exit(1) 32 | } 33 | 34 | console.log(chalk.cyan(' Build complete.\n')) 35 | console.log(chalk.yellow( 36 | ' Tip: built files are meant to be served over an HTTP server.\n' + 37 | ' Opening index.html over file:// won\'t work.\n' 38 | )) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /src/main/frontend/build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | var shell = require('shelljs') 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | } 15 | ] 16 | 17 | if (shell.which('npm')) { 18 | versionRequirements.push({ 19 | name: 'npm', 20 | currentVersion: exec('npm --version'), 21 | versionRequirement: packageConfig.engines.npm 22 | }) 23 | } 24 | 25 | module.exports = function () { 26 | var warnings = [] 27 | for (var i = 0; i < versionRequirements.length; i++) { 28 | var mod = versionRequirements[i] 29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 30 | warnings.push(mod.name + ': ' + 31 | chalk.red(mod.currentVersion) + ' should be ' + 32 | chalk.green(mod.versionRequirement) 33 | ) 34 | } 35 | } 36 | 37 | if (warnings.length) { 38 | console.log('') 39 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 40 | console.log() 41 | for (var i = 0; i < warnings.length; i++) { 42 | var warning = warnings[i] 43 | console.log(' ' + warning) 44 | } 45 | console.log() 46 | process.exit(1) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/frontend/build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /src/main/frontend/build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = (process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production') 14 | ? require('./webpack.prod.conf') 15 | : require('./webpack.dev.conf') 16 | 17 | // default port where dev server listens for incoming traffic 18 | var port = process.env.PORT || config.dev.port 19 | // automatically open browser, if not set will be false 20 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 21 | // Define HTTP proxies to your custom API backend 22 | // https://github.com/chimurai/http-proxy-middleware 23 | var proxyTable = config.dev.proxyTable 24 | 25 | var app = express() 26 | var compiler = webpack(webpackConfig) 27 | 28 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 29 | publicPath: webpackConfig.output.publicPath, 30 | quiet: true 31 | }) 32 | 33 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 34 | log: false, 35 | heartbeat: 2000 36 | }) 37 | // force page reload when html-webpack-plugin template changes 38 | compiler.plugin('compilation', function (compilation) { 39 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 40 | hotMiddleware.publish({ action: 'reload' }) 41 | cb() 42 | }) 43 | }) 44 | 45 | // proxy api requests 46 | Object.keys(proxyTable).forEach(function (context) { 47 | var options = proxyTable[context] 48 | if (typeof options === 'string') { 49 | options = { target: options } 50 | } 51 | app.use(proxyMiddleware(options.filter || context, options)) 52 | }) 53 | 54 | // handle fallback for HTML5 history API 55 | app.use(require('connect-history-api-fallback')()) 56 | 57 | // serve webpack bundle output 58 | app.use(devMiddleware) 59 | 60 | // enable hot-reload and state-preserving 61 | // compilation error display 62 | app.use(hotMiddleware) 63 | 64 | // serve pure static assets 65 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 66 | app.use(staticPath, express.static('./static')) 67 | 68 | var uri = 'http://localhost:' + port 69 | 70 | var _resolve 71 | var readyPromise = new Promise(resolve => { 72 | _resolve = resolve 73 | }) 74 | 75 | console.log('> Starting dev server...') 76 | devMiddleware.waitUntilValid(() => { 77 | console.log('> Listening at ' + uri + '\n') 78 | // when env is testing, don't need open it 79 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 80 | opn(uri) 81 | } 82 | _resolve() 83 | }) 84 | 85 | var server = app.listen(port) 86 | 87 | module.exports = { 88 | ready: readyPromise, 89 | close: () => { 90 | server.close() 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/frontend/build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | // generate loader string to be used with extract text plugin 24 | function generateLoaders (loader, loaderOptions) { 25 | var loaders = [cssLoader] 26 | if (loader) { 27 | loaders.push({ 28 | loader: loader + '-loader', 29 | options: Object.assign({}, loaderOptions, { 30 | sourceMap: options.sourceMap 31 | }) 32 | }) 33 | } 34 | 35 | // Extract CSS when that option is specified 36 | // (which is the case during production build) 37 | if (options.extract) { 38 | return ExtractTextPlugin.extract({ 39 | use: loaders, 40 | fallback: 'vue-style-loader' 41 | }) 42 | } else { 43 | return ['vue-style-loader'].concat(loaders) 44 | } 45 | } 46 | 47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 48 | return { 49 | css: generateLoaders(), 50 | postcss: generateLoaders(), 51 | less: generateLoaders('less'), 52 | sass: generateLoaders('sass', { indentedSyntax: true }), 53 | scss: generateLoaders('sass'), 54 | stylus: generateLoaders('stylus'), 55 | styl: generateLoaders('stylus') 56 | } 57 | } 58 | 59 | // Generate loaders for standalone style files (outside of .vue) 60 | exports.styleLoaders = function (options) { 61 | var output = [] 62 | var loaders = exports.cssLoaders(options) 63 | for (var extension in loaders) { 64 | var loader = loaders[extension] 65 | output.push({ 66 | test: new RegExp('\\.' + extension + '$'), 67 | use: loader 68 | }) 69 | } 70 | return output 71 | } 72 | -------------------------------------------------------------------------------- /src/main/frontend/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }), 12 | transformToRequire: { 13 | video: 'src', 14 | source: 'src', 15 | img: 'src', 16 | image: 'xlink:href' 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/frontend/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve (dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | app: './src/main.js' 13 | }, 14 | output: { 15 | path: config.build.assetsRoot, 16 | filename: '[name].js', 17 | publicPath: process.env.NODE_ENV === 'production' 18 | ? config.build.assetsPublicPath 19 | : config.dev.assetsPublicPath 20 | }, 21 | resolve: { 22 | extensions: ['.js', '.vue', '.json'], 23 | alias: { 24 | 'vue$': 'vue/dist/vue.esm.js', 25 | '@': resolve('src') 26 | } 27 | }, 28 | module: { 29 | rules: [ 30 | // { 31 | // test: /\.(js|vue)$/, 32 | // loader: 'eslint-loader', 33 | // enforce: 'pre', 34 | // include: [resolve('src'), resolve('test')], 35 | // options: { 36 | // formatter: require('eslint-friendly-formatter') 37 | // } 38 | // }, 39 | { 40 | test: /\.vue$/, 41 | loader: 'vue-loader', 42 | options: vueLoaderConfig 43 | }, 44 | { 45 | test: /\.js$/, 46 | loader: 'babel-loader', 47 | include: [resolve('src'), resolve('test')] 48 | }, 49 | { 50 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 51 | loader: 'url-loader', 52 | options: { 53 | limit: 10000, 54 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 55 | } 56 | }, 57 | { 58 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 59 | loader: 'url-loader', 60 | options: { 61 | limit: 10000, 62 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 63 | } 64 | }, 65 | { 66 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 67 | loader: 'url-loader', 68 | options: { 69 | limit: 10000, 70 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 71 | } 72 | }, 73 | { 74 | test: /\.s[a|c]ss$/, 75 | loader: 'style!css!sass' 76 | } 77 | ] 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/frontend/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | filename: 'index.html', 30 | template: 'index.html', 31 | inject: true 32 | }), 33 | new FriendlyErrorsPlugin() 34 | ] 35 | }) 36 | -------------------------------------------------------------------------------- /src/main/frontend/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var CopyWebpackPlugin = require('copy-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 11 | 12 | var env = process.env.NODE_ENV === 'testing' 13 | ? require('../config/test.env') 14 | : config.build.env 15 | 16 | var webpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ 19 | sourceMap: config.build.productionSourceMap, 20 | extract: true 21 | }) 22 | }, 23 | devtool: config.build.productionSourceMap ? '#source-map' : false, 24 | output: { 25 | path: config.build.assetsRoot, 26 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 27 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 28 | }, 29 | plugins: [ 30 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 31 | new webpack.DefinePlugin({ 32 | 'process.env': env 33 | }), 34 | new webpack.optimize.UglifyJsPlugin({ 35 | compress: { 36 | warnings: false 37 | }, 38 | sourceMap: true 39 | }), 40 | // extract css into its own file 41 | new ExtractTextPlugin({ 42 | filename: utils.assetsPath('css/[name].[contenthash].css') 43 | }), 44 | // Compress extracted CSS. We are using this plugin so that possible 45 | // duplicated CSS from different components can be deduped. 46 | new OptimizeCSSPlugin({ 47 | cssProcessorOptions: { 48 | safe: true 49 | } 50 | }), 51 | // generate dist index.html with correct asset hash for caching. 52 | // you can customize output by editing /index.html 53 | // see https://github.com/ampedandwired/html-webpack-plugin 54 | new HtmlWebpackPlugin({ 55 | filename: process.env.NODE_ENV === 'testing' 56 | ? 'index.html' 57 | : config.build.index, 58 | template: 'index.html', 59 | inject: true, 60 | minify: { 61 | removeComments: true, 62 | collapseWhitespace: true, 63 | removeAttributeQuotes: true 64 | // more options: 65 | // https://github.com/kangax/html-minifier#options-quick-reference 66 | }, 67 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 68 | chunksSortMode: 'dependency' 69 | }), 70 | // keep module.id stable when vender modules does not change 71 | new webpack.HashedModuleIdsPlugin(), 72 | // split vendor js into its own file 73 | new webpack.optimize.CommonsChunkPlugin({ 74 | name: 'vendor', 75 | minChunks: function (module, count) { 76 | // any required modules inside node_modules are extracted to vendor 77 | return ( 78 | module.resource && 79 | /\.js$/.test(module.resource) && 80 | module.resource.indexOf( 81 | path.join(__dirname, '../node_modules') 82 | ) === 0 83 | ) 84 | } 85 | }), 86 | // extract webpack runtime and module manifest to its own file in order to 87 | // prevent vendor hash from being updated whenever app bundle is updated 88 | new webpack.optimize.CommonsChunkPlugin({ 89 | name: 'manifest', 90 | chunks: ['vendor'] 91 | }), 92 | // copy custom static assets 93 | new CopyWebpackPlugin([ 94 | { 95 | from: path.resolve(__dirname, '../static'), 96 | to: config.build.assetsSubDirectory, 97 | ignore: ['.*'] 98 | } 99 | ]) 100 | ] 101 | }) 102 | 103 | if (config.build.productionGzip) { 104 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 105 | 106 | webpackConfig.plugins.push( 107 | new CompressionWebpackPlugin({ 108 | asset: '[path].gz[query]', 109 | algorithm: 'gzip', 110 | test: new RegExp( 111 | '\\.(' + 112 | config.build.productionGzipExtensions.join('|') + 113 | ')$' 114 | ), 115 | threshold: 10240, 116 | minRatio: 0.8 117 | }) 118 | ) 119 | } 120 | 121 | if (config.build.bundleAnalyzerReport) { 122 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 123 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 124 | } 125 | 126 | module.exports = webpackConfig 127 | -------------------------------------------------------------------------------- /src/main/frontend/build/webpack.test.conf.js: -------------------------------------------------------------------------------- 1 | // This is the webpack config used for unit tests. 2 | 3 | var utils = require('./utils') 4 | var webpack = require('webpack') 5 | var merge = require('webpack-merge') 6 | var baseConfig = require('./webpack.base.conf') 7 | 8 | var webpackConfig = merge(baseConfig, { 9 | // use inline sourcemap for karma-sourcemap-loader 10 | module: { 11 | rules: utils.styleLoaders() 12 | }, 13 | devtool: '#inline-source-map', 14 | resolveLoader: { 15 | alias: { 16 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option 17 | // see discussion at https://github.com/vuejs/vue-loader/issues/724 18 | 'scss-loader': 'sass-loader' 19 | } 20 | }, 21 | plugins: [ 22 | new webpack.DefinePlugin({ 23 | 'process.env': require('../config/test.env') 24 | }) 25 | ] 26 | }) 27 | 28 | // no need for app entry during tests 29 | delete webpackConfig.entry 30 | 31 | module.exports = webpackConfig 32 | -------------------------------------------------------------------------------- /src/main/frontend/config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /src/main/frontend/config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8081, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/frontend/config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | API_URL: '"http://localhost:8080"', 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /src/main/frontend/config/test.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var devEnv = require('./dev.env') 3 | 4 | module.exports = merge(devEnv, { 5 | NODE_ENV: '"testing"' 6 | }) 7 | -------------------------------------------------------------------------------- /src/main/frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | frontend 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/frontend/package-lock.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/main/frontend/package-lock.json -------------------------------------------------------------------------------- /src/main/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "node build/dev-server.js", 7 | "start": "node build/dev-server.js", 8 | "build": "node build/build.js", 9 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", 10 | "test": "npm run unit", 11 | "lint": "eslint --ext .js,.vue src test/unit/specs", 12 | "release": "npm run build && npm run deploy" 13 | }, 14 | "dependencies": { 15 | "axios": "^0.16.2", 16 | "font-awesome": "^4.7.0", 17 | "font-awesome-webpack": "^0.0.5-beta.2", 18 | "jwt-decode": "^2.2.0", 19 | "less": "^3.8.1", 20 | "vertx3-eventbus-client": "^3.5.4", 21 | "vue": "^2.4.2", 22 | "vue-axios": "^2.0.2", 23 | "vue-router": "^2.7.0", 24 | "vuex": "^3.0.0" 25 | }, 26 | "devDependencies": { 27 | "autoprefixer": "^7.1.2", 28 | "babel-core": "^6.22.1", 29 | "babel-eslint": "^7.1.1", 30 | "babel-loader": "^7.1.1", 31 | "babel-plugin-istanbul": "^4.1.1", 32 | "babel-plugin-transform-runtime": "^6.22.0", 33 | "babel-preset-env": "^1.3.2", 34 | "babel-preset-stage-2": "^6.22.0", 35 | "babel-register": "^6.22.0", 36 | "chai": "^3.5.0", 37 | "chalk": "^2.0.1", 38 | "connect-history-api-fallback": "^1.3.0", 39 | "copy-webpack-plugin": "^4.0.1", 40 | "cross-env": "^5.0.1", 41 | "css-loader": "^0.28.0", 42 | "cssnano": "^3.10.0", 43 | "eslint": "^3.19.0", 44 | "eslint-config-standard": "^6.2.1", 45 | "eslint-friendly-formatter": "^3.0.0", 46 | "eslint-loader": "^1.7.1", 47 | "eslint-plugin-html": "^3.0.0", 48 | "eslint-plugin-promise": "^3.4.0", 49 | "eslint-plugin-standard": "^2.0.1", 50 | "eventsource-polyfill": "^0.9.6", 51 | "express": "^4.14.1", 52 | "extract-text-webpack-plugin": "^2.0.0", 53 | "file-loader": "^0.11.1", 54 | "friendly-errors-webpack-plugin": "^1.1.3", 55 | "html-webpack-plugin": "^2.28.0", 56 | "http-proxy-middleware": "^0.17.3", 57 | "inject-loader": "^3.0.0", 58 | "karma": "^1.4.1", 59 | "karma-coverage": "^1.1.1", 60 | "karma-mocha": "^1.3.0", 61 | "karma-phantomjs-launcher": "^1.0.2", 62 | "karma-phantomjs-shim": "^1.4.0", 63 | "karma-sinon-chai": "^1.3.1", 64 | "karma-sourcemap-loader": "^0.3.7", 65 | "karma-spec-reporter": "0.0.31", 66 | "karma-webpack": "^2.0.2", 67 | "mocha": "^3.2.0", 68 | "node-sass": "^4.5.3", 69 | "opn": "^5.1.0", 70 | "optimize-css-assets-webpack-plugin": "^2.0.0", 71 | "ora": "^1.2.0", 72 | "phantomjs-prebuilt": "^2.1.14", 73 | "rimraf": "^2.6.0", 74 | "s3-deploy": "^0.10.0", 75 | "sass-loader": "^6.0.6", 76 | "semver": "^5.3.0", 77 | "shelljs": "^0.7.6", 78 | "sinon": "^2.1.0", 79 | "sinon-chai": "^2.8.0", 80 | "style-loader": "^0.19.0", 81 | "url-loader": "^0.5.8", 82 | "vue-loader": "^13.0.4", 83 | "vue-style-loader": "^3.0.1", 84 | "vue-template-compiler": "^2.4.2", 85 | "webpack": "^2.6.1", 86 | "webpack-bundle-analyzer": "^2.2.1", 87 | "webpack-dev-middleware": "^1.10.0", 88 | "webpack-hot-middleware": "^2.18.0", 89 | "webpack-merge": "^4.1.0" 90 | }, 91 | "engines": { 92 | "node": ">= 4.0.0", 93 | "npm": ">= 3.0.0" 94 | }, 95 | "browserslist": [ 96 | "> 1%", 97 | "last 2 versions", 98 | "not ie <= 8" 99 | ] 100 | } 101 | -------------------------------------------------------------------------------- /src/main/frontend/src/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 46 | 47 | 52 | -------------------------------------------------------------------------------- /src/main/frontend/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/main/frontend/src/assets/logo.png -------------------------------------------------------------------------------- /src/main/frontend/src/backend/vue-axios/axios.js: -------------------------------------------------------------------------------- 1 | /* global localStorage */ 2 | 3 | import axios from 'axios' 4 | 5 | const API_URL = process.env.API_URL || 'http://localhost:8080/api/v1' 6 | 7 | export default axios.create({ 8 | baseURL: API_URL, 9 | headers: { 10 | 'Content-Type': 'application/json', 11 | 'Authorization': 'Bearer ' + localStorage.token 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /src/main/frontend/src/backend/vue-axios/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueAxios from 'vue-axios' 3 | 4 | import axios from './axios' 5 | 6 | Vue.use(VueAxios, axios) 7 | -------------------------------------------------------------------------------- /src/main/frontend/src/components/Hello.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ msg }} 4 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 39 | -------------------------------------------------------------------------------- /src/main/frontend/src/components/Home.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Message Wall 5 | Connected users: {{connectionCount}} 6 | 7 | 8 | 9 | 10 | 11 | Send 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {{message.content}} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 83 | 84 | 119 | -------------------------------------------------------------------------------- /src/main/frontend/src/components/Login.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Please sign in 6 | {{ error }} 7 | Email address 8 | 9 | Password 10 | 11 | Sign in 12 | 13 | 14 | 15 | 16 | 17 | 68 | 69 | -------------------------------------------------------------------------------- /src/main/frontend/src/components/Logout.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /src/main/frontend/src/components/Navbar.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Your App 4 | 5 | {{ currentUser.email }} 6 | Logout 7 | 8 | 9 | 10 | 11 | 21 | 22 | 38 | -------------------------------------------------------------------------------- /src/main/frontend/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import axios from './backend/vue-axios' 7 | import store from './store' 8 | import 'font-awesome-webpack' 9 | 10 | Vue.config.productionTip = false 11 | 12 | /* eslint-disable no-new */ 13 | new Vue({ 14 | el: '#app', 15 | router, 16 | axios, 17 | store, 18 | template: '', 19 | components: { App } 20 | }) 21 | -------------------------------------------------------------------------------- /src/main/frontend/src/models/User.js: -------------------------------------------------------------------------------- 1 | import JwtDecode from 'jwt-decode' 2 | 3 | export default class User { 4 | static from (token) { 5 | try { 6 | let obj = JwtDecode(token) 7 | return new User(obj) 8 | } catch (_) { 9 | return null 10 | } 11 | } 12 | 13 | constructor ({ user_id, admin, email }) { 14 | this.id = user_id // eslint-disable-line camelcase 15 | this.admin = admin 16 | this.email = email 17 | } 18 | 19 | get isAdmin () { 20 | return this.admin 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/frontend/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Login from '@/components/Login' 4 | import Logout from '@/components/Logout' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | mode: 'history', 10 | routes: [ 11 | { 12 | path: '/', 13 | name: 'Login', 14 | component: Login 15 | }, 16 | { 17 | path: '/logout', 18 | name: 'Logout', 19 | component: Logout 20 | } 21 | ] 22 | }) 23 | -------------------------------------------------------------------------------- /src/main/frontend/src/store/auth.js: -------------------------------------------------------------------------------- 1 | /* global localStorage */ 2 | 3 | import User from '@/models/User' 4 | import * as MutationTypes from './mutation-types' 5 | 6 | const state = { 7 | user: User.from(localStorage.token) 8 | } 9 | 10 | const mutations = { 11 | [MutationTypes.LOGIN] (state) { 12 | state.user = User.from(localStorage.token) 13 | }, 14 | [MutationTypes.LOGOUT] (state) { 15 | state.user = null 16 | } 17 | } 18 | 19 | const getters = { 20 | currentUser (state) { 21 | return state.user 22 | } 23 | } 24 | 25 | const actions = { 26 | login ({ commit }) { 27 | commit(MutationTypes.LOGIN) 28 | }, 29 | 30 | logout ({ commit }) { 31 | commit(MutationTypes.LOGOUT) 32 | } 33 | } 34 | 35 | export default { 36 | state, 37 | mutations, 38 | getters, 39 | actions 40 | } 41 | -------------------------------------------------------------------------------- /src/main/frontend/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | import auth from './auth' 5 | 6 | Vue.use(Vuex) 7 | 8 | export default new Vuex.Store({ 9 | modules: { 10 | auth 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /src/main/frontend/src/store/mutation-types.js: -------------------------------------------------------------------------------- 1 | export const LOGIN = 'LOGIN' 2 | export const LOGOUT = 'LOGOUT' 3 | -------------------------------------------------------------------------------- /src/main/frontend/src/utils/eventbus.js: -------------------------------------------------------------------------------- 1 | import EventBus from 'vertx3-eventbus-client' 2 | 3 | const API_URL = process.env.API_URL + '/eventbus' || 'http://localhost:8080/eventbus' 4 | const eventbus = new EventBus(API_URL) 5 | 6 | export default { 7 | callApi (api, inputObject) { 8 | return new Promise((resolve, reject) => { 9 | console.log('calling vertx API ', api) 10 | eventbus.send(api, inputObject, function (response, json) { 11 | resolve(json.body) 12 | }) 13 | }) 14 | }, 15 | subscribe (api, bodyHandler) { 16 | eventbus.registerHandler(api, function (err, msg) { 17 | if (err) { 18 | console.log('SockJS/EventBus error: ', err) 19 | } else { 20 | bodyHandler(msg.body) 21 | } 22 | }) 23 | } 24 | } 25 | 26 | eventbus.onopen = function () { 27 | this.isConnected = true 28 | console.log('EventBus is now connected') 29 | } 30 | 31 | eventbus.onerror = function (e) { 32 | console.log('General error: ', e) 33 | } 34 | -------------------------------------------------------------------------------- /src/main/frontend/src/utils/remove.js: -------------------------------------------------------------------------------- 1 | // removes each item in vue data satisfying predicate 2 | function remove (data, predicate) { 3 | data.forEach(function (item) { 4 | if (predicate(item)) { 5 | data.$remove(item) 6 | } 7 | }) 8 | } 9 | 10 | export { remove } 11 | -------------------------------------------------------------------------------- /src/main/frontend/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/main/frontend/static/.gitkeep -------------------------------------------------------------------------------- /src/main/frontend/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true, 7 | "sinon": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/frontend/test/unit/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context('./specs', true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /src/main/frontend/test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | // This is a karma config file. For more details see 2 | // http://karma-runner.github.io/0.13/config/configuration-file.html 3 | // we are also using it with karma-webpack 4 | // https://github.com/webpack/karma-webpack 5 | 6 | var webpackConfig = require('../../build/webpack.test.conf') 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | // to run in additional browsers: 11 | // 1. install corresponding karma launcher 12 | // http://karma-runner.github.io/0.13/config/browsers.html 13 | // 2. add it to the `browsers` array below. 14 | browsers: ['PhantomJS'], 15 | frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'], 16 | reporters: ['spec', 'coverage'], 17 | files: ['./index.js'], 18 | preprocessors: { 19 | './index.js': ['webpack', 'sourcemap'] 20 | }, 21 | webpack: webpackConfig, 22 | webpackMiddleware: { 23 | noInfo: true 24 | }, 25 | coverageReporter: { 26 | dir: './coverage', 27 | reporters: [ 28 | { type: 'lcov', subdir: '.' }, 29 | { type: 'text-summary' } 30 | ] 31 | } 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /src/main/frontend/test/unit/specs/Hello.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Hello from '@/components/Hello' 3 | 4 | describe('Hello.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(Hello) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .to.equal('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/main/java/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/main/java/.gitkeep -------------------------------------------------------------------------------- /src/main/java/backend/MainVerticle.java: -------------------------------------------------------------------------------- 1 | package backend; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | 6 | import io.netty.handler.codec.http.HttpResponseStatus; 7 | import io.vertx.core.AbstractVerticle; 8 | import io.vertx.core.Future; 9 | import io.vertx.core.eventbus.Message; 10 | import io.vertx.core.http.HttpServerOptions; 11 | import io.vertx.core.json.JsonArray; 12 | import io.vertx.core.json.JsonObject; 13 | import io.vertx.core.net.JksOptions; 14 | import io.vertx.ext.auth.User; 15 | import io.vertx.ext.auth.oauth2.OAuth2Auth; 16 | import io.vertx.ext.auth.oauth2.OAuth2FlowType; 17 | import io.vertx.ext.auth.oauth2.providers.KeycloakAuth; 18 | import io.vertx.ext.web.Router; 19 | import io.vertx.ext.web.handler.BodyHandler; 20 | import io.vertx.ext.web.handler.CorsHandler; 21 | import io.vertx.ext.web.handler.StaticHandler; 22 | 23 | public class MainVerticle extends AbstractVerticle { 24 | 25 | // configuration for HTTP server 26 | private JsonObject httpServer = new JsonObject() 27 | .put("hostname", "0.0.0.0") 28 | .put("port", 8080); 29 | 30 | // configuration for HTTPS server 31 | private JsonObject httpsServer = new JsonObject() 32 | .put("hostname", "0.0.0.0") 33 | .put("port", 4443) 34 | .put("keyStore", "test.jks") 35 | .put("enforceRedirect", false); 36 | 37 | private JsonArray messages = new JsonArray() 38 | .add(new JsonObject().put("content", "blabla")) 39 | .add(new JsonObject().put("content", "here's a second message")) 40 | .add(new JsonObject().put("content", "one more")); 41 | 42 | @Override 43 | public void start(Future startFuture) { 44 | createHttpServerAndRoutes(); 45 | createApiEndpoints(); 46 | } 47 | 48 | 49 | @Override 50 | public void stop() throws Exception { 51 | super.stop(); 52 | } 53 | 54 | 55 | private void createHttpServerAndRoutes() { 56 | Router router = Router.router(vertx); 57 | 58 | // create HTTP server 59 | HttpServerOptions httpOptions = new HttpServerOptions(); 60 | httpOptions.setHost(httpServer.getString("hostname")); 61 | httpOptions.setPort(httpServer.getInteger("port")); 62 | httpOptions.setSsl(false); 63 | vertx.createHttpServer(httpOptions).requestHandler(router::accept).listen(); 64 | System.out.println("created HTTP server at " + httpServer.getString("hostname") + ":" + httpServer.getInteger("port")); 65 | 66 | // create HTTPS server 67 | HttpServerOptions httpsOptions = new HttpServerOptions(); 68 | httpsOptions.setHost(httpsServer.getString("hostname")); 69 | httpsOptions.setPort(httpsServer.getInteger("port")); 70 | httpsOptions.setSsl(true); 71 | httpsOptions.setKeyStoreOptions(new JksOptions().setPath( httpsServer.getString("keyStore") ).setPassword("testpassword")); 72 | vertx.createHttpServer(httpsOptions).requestHandler(router::accept).listen(); 73 | System.out.println("created HTTPS server at " + httpsServer.getString("hostname") + ":" + httpsServer.getInteger("port") + " (keyFile: " + httpsServer.getString("keyStore") + ")"); 74 | 75 | // configure BodyHandler 76 | final BodyHandler bodyHandler = BodyHandler.create(); 77 | router.route("/app/*").handler(bodyHandler); 78 | router.route("/login").handler(bodyHandler); 79 | router.route().handler(BodyHandler.create()); 80 | 81 | // enable CORS 82 | router.route().handler(CorsHandler.create("http://localhost:8081") 83 | .allowedMethod(io.vertx.core.http.HttpMethod.GET) 84 | .allowedMethod(io.vertx.core.http.HttpMethod.POST) 85 | .allowedMethod(io.vertx.core.http.HttpMethod.OPTIONS) 86 | .allowCredentials(true) 87 | .allowedHeader("Access-Control-Allow-Headers") 88 | .allowedHeader("Authorization") 89 | .allowedHeader("Access-Control-Allow-Method") 90 | .allowedHeader("Access-Control-Allow-Origin") 91 | .allowedHeader("Access-Control-Allow-Credentials") 92 | .allowedHeader("Content-Type")); 93 | 94 | // HTTP to HTTPS redirect 95 | router.route().handler( context -> { 96 | boolean sslUsed = context.request().isSSL(); 97 | boolean enforceSslRedirect = httpsServer.getBoolean("enforceRedirect"); 98 | 99 | if(!sslUsed && enforceSslRedirect) { 100 | try { 101 | int httpsPort = httpsServer.getInteger("port"); 102 | 103 | URI myHttpUri = new URI( context.request().absoluteURI() ); 104 | URI myHttpsUri = new URI("https", 105 | myHttpUri.getUserInfo(), 106 | myHttpUri.getHost(), 107 | httpsPort, 108 | myHttpUri.getRawPath(), 109 | myHttpUri.getRawQuery(), 110 | myHttpUri.getRawFragment()); 111 | context.response().putHeader("location", myHttpsUri.toString() ).setStatusCode(302).end(); 112 | } catch(URISyntaxException ex) { 113 | ex.printStackTrace(); 114 | context.next(); 115 | } 116 | } 117 | else context.next(); 118 | }); 119 | 120 | // configure OAuth2 based on Keycloak 121 | JsonObject keycloakJson = new JsonObject() 122 | .put("realm", "master") // (1) 123 | .put("realm-public-key", "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqZeGGDeEHmmUN4/UXh2gQD0yZEZirprsrdYK7GfcE1+QF9yfYfBrIv5cQUssFQKISVpbbLcoqYolsxcOvDyVFSQedHRsumOzqNZK38RHkidPMPrSNof5C3iMIHuXOCv/6exnLZvVoeYmkq42davYEz1tpSWzkZnlUMbRZFs1CfzLMM2rsAJWsO1/5zbDm0JhFl7EFUsTki72ihac1Q5zUUSFyf1jKUEkL7rrkYINjgAaQKktE8pnubc3Y44F5llY4YyU9/bqUWqMYDx868oiDcnoBpGGd4QrUMlbULZZLRqqUKK6iG1kHxDCJQ9gaCiJoELyAqXjnnO28OODQhxMHQIDAQAB") // (2) 124 | .put("auth-server-url", "http://127.0.0.1:38080/auth") 125 | .put("ssl-required", "external") 126 | .put("resource", "vertx-account") // (3) 127 | .put("credentials", new JsonObject().put("secret", "0c22e587-2ccb-4dd3-b017-5ff6a903891b")); // (4) 128 | OAuth2Auth oauth2 = KeycloakAuth.create(vertx, OAuth2FlowType.PASSWORD, keycloakJson); 129 | 130 | 131 | // // handler to deliver the user info object, currently disabled 132 | // router.route("/app/userinfo").handler(context -> { 133 | // if (context.user() != null) { 134 | // JsonObject userDetails = context.user().principal(); 135 | // userDetails.remove("password"); 136 | // userDetails.put("jsessionid", context.session().id()); 137 | // context.request().response().putHeader("Content-Type", "application/json"); 138 | // context.request().response().end(userDetails.encodePrettily()); 139 | // } 140 | // else context.request().response().end( 141 | // new JsonObject().put("error", "401").put("message", "user is not authenticated").encodePrettily() 142 | // ); 143 | // }); 144 | 145 | // Login handler 146 | router.post("/login").produces("application/json").handler(rc -> { 147 | System.err.println("received body ::: '"+rc.getBodyAsString()+"'"); 148 | JsonObject userJson = rc.getBodyAsJson(); 149 | System.err.println("User ::: "+userJson.encode()); 150 | 151 | oauth2.authenticate(userJson, res -> { 152 | if (res.failed()) { 153 | System.err.println("Access token error: {} " + res.cause().getMessage()); 154 | rc.response().setStatusCode(HttpResponseStatus.UNAUTHORIZED.code()).end(); 155 | } else { 156 | User user = res.result(); 157 | System.out.println("Success: we have found user: "+user.principal().encodePrettily()); 158 | rc.response().end(user.principal().encodePrettily()); 159 | } 160 | }); 161 | }); 162 | 163 | // router.post("/login").handler(FormLoginHandler.create(authProvider).setDirectLoggedInOKURL("/app/")); 164 | // 165 | // // Implement logout 166 | // router.route("/logout").handler(context -> { 167 | // context.clearUser(); 168 | // context.setUser(null); 169 | // context.session().destroy(); 170 | // context.setSession(null); 171 | // System.out.println("session destroyed, should log out now"); 172 | //// context.reroute("/"); 173 | // }); 174 | 175 | // make sure the user is properly authenticated when using the eventbus, if not reject with 403 176 | // NOTE: this is currently disabled, as the user auth needs to be properly synchronized between the Frontend and the backend 177 | // router.route("/eventbus/*").handler(ctx -> { 178 | // // we need to be logged in 179 | // if (ctx.user() == null) { 180 | // ctx.fail(403); 181 | // } else { 182 | // ctx.next(); 183 | // } 184 | // }); 185 | 186 | // configure EventBus based on the SockJSBridge 187 | router.route("/eventbus/*").handler(new SockJSBridge(vertx)); 188 | 189 | // staticHandler to handle static resources 190 | router.route().handler(StaticHandler.create().setCachingEnabled(true)); 191 | } 192 | 193 | 194 | /** 195 | * creates Vertx EventBus based API endpoints (for query and mutation) 196 | */ 197 | private void createApiEndpoints() { 198 | vertx.eventBus().consumer("/api/messages", this::apiMessages); 199 | vertx.eventBus().consumer("/api/messages/delete", this::apiMessagesDelete); 200 | vertx.eventBus().consumer("/api/messages/add", this::apiMessagesAdd); 201 | } 202 | 203 | /** 204 | * get messages API handler, this simply returns our as-is messages array 205 | * @param msg 206 | */ 207 | private void apiMessages(Message msg) { 208 | System.err.println("apiMessages called"); 209 | msg.reply(messages); 210 | } 211 | 212 | /** 213 | * delete message API handler, this deletes a given message from our messages array and 214 | * publishes the entire message array to all potential subscribers 215 | * @param msg 216 | */ 217 | private void apiMessagesDelete(Message msg) { 218 | JsonObject inputObject = msg.body(); 219 | System.err.println("apiMessagesDelete called : "+inputObject.encode()); 220 | 221 | for(int a=0; a < messages.size(); a++) { 222 | if(messages.getJsonObject(a).equals(inputObject)) { 223 | System.out.println("=> removing document: "+inputObject.encode()); 224 | messages.remove(a); 225 | break; 226 | } 227 | } 228 | // publish all known messages to any subscriber 229 | this.vertx.eventBus().publish(":pubsub/messages", messages); 230 | msg.reply(new JsonObject()); 231 | } 232 | 233 | /** 234 | * add message API handler, this adds a new message into our messages array and 235 | * publishes the entire message array to all potential subscribers 236 | * @param msg 237 | */ 238 | private void apiMessagesAdd(Message msg) { 239 | JsonObject inputObject = msg.body(); 240 | System.err.println("apiMessagesAdd called : "+inputObject.encode()); 241 | messages.add(inputObject); 242 | 243 | // publish all known messages to any subscriber 244 | this.vertx.eventBus().publish(":pubsub/messages", messages); 245 | msg.reply(new JsonObject()); 246 | } 247 | } 248 | 249 | -------------------------------------------------------------------------------- /src/main/java/backend/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | package backend; 2 | 3 | import io.vertx.core.Handler; 4 | import io.vertx.core.http.HttpServerRequest; 5 | import io.vertx.core.json.Json; 6 | import io.vertx.ext.web.RoutingContext; 7 | 8 | import java.util.List; 9 | import java.util.function.Function; 10 | 11 | public class ResponseUtil { 12 | 13 | public static void respondWithCreated(RoutingContext routingContext, String location, Object content) { 14 | routingContext.response().setStatusCode(200).putHeader("content-type", "application/json; charset=utf-8") 15 | .putHeader("Location", routingContext.request().absoluteURI() + "/" + location).end(Json.encode(content)); 16 | } 17 | 18 | public static void respondWithDeleted(RoutingContext routingContext) { 19 | routingContext.response().setStatusCode(204).putHeader("content-type", "application/json; charset=utf-8").end(); 20 | } 21 | 22 | public static Handler respondWithJson(Function> listSupplier) { 23 | return (RoutingContext rc) -> { 24 | rc.response().putHeader("content-type", "application/json; charset=utf-8") 25 | .end(Json.encode(listSupplier.apply(rc.request()))); 26 | }; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/backend/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package backend; 2 | 3 | import io.vertx.core.Handler; 4 | import io.vertx.core.Vertx; 5 | import io.vertx.core.http.HttpServerResponse; 6 | import io.vertx.ext.web.Router; 7 | import io.vertx.ext.web.RoutingContext; 8 | import io.vertx.ext.web.handler.CSRFHandler; 9 | import io.vertx.ext.web.handler.CookieHandler; 10 | import io.vertx.ext.web.handler.SessionHandler; 11 | import io.vertx.ext.web.sstore.LocalSessionStore; 12 | 13 | public class SecurityConfig { 14 | 15 | public static void addSecurity(Router router, Vertx vertx) { 16 | 17 | if (!Boolean.getBoolean("vertx.development")) { 18 | // Sessions 19 | router.route().handler(CookieHandler.create()); 20 | router.route().handler( 21 | SessionHandler.create(LocalSessionStore.create(vertx)).setCookieHttpOnlyFlag(true) 22 | .setCookieSecureFlag(true)); 23 | // CSRF protection 24 | router.route().handler(CSRFHandler.create("not a good secret")); 25 | // Headers 26 | router.route().handler(addSecurityHeaders()); 27 | } else { 28 | System.out.println("development mode"); 29 | } 30 | 31 | } 32 | 33 | private static Handler addSecurityHeaders() { 34 | return (RoutingContext rc) -> { 35 | final HttpServerResponse response = rc.response(); 36 | // prevent caching for HTTP/1.1 37 | response.putHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 38 | // prevent caching for HTTP/1.0 39 | response.putHeader("Pragma", "no-cache").putHeader("Expires", "0"); 40 | // prevents Internet Explorer from MIME - sniffing a 41 | // response away from the declared content-type 42 | response.putHeader("X-Content-Type-Options", "nosniff"); 43 | // Strict HTTPS (for about ~6Months) 44 | response.putHeader("Strict-Transport-Security", "max-age=15768000 ; includeSubDomains"); 45 | // IE8+ do not allow opening of attachments in the context 46 | // of this resource 47 | response.putHeader("X-Download-Options", "noopen"); 48 | // enable XSS protection for IE 49 | response.putHeader("X-XSS-Protection", "1; mode=block"); 50 | // deny frames 51 | response.putHeader("X-FRAME-OPTIONS", "DENY"); 52 | 53 | rc.next(); 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/backend/SockJSBridge.java: -------------------------------------------------------------------------------- 1 | package backend; 2 | 3 | import java.io.Console; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | import io.vertx.core.Handler; 7 | import io.vertx.core.Vertx; 8 | import io.vertx.ext.bridge.BridgeEventType; 9 | import io.vertx.ext.web.RoutingContext; 10 | import io.vertx.ext.web.handler.sockjs.BridgeOptions; 11 | import io.vertx.ext.web.handler.sockjs.PermittedOptions; 12 | import io.vertx.ext.web.handler.sockjs.SockJSHandler; 13 | 14 | /** 15 | * Handles routing contexts bridging to the event bus via sockjs. 16 | * 17 | */ 18 | public class SockJSBridge implements Handler { 19 | 20 | private Vertx vertx; 21 | private final Handler delegate; 22 | private final AtomicInteger connections; 23 | 24 | public SockJSBridge(Vertx vertx) { 25 | this.vertx = vertx; 26 | this.delegate = createDelegate(vertx); 27 | this.connections = new AtomicInteger(0); 28 | vertx.setPeriodic(1000, id -> { 29 | publishCounts(connections.get()); 30 | }); 31 | } 32 | 33 | private void publishCounts(Integer count) { 34 | vertx.eventBus().publish(":pubsub/connections", "{\"count\": " + count + "}"); 35 | } 36 | 37 | private Handler createDelegate(Vertx vertx) { 38 | // permit all adresses; may be unsecure in a real application 39 | // final BridgeOptions OPTIONS = new BridgeOptions().addOutboundPermitted(new PermittedOptions() 40 | // .setAddressRegex(".*")); 41 | 42 | BridgeOptions options = new BridgeOptions(); 43 | options.addInboundPermitted(new PermittedOptions()); 44 | options.addOutboundPermitted(new PermittedOptions()); 45 | 46 | return SockJSHandler.create(vertx).bridge(options, event -> { 47 | 48 | if (event.type() == BridgeEventType.SOCKET_CREATED) { 49 | publishCounts(connections.incrementAndGet()); 50 | } 51 | if (event.type() == BridgeEventType.SOCKET_CLOSED) { 52 | publishCounts(connections.decrementAndGet()); 53 | } 54 | event.complete(true); 55 | }); 56 | } 57 | 58 | @Override 59 | public void handle(RoutingContext event) { 60 | delegate.handle(event); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/resources/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/main/resources/.gitkeep -------------------------------------------------------------------------------- /src/test/java/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/test/java/.gitkeep -------------------------------------------------------------------------------- /src/test/java/web/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package web; 2 | 3 | import io.vertx.core.Vertx; 4 | import io.vertx.ext.unit.TestContext; 5 | import io.vertx.ext.unit.junit.VertxUnitRunner; 6 | 7 | import org.junit.AfterClass; 8 | import org.junit.BeforeClass; 9 | import org.junit.runner.RunWith; 10 | 11 | import backend.MainVerticle; 12 | 13 | @RunWith(VertxUnitRunner.class) 14 | public class AbstractIntegrationTest { 15 | 16 | public static Vertx vertx; 17 | 18 | @BeforeClass 19 | public static void setUp(TestContext context) { 20 | vertx = Vertx.vertx(); 21 | vertx.deployVerticle(MainVerticle.class.getName(), context.asyncAssertSuccess()); 22 | } 23 | 24 | @AfterClass 25 | public static void tearDown(TestContext context) { 26 | vertx.close(context.asyncAssertSuccess()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/web/AbstractIsolatedIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package web; 2 | 3 | import io.vertx.core.Vertx; 4 | import io.vertx.ext.unit.TestContext; 5 | import io.vertx.ext.unit.junit.VertxUnitRunner; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.runner.RunWith; 10 | 11 | import backend.MainVerticle; 12 | 13 | @RunWith(VertxUnitRunner.class) 14 | public class AbstractIsolatedIntegrationTest { 15 | 16 | public Vertx vertx; 17 | 18 | @Before 19 | public void setUp(TestContext context) { 20 | vertx = Vertx.vertx(); 21 | vertx.deployVerticle(MainVerticle.class.getName(), context.asyncAssertSuccess()); 22 | } 23 | 24 | @After 25 | public void tearDown(TestContext context) { 26 | vertx.close(context.asyncAssertSuccess()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/resources/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/src/test/resources/.gitkeep -------------------------------------------------------------------------------- /test.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertx-stack/vertx-vue-keycloak/d886e61c7720e7bc280c8f2f1e4756ab273ef78a/test.jks -------------------------------------------------------------------------------- /vert.x.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------