feat: initial commit
parent
35d6accafb
commit
abfaf19c47
|
@ -1,158 +1,22 @@
|
|||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
# Nuxt dev/build outputs
|
||||
/frontend/.output
|
||||
/frontend/.nuxt
|
||||
/frontend/dist
|
||||
/frontend/coverage
|
||||
|
||||
# Log file
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# System files
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
# Java dev/build outputs
|
||||
target
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
# IDE
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# Project specific
|
||||
data/
|
||||
/frontend/.nuxt/
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
|
@ -0,0 +1,25 @@
|
|||
FROM maven:3.8.6-eclipse-temurin-17 as builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
RUN mvn clean package
|
||||
|
||||
WORKDIR /app
|
||||
RUN cp /src/target/bousole-pluss-backend*.jar bousole-pluss-backend.jar
|
||||
RUN java -Djarmode=layertools -jar bousole-pluss-backend.jar extract
|
||||
|
||||
FROM eclipse-temurin:17-jre-alpine
|
||||
EXPOSE 8080
|
||||
USER root
|
||||
RUN addgroup -S pluss && adduser -S pluss -G pluss
|
||||
|
||||
ENV CORS_ALLOWED_ORIGINS=$CORS_ALLOWED_ORIGINS
|
||||
|
||||
USER pluss:pluss
|
||||
WORKDIR /app
|
||||
|
||||
COPY --chown=pluss:pluss --from=builder /app/dependencies/ ./
|
||||
COPY --chown=pluss:pluss --from=builder /app/snapshot-dependencies/ ./
|
||||
COPY --chown=pluss:pluss --from=builder /app/spring-boot-loader/ ./
|
||||
COPY --chown=pluss:pluss --from=builder /app/application/ ./
|
||||
ENTRYPOINT java org.springframework.boot.loader.JarLauncher
|
|
@ -0,0 +1,27 @@
|
|||
# Getting Started
|
||||
|
||||
### Reference Documentation
|
||||
For further reference, please consider the following sections:
|
||||
|
||||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
|
||||
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.2/maven-plugin/reference/html/)
|
||||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.2/maven-plugin/reference/html/#build-image)
|
||||
* [Rest Repositories](https://docs.spring.io/spring-boot/docs/2.7.2/reference/htmlsingle/#howto.data-access.exposing-spring-data-repositories-as-rest)
|
||||
* [Spring Security](https://docs.spring.io/spring-boot/docs/2.7.2/reference/htmlsingle/#web.security)
|
||||
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/2.7.2/reference/htmlsingle/#data.sql.jpa-and-spring-data)
|
||||
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.7.2/reference/htmlsingle/#web)
|
||||
|
||||
### Guides
|
||||
The following guides illustrate how to use some features concretely:
|
||||
|
||||
* [Accessing JPA Data with REST](https://spring.io/guides/gs/accessing-data-rest/)
|
||||
* [Accessing Neo4j Data with REST](https://spring.io/guides/gs/accessing-neo4j-data-rest/)
|
||||
* [Accessing MongoDB Data with REST](https://spring.io/guides/gs/accessing-mongodb-data-rest/)
|
||||
* [Securing a Web Application](https://spring.io/guides/gs/securing-web/)
|
||||
* [Spring Boot and OAuth2](https://spring.io/guides/tutorials/spring-boot-oauth2/)
|
||||
* [Authenticating a User with LDAP](https://spring.io/guides/gs/authenticating-ldap/)
|
||||
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
|
||||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
|
||||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
|
||||
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
|
||||
|
|
@ -0,0 +1,316 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -0,0 +1,188 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a team defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>fr.itsonus</groupId>
|
||||
<artifactId>bousole-pluss-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>bousole-pluss-backend</name>
|
||||
<description>Backend projet of Bousole PLUSS project</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-data</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<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>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
package fr.itsonus.bousoleplussbackend;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package fr.itsonus.bousoleplussbackend.advice;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ErrorMessage {
|
||||
private int statusCode;
|
||||
private Date timestamp;
|
||||
private String message;
|
||||
private String description;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package fr.itsonus.bousoleplussbackend.advice;
|
||||
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.exception.TokenRefreshException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class TokenControllerAdvice {
|
||||
|
||||
@ExceptionHandler(value = TokenRefreshException.class)
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public ErrorMessage handleTokenRefreshException(TokenRefreshException ex, WebRequest request) {
|
||||
return new ErrorMessage(
|
||||
HttpStatus.FORBIDDEN.value(),
|
||||
new Date(),
|
||||
ex.getMessage(),
|
||||
request.getDescription(false));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package fr.itsonus.bousoleplussbackend.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaAuditing
|
||||
public class PersistenceConfiguration {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package fr.itsonus.bousoleplussbackend.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class RestConfiguration implements RepositoryRestConfigurer {
|
||||
|
||||
// @Override
|
||||
// public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repositoryRestConfiguration,
|
||||
// CorsRegistry cors) {
|
||||
// repositoryRestConfiguration.getProjectionConfiguration()
|
||||
// .addProjection(QuizWithScore.class);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package fr.itsonus.bousoleplussbackend.configuration;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.security.jwt.AuthEntryPointJwt;
|
||||
import fr.itsonus.bousoleplussbackend.security.jwt.AuthTokenFilter;
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
@AllArgsConstructor
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
private final UserDetailsServiceImpl userDetailsService;
|
||||
|
||||
private final AuthEntryPointJwt unauthorizedHandler;
|
||||
|
||||
@Bean
|
||||
public AuthTokenFilter authenticationJwtTokenFilter() {
|
||||
return new AuthTokenFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
|
||||
authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.cors().configurationSource(request -> {
|
||||
var configuration = new CorsConfiguration();
|
||||
configuration.setAllowedOrigins(List.of("*"));
|
||||
configuration.setAllowedMethods(List.of("GET", "POST"));
|
||||
configuration.setAllowedHeaders(List.of("*"));
|
||||
return configuration;
|
||||
})
|
||||
.and()
|
||||
.csrf().disable()
|
||||
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
||||
.authorizeRequests().antMatchers("/auth/**").permitAll()
|
||||
.anyRequest().authenticated();
|
||||
|
||||
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package fr.itsonus.bousoleplussbackend.controllers;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.exception.TokenRefreshException;
|
||||
import fr.itsonus.bousoleplussbackend.models.RefreshToken;
|
||||
import fr.itsonus.bousoleplussbackend.models.User;
|
||||
import fr.itsonus.bousoleplussbackend.payload.request.LogOutRequest;
|
||||
import fr.itsonus.bousoleplussbackend.payload.request.LoginRequest;
|
||||
import fr.itsonus.bousoleplussbackend.payload.request.SignupRequest;
|
||||
import fr.itsonus.bousoleplussbackend.payload.request.TokenRefreshRequest;
|
||||
import fr.itsonus.bousoleplussbackend.payload.response.JwtResponse;
|
||||
import fr.itsonus.bousoleplussbackend.payload.response.MessageResponse;
|
||||
import fr.itsonus.bousoleplussbackend.payload.response.TokenRefreshResponse;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.UserRepository;
|
||||
import fr.itsonus.bousoleplussbackend.security.jwt.JwtUtils;
|
||||
import fr.itsonus.bousoleplussbackend.security.services.RefreshTokenService;
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
@AllArgsConstructor
|
||||
public class AuthController {
|
||||
|
||||
private final AuthenticationManager authenticationManager;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
private final PasswordEncoder encoder;
|
||||
|
||||
private final JwtUtils jwtUtils;
|
||||
|
||||
private final RefreshTokenService refreshTokenService;
|
||||
|
||||
@PostMapping("/signin")
|
||||
public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {
|
||||
|
||||
var authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
var userDetails = (UserDetailsImpl) authentication.getPrincipal();
|
||||
var jwt = jwtUtils.generateJwtToken(userDetails);
|
||||
var refreshToken = refreshTokenService.createRefreshToken(userDetails.getId());
|
||||
|
||||
return ResponseEntity.ok(new JwtResponse(jwt, refreshToken.getToken(), userDetails.getId(),
|
||||
userDetails.getUsername()));
|
||||
}
|
||||
|
||||
@PostMapping("/signup")
|
||||
public ResponseEntity<?> registerUser(@Valid @RequestBody SignupRequest signUpRequest) {
|
||||
if (userRepository.existsByUsername(signUpRequest.getUsername())) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("Error: Username is already taken!"));
|
||||
}
|
||||
|
||||
// Create new user's account
|
||||
var user = new User();
|
||||
user.setUsername(signUpRequest.getUsername());
|
||||
user.setPassword(encoder.encode(signUpRequest.getPassword()));
|
||||
userRepository.save(user);
|
||||
|
||||
return ResponseEntity.ok(new MessageResponse("User registered successfully!"));
|
||||
}
|
||||
|
||||
@PostMapping("/refreshtoken")
|
||||
public ResponseEntity<?> refreshToken(@Valid @RequestBody TokenRefreshRequest request) {
|
||||
String requestRefreshToken = request.getRefreshToken();
|
||||
|
||||
return refreshTokenService.findByToken(requestRefreshToken)
|
||||
.map(refreshTokenService::verifyExpiration)
|
||||
.map(RefreshToken::getUser)
|
||||
.map(user -> {
|
||||
String token = jwtUtils.generateTokenFromUsername(user.getUsername());
|
||||
return ResponseEntity.ok(new TokenRefreshResponse(token, requestRefreshToken));
|
||||
})
|
||||
.orElseThrow(() -> new TokenRefreshException(requestRefreshToken,
|
||||
"Refresh token is not in database!"));
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseEntity<?> logoutUser(@Valid @RequestBody LogOutRequest logOutRequest) {
|
||||
refreshTokenService.deleteByUserId(logOutRequest.getUserId());
|
||||
return ResponseEntity.ok(new MessageResponse("Log out successful!"));
|
||||
}
|
||||
|
||||
@GetMapping("/me")
|
||||
public ResponseEntity<?> me() {
|
||||
var authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
return ResponseEntity.ok(authentication.getPrincipal());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package fr.itsonus.bousoleplussbackend.controllers;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Quiz;
|
||||
import fr.itsonus.bousoleplussbackend.models.QuizScore;
|
||||
import fr.itsonus.bousoleplussbackend.models.Response;
|
||||
import fr.itsonus.bousoleplussbackend.payload.request.QuizRequest;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.QuestionRepository;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.QuizRepository;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.QuizScoreRepository;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.ResponseRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/quizzes")
|
||||
@AllArgsConstructor
|
||||
public class QuizController {
|
||||
|
||||
private QuizRepository quizRepository;
|
||||
private ResponseRepository responseRepository;
|
||||
private QuestionRepository questionRepository;
|
||||
private QuizScoreRepository quizScoreRepository;
|
||||
|
||||
@PostMapping("batch") // TODO add to REST representation
|
||||
public Quiz create(@Valid @RequestBody QuizRequest request) {
|
||||
var quiz = quizRepository.save(new Quiz());
|
||||
var responsesCreated = request.getResponses().stream().map(response -> {
|
||||
// TODO add correct exception with correct status code
|
||||
var question = questionRepository.findById(response.getQuestionId())
|
||||
.orElseThrow(() -> new NoSuchElementException("No such question with id " + response.getQuestionId()));
|
||||
log.info("Saving {}", response);
|
||||
return responseRepository.save(
|
||||
new Response()
|
||||
.setScore(response.getScore())
|
||||
.setComment(response.getComment())
|
||||
.setQuiz(quiz)
|
||||
.setQuestion(question));
|
||||
}).collect(Collectors.toSet());
|
||||
quiz.setResponses(responsesCreated);
|
||||
return quiz;
|
||||
}
|
||||
|
||||
@GetMapping("{id}/scores")
|
||||
public Iterable<QuizScore> findScores(@PathVariable("id") Long id) {
|
||||
return this.quizScoreRepository.findAllByQuizId(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package fr.itsonus.bousoleplussbackend.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public class TokenRefreshException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TokenRefreshException(String token, String message) {
|
||||
super(String.format("Failed for [%s]: %s", token, message));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
public class Axe {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private Integer identifier;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 50)
|
||||
private String shortTitle;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 100)
|
||||
private String title;
|
||||
|
||||
@NotBlank
|
||||
private String color;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
Axe axe = (Axe) o;
|
||||
return id != null && Objects.equals(id, axe.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsImpl;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
public class Question {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Axe axe;
|
||||
|
||||
@JsonIgnore
|
||||
private Long userId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String label;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 500)
|
||||
private String description;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
var question = (Question) o;
|
||||
return id != null && Objects.equals(id, question.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
var userDetails = (UserDetailsImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
this.userId = userDetails.getId();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsImpl;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.PrePersist;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class Quiz {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(name = "created_date", nullable = false, updatable = false)
|
||||
@CreatedDate
|
||||
private Date createdDate;
|
||||
|
||||
@JsonIgnore
|
||||
private Long userId;
|
||||
|
||||
@OneToMany(mappedBy = "quiz")
|
||||
@ToString.Exclude
|
||||
private Set<Response> responses;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
var userDetails = (UserDetailsImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
this.userId = userDetails.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
Quiz that = (Quiz) o;
|
||||
return id != null && Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
@Immutable
|
||||
public class QuizScore {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Long id;
|
||||
|
||||
private Float scoreAvg;
|
||||
private Integer axeIdentifier;
|
||||
@JsonIgnore
|
||||
private Long quizId;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
public class RefreshToken {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "user_id", referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String token;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Instant expiryDate;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
RefreshToken that = (RefreshToken) o;
|
||||
return id != null && Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Entity
|
||||
public class Response {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "question_id")
|
||||
private Question question;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "quiz_id")
|
||||
@JsonIgnore
|
||||
private Quiz quiz;
|
||||
|
||||
@Min(0)
|
||||
@Max(10)
|
||||
private Short score;
|
||||
|
||||
@Length(max = 500)
|
||||
private String comment;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
Response response = (Response) o;
|
||||
return id != null && Objects.equals(id, response.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "users",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = "username")
|
||||
})
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 20)
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 120)
|
||||
private String password;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
User user = (User) o;
|
||||
return id != null && Objects.equals(id, user.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LogOutRequest {
|
||||
private Long userId;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class LoginRequest {
|
||||
@NotBlank
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
private String password;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class QuizRequest {
|
||||
@NotEmpty
|
||||
private Set<@Valid ResponseRequest> responses;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ResponseRequest {
|
||||
@NotNull
|
||||
private Long questionId;
|
||||
@NotNull
|
||||
private Short score;
|
||||
private String comment;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
public class SignupRequest {
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 20)
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 40)
|
||||
private String password;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class TokenRefreshRequest {
|
||||
@NotBlank
|
||||
private String refreshToken;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class JwtResponse {
|
||||
|
||||
private static String type = "Bearer";
|
||||
private String token;
|
||||
private String refreshToken;
|
||||
private Long id;
|
||||
private String username;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MessageResponse {
|
||||
private String message;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package fr.itsonus.bousoleplussbackend.payload.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class TokenRefreshResponse {
|
||||
|
||||
private static String tokenType = "Bearer";
|
||||
private String accessToken;
|
||||
private String refreshToken;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package fr.itsonus.bousoleplussbackend.projections;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Quiz;
|
||||
import fr.itsonus.bousoleplussbackend.models.Response;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Projection(name = "responseWithQuestion", types = { Quiz.class })
|
||||
public interface QuizWithResponses {
|
||||
|
||||
String getCreatedDate();
|
||||
|
||||
@Value("#{target.getResponses()}")
|
||||
Set<ResponseWithQuestion> getResponses();
|
||||
|
||||
// @Value("#{target.getResponses().stream().collect(Collectors.toMap(value -> value, value -> value.length()))}")
|
||||
// Map<Integer, ResponseWithQuestion> getResponses();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package fr.itsonus.bousoleplussbackend.projections;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Response;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
@Projection(name = "responseWithQuestion", types = { Response.class })
|
||||
public interface ResponseWithQuestion {
|
||||
|
||||
String getComment();
|
||||
Short getScore();
|
||||
|
||||
@Value("#{target.getQuestion().getLabel()}")
|
||||
String getQuestion();
|
||||
|
||||
@Value("#{target.getQuestion().getAxe().getIdentifier()}")
|
||||
Integer getAxeIdentifier();
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Axe;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RepositoryRestResource
|
||||
public interface AxeRepository extends CrudRepository<Axe, Long> {
|
||||
|
||||
Optional<Axe> findByIdentifier(Integer identifier);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Question;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@RepositoryRestResource
|
||||
public interface QuestionRepository extends CrudRepository<Question, Long> {
|
||||
|
||||
@RestResource(path="byAxeId", rel="byAxeId")
|
||||
@Query("SELECT q FROM Question q JOIN q.axe a WHERE q.axe.id = :id AND user_id = ?#{principal.id}")
|
||||
Iterable<Question> findAllByAxeId(@Param("id") final Long id);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Quiz;
|
||||
import fr.itsonus.bousoleplussbackend.models.Response;
|
||||
import fr.itsonus.bousoleplussbackend.projections.QuizWithResponses;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@RepositoryRestResource(excerptProjection = QuizWithResponses.class)
|
||||
public interface QuizRepository extends PagingAndSortingRepository<Quiz, Long> {
|
||||
|
||||
@RestResource(path = "me", rel = "me")
|
||||
@Query("SELECT q FROM Quiz q WHERE q.userId = ?#{principal.id}")
|
||||
Page<Quiz> findAllOfCurrentUser(final Pageable pageable);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.QuizScore;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface QuizScoreRepository extends JpaRepository<QuizScore, Long> {
|
||||
|
||||
Iterable<QuizScore> findAllByQuizId(Long quizId);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.RefreshToken;
|
||||
import fr.itsonus.bousoleplussbackend.models.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface RefreshTokenRepository extends JpaRepository<RefreshToken, Long> {
|
||||
Optional<RefreshToken> findByToken(String token);
|
||||
|
||||
@Modifying
|
||||
int deleteByUser(User user);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Response;
|
||||
import fr.itsonus.bousoleplussbackend.projections.ResponseWithQuestion;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
@RepositoryRestResource(excerptProjection = ResponseWithQuestion.class)
|
||||
public interface ResponseRepository extends CrudRepository<Response, Long> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
Optional<User> findByUsername(String username);
|
||||
|
||||
Boolean existsByUsername(String username);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.jwt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Component
|
||||
public class AuthEntryPointJwt implements AuthenticationEntryPoint {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuthEntryPointJwt.class);
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
|
||||
throws IOException, ServletException {
|
||||
logger.error("Unauthorized error: {}", authException.getMessage());
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
|
||||
final Map<String, Object> body = new HashMap<>();
|
||||
body.put("status", HttpServletResponse.SC_UNAUTHORIZED);
|
||||
body.put("error", "Unauthorized");
|
||||
body.put("message", authException.getMessage());
|
||||
body.put("path", request.getServletPath());
|
||||
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.writeValue(response.getOutputStream(), body);
|
||||
|
||||
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Error: Unauthorized");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.jwt;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class AuthTokenFilter extends OncePerRequestFilter {
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsServiceImpl userDetailsService;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
var jwt = parseJwt(request);
|
||||
if (jwt != null && jwtUtils.validateJwtToken(jwt)) {
|
||||
String username = jwtUtils.getUserNameFromJwtToken(jwt);
|
||||
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null,
|
||||
userDetails.getAuthorities());
|
||||
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot set user authentication: {}", e.getMessage());
|
||||
}
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
private String parseJwt(HttpServletRequest request) {
|
||||
var headerAuth = request.getHeader("Authorization");
|
||||
if (StringUtils.hasText(headerAuth) && headerAuth.startsWith("Bearer ")) {
|
||||
return headerAuth.substring(7);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.jwt;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.security.services.UserDetailsImpl;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.MalformedJwtException;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.SignatureException;
|
||||
import io.jsonwebtoken.UnsupportedJwtException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JwtUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
|
||||
|
||||
@Value("${app.jwtSecret}")
|
||||
private String jwtSecret;
|
||||
|
||||
@Value("${app.jwtExpirationMs}")
|
||||
private int jwtExpirationMs;
|
||||
|
||||
public String generateJwtToken(UserDetailsImpl userPrincipal) {
|
||||
return generateTokenFromUsername(userPrincipal.getUsername());
|
||||
}
|
||||
|
||||
public String generateTokenFromUsername(String username) {
|
||||
return Jwts.builder().setSubject(username).setIssuedAt(new Date())
|
||||
.setExpiration(new Date((new Date()).getTime() + jwtExpirationMs)).signWith(SignatureAlgorithm.HS512, jwtSecret)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public String getUserNameFromJwtToken(String token) {
|
||||
return Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(token).getBody().getSubject();
|
||||
}
|
||||
|
||||
public boolean validateJwtToken(String authToken) {
|
||||
try {
|
||||
Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(authToken);
|
||||
return true;
|
||||
} catch (SignatureException e) {
|
||||
logger.error("Invalid JWT signature: {}", e.getMessage());
|
||||
} catch (MalformedJwtException e) {
|
||||
logger.error("Invalid JWT token: {}", e.getMessage());
|
||||
} catch (ExpiredJwtException e) {
|
||||
logger.error("JWT token is expired: {}", e.getMessage());
|
||||
} catch (UnsupportedJwtException e) {
|
||||
logger.error("JWT token is unsupported: {}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("JWT claims string is empty: {}", e.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.services;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.exception.TokenRefreshException;
|
||||
import fr.itsonus.bousoleplussbackend.models.RefreshToken;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.RefreshTokenRepository;
|
||||
import fr.itsonus.bousoleplussbackend.repositories.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class RefreshTokenService {
|
||||
@Value("${app.jwtRefreshExpirationMs}")
|
||||
private Long refreshTokenDurationMs;
|
||||
|
||||
private final RefreshTokenRepository refreshTokenRepository;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public RefreshTokenService(final RefreshTokenRepository refreshTokenRepository, final UserRepository userRepository) {
|
||||
this.refreshTokenRepository = refreshTokenRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public Optional<RefreshToken> findByToken(String token) {
|
||||
return refreshTokenRepository.findByToken(token);
|
||||
}
|
||||
|
||||
public RefreshToken createRefreshToken(Long userId) {
|
||||
RefreshToken refreshToken = new RefreshToken();
|
||||
|
||||
refreshToken.setUser(userRepository.findById(userId).get());
|
||||
refreshToken.setExpiryDate(Instant.now().plusMillis(refreshTokenDurationMs));
|
||||
refreshToken.setToken(UUID.randomUUID().toString());
|
||||
|
||||
refreshToken = refreshTokenRepository.save(refreshToken);
|
||||
return refreshToken;
|
||||
}
|
||||
|
||||
public RefreshToken verifyExpiration(RefreshToken token) {
|
||||
if (token.getExpiryDate().compareTo(Instant.now()) < 0) {
|
||||
refreshTokenRepository.delete(token);
|
||||
throw new TokenRefreshException(token.getToken(), "Refresh token was expired. Please make a new signin request");
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int deleteByUserId(Long userId) {
|
||||
return refreshTokenRepository.deleteByUser(userRepository.findById(userId).get());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.services;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import fr.itsonus.bousoleplussbackend.models.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class UserDetailsImpl implements UserDetails {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
|
||||
public static UserDetailsImpl build(User user) {
|
||||
return new UserDetailsImpl(
|
||||
user.getId(),
|
||||
user.getUsername(),
|
||||
user.getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
UserDetailsImpl user = (UserDetailsImpl) o;
|
||||
return Objects.equals(id, user.id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package fr.itsonus.bousoleplussbackend.security.services;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.repositories.UserRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
var user = userRepository.findByUsername(username)
|
||||
.orElseThrow(() -> new UsernameNotFoundException("User Not Found with username: " + username));
|
||||
|
||||
return UserDetailsImpl.build(user);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
server.error.include-message=always
|
||||
|
||||
app.jwtSecret=generateSecretKey
|
||||
app.jwtExpirationMs=3600000
|
||||
app.jwtRefreshExpirationMs=86400000
|
||||
|
||||
spring.datasource.url=jdbc:h2:file:${DATABASE_PATH:./data/pluss}
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
|
||||
logging.level.org.hibernate.SQL=DEBUG
|
||||
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
|
||||
logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE
|
|
@ -0,0 +1,69 @@
|
|||
CREATE SEQUENCE hibernate_sequence START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE users
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
username VARCHAR(20) NOT NULL,
|
||||
password VARCHAR(120) NOT NULL,
|
||||
CONSTRAINT pk_user PRIMARY KEY (id),
|
||||
CONSTRAINT uc_user_username UNIQUE (username)
|
||||
);
|
||||
|
||||
CREATE TABLE refresh_token
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
expiry_date DATE NOT NULL,
|
||||
token VARCHAR(500) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
CONSTRAINT pk_refresh_token PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE axe
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
identifier INTEGER NOT NULL,
|
||||
short_title VARCHAR(100) NOT NULL,
|
||||
title VARCHAR(200) NOT NULL,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
CONSTRAINT pk_axe PRIMARY KEY (id),
|
||||
CONSTRAINT uc_axe_identifier UNIQUE (identifier, title, short_title)
|
||||
);
|
||||
|
||||
CREATE TABLE question
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
axe_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
label VARCHAR(200) NOT NULL,
|
||||
description VARCHAR(500),
|
||||
CONSTRAINT question_quiz PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE quiz
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created_date TIMESTAMP NOT NULL,
|
||||
CONSTRAINT pk_quiz PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE response
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
question_id INTEGER NOT NULL,
|
||||
quiz_id INTEGER NOT NULL,
|
||||
score SMALLINT NOT NULL,
|
||||
comment VARCHAR(500),
|
||||
CONSTRAINT pk_response PRIMARY KEY (id)
|
||||
);
|
||||
-- FIXME id may be wrong
|
||||
CREATE VIEW quiz_score AS
|
||||
SELECT
|
||||
r.quiz_id + a.identifier AS id
|
||||
,a.identifier AS axe_identifier
|
||||
,r.quiz_id as quiz_id
|
||||
,AVG(r.score) as score_avg
|
||||
FROM response r
|
||||
INNER JOIN QUESTION q ON q.id = r.question_id
|
||||
INNER JOIN AXE a ON a.id = q.axe_id
|
||||
GROUP BY r.quiz_id, a.identifier;
|
|
@ -0,0 +1,101 @@
|
|||
INSERT INTO axe (id, identifier, short_title, title, color)
|
||||
VALUES
|
||||
(nextval('hibernate_sequence'), '1', 'Pouvoir d''agir', 'AGIR en (re)donnant du pouvoir d’agir aux territoires et à leurs habitants', '#CA8AE8'),
|
||||
(nextval('hibernate_sequence'), '2', 'Multi-secteur', 'AGIR sur tous les secteurs de l’économie et l’ensemble des chaînes de valeur', '#22B9A6');
|
||||
|
||||
INSERT INTO users (id, username, password)
|
||||
VALUES
|
||||
(nextval('hibernate_sequence'), 'demo', '$2a$10$z83Y96vADEMbDytv4O1h.eBPGcVy2KgvuG8Ftk1t3eGuaDGexrhEW');
|
||||
|
||||
INSERT INTO question (id, axe_id, user_id, label, description)
|
||||
VALUES
|
||||
(nextval('hibernate_sequence'), 1, 3, 'Le projet favorise-t-il la montée en compétence des parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 1, 3, 'Le projet permet-il la participation active des parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 1, 3, 'Le projet est il accessible à différentes parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 1, 3, 'Le projet a-t-il une animation des liens sociaux?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 1, 3, 'Le projet favorise-t-il l''inclusion? la mixité sociale? les liens sociaux?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
|
||||
(nextval('hibernate_sequence'), 2, 3, 'Les ressources locales sont-elles prises en compte?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 2, 3, 'Plusieurs filières ou thématiques sont-elles abordées dans le projet?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
(nextval('hibernate_sequence'), 2, 3, 'Quel est le degré d''indépendance du projet vis à vis des ressources extèrieures?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.');
|
||||
|
||||
-- INSERT INTO axe (id, identifier, title, color)
|
||||
-- VALUES
|
||||
-- (nextval('hibernate_sequence'), '1', 'Pouvoir d'agir', 'AGIR en (re)donnant du pouvoir d’agir aux territoires et à leurs habitants', '#CA8AE8'),
|
||||
-- (nextval('hibernate_sequence'), '2', 'Multi-secteur', 'AGIR sur tous les secteurs de l’économie et l’ensemble des chaînes de valeur', '#22B9A6'),
|
||||
-- (nextval('hibernate_sequence'), '3', 'Local global', 'AGIR localement en pensant globalement', '#E7E145'),
|
||||
-- (nextval('hibernate_sequence'), '4', 'Utilité (sociale et écologique)', 'AGIR de manière utile et sobre socialement et écologiquement', '#F39345'),
|
||||
-- (nextval('hibernate_sequence'), '5', 'Communs', 'AGIR pour préserver et se réapproprier les communs', '#9FCC8B'),
|
||||
-- (nextval('hibernate_sequence'), '6', 'Démocratie', 'AGIR démocratiquement', '#FDA6C5'),
|
||||
-- (nextval('hibernate_sequence'), '7', 'Coopération', 'AGIR en encourageant la coopération à tous les niveaux', '#7E91F1'),
|
||||
-- (nextval('hibernate_sequence'), '8', 'Finances', 'AGIR pour maîtriser les outils de production', '#F37665'),
|
||||
-- (nextval('hibernate_sequence'), '9', 'Moyens de production', 'AGIR sur les instruments financiers', '#E9D280'),
|
||||
-- (nextval('hibernate_sequence'), '10','Travail', 'AGIR pour redonner au travail sa valeur véritable', '#7BD1F5');
|
||||
--
|
||||
-- INSERT INTO users (id, username, password)
|
||||
-- VALUES
|
||||
-- (nextval('hibernate_sequence'), 'demo', '$2a$10$z83Y96vADEMbDytv4O1h.eBPGcVy2KgvuG8Ftk1t3eGuaDGexrhEW');
|
||||
--
|
||||
-- INSERT INTO question (id, axe_id, user_id, label, description)
|
||||
-- VALUES
|
||||
-- (nextval('hibernate_sequence'), 1, 11, 'Le projet favorise-t-il la montée en compétence des parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 1, 11, 'Le projet permet-il la participation active des parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 1, 11, 'Le projet est il accessible à différentes parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 1, 11, 'Le projet a-t-il une animation des liens sociaux?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 1, 11, 'Le projet favorise-t-il l''inclusion? la mixité sociale? les liens sociaux?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 2, 11, 'Les ressources locales sont-elles prises en compte?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 2, 11, 'Plusieurs filières ou thématiques sont-elles abordées dans le projet?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 2, 11, 'Quel est le degré d''indépendance du projet vis à vis des ressources extèrieures?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 3 ,11, 'Êtes-vous en lien avec des écosystèmes locaux?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 3 ,11, 'Le projet contribue-t-il au développement économique d''autres acteurs du territoire?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 3 ,11, 'Le projet contribue-t-il au rééquilibrage territorial?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 3 ,11, 'Les parties prenantes du projet contribuent-elles à essaimer les bonnes pratiques liées au projet?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 4 ,11, 'Les besoins auxquels répond le projet ont-ils été définis collectivement?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 4 ,11, 'Avez-vous une politique d''achat responsable?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 4 ,11, 'Le projet cherche-t-il à réduire les impacts environnementaux négatifs?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 4 ,11, 'Le projet contribue-t-il à une boucle d''économie circulaire?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 5 ,11, 'Existe-t-il autour du projet une(des) ressource(s) partageable(s) préexistante(s) ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 5 ,11, 'Le projet va-t-il produire une(des) ressource(s) partageable(s) ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 5 ,11, 'Le projet est-il considéré lui-même comme une ressource partageable ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 5 ,11, 'Existe-t-il autour du projet une communauté souhaitant s''occuper de cette ressource partageable ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 5 ,11, 'Existe-t-il des règles d''accès et/ou d''usage à ces ressources ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'Existe t-il des lieux et des temps d''expression et de débat ouverts autour du projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'Les phases essentielles de développement et d''évaluation du projet sont elles soumises au débat ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'Tous les groupes représentatifs sont ils invités au débat: élu.e.s, producteur.ices, consommateur.ices, bénéficiaires, chargé.e.s de projet, encadrant.e.s, ....', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'Le droit à la parole est-il équitable lors des débats ? (ou les moyens mobilisés permettent-ils l''expression de chacun.e de manière équitable ?)', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'La gouvernance permet-elle une prise de décision partagée avec tous les groupes de parties prenantes ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 6 ,11, 'L''accès à la gouvernance par chacun.e est-il lisible et accessible ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'Le projet prend-il en compte les contraintes des différentes parties prenantes?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'La prise en compte des contraintes des parties prenantes fait-elle évoluer le projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'La coopération des acteurs permet-elle d''identifier les ressources matérielles et immatérielles locales mobilisables ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'La coopération permet-elle de réintégrer les externalités négatives du projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'La coopération permet-elle le financement des externalités positives du projet de manière monétaire ou non monétaire ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'Le processus de coopération fait-il évoluer la façon de travailler de chacun.e ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 7 ,11, 'Existe t-il un processus de partage et de transmission de l''information qui favorise la coopération?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Existe-t-il une réflexion autour de la propriété du foncier/l''immobilier utile au projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Existe-t-il une réflexion autour de la propriété des machines et des équipements utiles au projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Existe-t-il une réflexion autour de la propriété des process de production et d''innovation ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Êtes-vous libre de décider de l''emploi des outils de production nécessaires au projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Êtes-vous libre de décider quel est le niveau souhaitable de productivité du projet ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Un processus d''acquisition en propriété collective est-il à l''œuvre ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Vous sentez vous protégé contre d''éventuelles opérations de délocalisation ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 8 ,11, 'Le projet contribue-t-il à une reprise en main de l''économie locale ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 9 ,11, 'Le projet mobilise-t-il du financement solidaire et/ou participatif (épargne solidaire, crowdfunding, ...) ?','Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 9 ,11, 'Le projet mobilise-t-il des financements locaux (micro-crédit, capital-risque solidaire, clubs d''investisseurs locaux, ...) ?','Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 9 ,11, 'Le projet intègre-t-il le recours à des boucles locales d''échanges (monnaie complémentaire, troc inter-entreprise, système d''échange local, ...) ?','Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 9 ,11, 'Le projet mobilise-t-il du soutien auprès de fondations ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 9 ,11, 'Le projet cherche-t-il à favoriser la création d''une fondation territoriale ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
--
|
||||
-- (nextval('hibernate_sequence'), 10 ,11, 'Le projet valorise-t-il les ressources immatérielles (intentions, initiatives, compétences, savoir-faire) des contributeur.ices ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 10 ,11, 'Le projet contribue-t-il à développer les ressources immatérielles des contributeur.ices? (formation, santé, bien-être, confiance) ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 10 ,11, 'Le projet mobilise-t-il différentes formes de contribution : bénévolat, insertion, salariat, ... ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 10 ,11, 'Le projet mobilise-t-il différentes formes de rétribution des contributions : salariat., rétribution contributive,échanges, ...', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.'),
|
||||
-- (nextval('hibernate_sequence'), 10 ,11, 'La rémunération juste des parties prenantes est-elle prise en compte ?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus.')
|
|
@ -0,0 +1,13 @@
|
|||
package fr.itsonus.bousoleplussbackend;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
frontend:
|
||||
build:
|
||||
context: frontend/
|
||||
args:
|
||||
BACKEND_BASE_URL: http://localhost:8080
|
||||
ports:
|
||||
- "3000:80"
|
||||
networks:
|
||||
- front-tier
|
||||
- back-tier
|
||||
# configs:
|
||||
# - httpd-config
|
||||
|
||||
backend:
|
||||
build: backend/
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
environment:
|
||||
- CORS_ALLOWED_ORIGINS=http://localhost:8080
|
||||
networks:
|
||||
- back-tier
|
||||
|
||||
networks:
|
||||
# The presence of these objects is sufficient to define them
|
||||
front-tier: {}
|
||||
back-tier: {}
|
Loading…
Reference in New Issue