Skip to content

Instantly share code, notes, and snippets.

View apalyukha's full-sized avatar
🇺🇦

Andrii Paliukha apalyukha

🇺🇦
View GitHub Profile
@apalyukha
apalyukha / package.json
Created January 7, 2019 13:01
Spring Boot REST: add webpack
{
"name": "sarafan",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"vue": "^2.5.17",
"vue-resource": "^1.5.1"
},
"devDependencies": {
@apalyukha
apalyukha / webpack.config.js
Created January 7, 2019 13:02
Spring Boot REST: add webpack
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: path.join(__dirname, 'src', 'main', 'resources', 'static', 'js', 'main.js'),
devServer: {
contentBase: './dist',
compress: true,
@apalyukha
apalyukha / pom.xml
Created January 7, 2019 13:04
Spring boot MVC: integration tests - dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>RELEASE</version>
<scope>test</scope>
@apalyukha
apalyukha / session_tables.sql
Created January 7, 2019 13:06
Spring Boot REST: add oAuth2 authorization sessions table 2
CREATE TABLE spring_session (
primary_id CHAR(36) NOT NULL
CONSTRAINT spring_session_pk
PRIMARY KEY,
session_id CHAR(36) NOT NULL,
creation_time BIGINT NOT NULL,
last_access_time BIGINT NOT NULL,
max_inactive_interval INTEGER NOT NULL,
expiry_time BIGINT NOT NULL,
principal_name VARCHAR(300) -- <= here was 100
@apalyukha
apalyukha / application.properties
Created January 7, 2019 13:07
Spring Boot REST: add oAuth2 authorization 2
spring.session.jdbc.initialize-schema=always
spring.session.jdbc.table-name=SPRING_SESSION
spring.session.jdbc.schema=classpath:session_tables.sql
@apalyukha
apalyukha / build.gradle
Created January 7, 2019 13:11
Spring Boot REST: add oAuth2 authentication dependencies
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.0.RELEASE')
@apalyukha
apalyukha / application.properties
Created January 7, 2019 13:12
Spring Boot REST: add oAuth2 authorization
security.oauth2.client.clientId=some-secret.apps.googleusercontent.com
security.oauth2.client.clientSecret=very-secret
security.oauth2.client.accessTokenUri=https://www.googleapis.com/oauth2/v4/token
security.oauth2.client.userAuthorizationUri=https://accounts.google.com/o/oauth2/v2/auth
security.oauth2.client.clientAuthenticationScheme=form
security.oauth2.client.scope=openid,email,profile
security.oauth2.resource.userInfoUri=https://www.googleapis.com/oauth2/v3/userinfo
security.oauth2.resource.preferTokenInfo=true
server.port=9000
@apalyukha
apalyukha / build.gradle
Created January 7, 2019 13:14
Example: Add db support
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.postgresql:postgresql')
compile('org.projectlombok:lombok')
compile('javax.xml.bind:jaxb-api')
compile('com.sun.xml.bind:jaxb-core')
compile('com.sun.xml.bind:jaxb-impl')
@apalyukha
apalyukha / pom.xml
Created January 7, 2019 13:16
Lombok: write less code
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
@apalyukha
apalyukha / requests.js
Created January 7, 2019 13:18
Spring Boot REST: test rest methods
// GET all
fetch('/message/').then(response => response.json().then(console.log))
// GET one
fetch('/message/2').then(response => response.json().then(console.log))
// POST add new one
fetch(
'/message',
{