Compare commits
67 Commits
5175cb89b5
...
renovate/o
| Author | SHA1 | Date | |
|---|---|---|---|
| dcd656606f | |||
| 2831f03ac1 | |||
| e5ffea3196 | |||
| d0776d7f0b | |||
| 2acafb87eb | |||
| f733b03213 | |||
| 2c3246660e | |||
| d98991c0a0 | |||
| d0f0e72eb2 | |||
| ad675f06f0 | |||
| 90334d15f8 | |||
| 02be0a405e | |||
| 574dd4c093 | |||
| e69462be26 | |||
| 2024c356b0 | |||
| 66233827fd | |||
| 02bd377430 | |||
| a2e69c6a57 | |||
| bbbf34da6e | |||
| e05e523c12 | |||
| 8d6bb14fc1 | |||
| 91415bea5b | |||
| 18ca42a056 | |||
| 8029f2d931 | |||
| d6ffe35d6e | |||
| 8b5ba88d24 | |||
| 86742f1f1a | |||
| 8acc7460a0 | |||
| 656a337501 | |||
| 8eaae7c659 | |||
| 6c077bce27 | |||
| 7a0ee4b438 | |||
| 03ea142db2 | |||
| d285783fe7 | |||
| eced10976b | |||
| eadeb8c518 | |||
| 6ffa22d7b5 | |||
| dacdfd7935 | |||
| a728e376f2 | |||
| 9890086810 | |||
| 2c3c2b783e | |||
| c5c76c77fa | |||
| 992e57a46b | |||
| 638bdd9b7b | |||
| d35063519e | |||
| eb81f6b26a | |||
| 58d59f17e0 | |||
| cce4d4a25d | |||
| b23b6f0dbd | |||
| 62bf6229a7 | |||
| cf297ffe94 | |||
| d27b2054eb | |||
| 178b77e868 | |||
| 23d46a28fb | |||
| dd156d3152 | |||
| cf1c3eefc8 | |||
| 920bddc0db | |||
| 4887902516 | |||
| 9012e61e61 | |||
| 0f9816461f | |||
| ea3860391d | |||
| 17ba5b8b9d | |||
| 9b3f43937f | |||
| 7ffb02bbf0 | |||
| c51486751f | |||
| 211aa26df1 | |||
| 5a706e56ae |
53
.drone.yml
53
.drone.yml
@@ -1,27 +1,41 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: default
|
name: verify
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# test if it compiles correctly
|
# test if it compiles correctly
|
||||||
- name: build
|
- name: build
|
||||||
image: maven:3-eclipse-temurin-17
|
image: maven:3-eclipse-temurin-21
|
||||||
commands:
|
commands:
|
||||||
- mvn verify --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
- mvn verify --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||||
|
|
||||||
# run unit tests
|
# run unit tests
|
||||||
- name: test
|
- name: test
|
||||||
image: maven:3-eclipse-temurin-17
|
image: maven:3-eclipse-temurin-21
|
||||||
commands:
|
commands:
|
||||||
- mvn test --no-transfer-progress -B -V
|
- mvn test --no-transfer-progress -B -V
|
||||||
|
|
||||||
|
# check maven dependencies
|
||||||
|
- name: dependency-check
|
||||||
|
image: maven:3-eclipse-temurin-21
|
||||||
|
commands:
|
||||||
|
- mvn dependency-check:check --no-transfer-progress -B -V -DnvdApiKey=$NVD_API_KEY
|
||||||
|
environment:
|
||||||
|
NVD_API_KEY:
|
||||||
|
from_secret: nvd_api_key
|
||||||
|
|
||||||
# run code analysis
|
# run code analysis
|
||||||
- name: code-analysis
|
- name: code-analysis
|
||||||
image: maven:3-eclipse-temurin-17
|
image: maven:3-eclipse-temurin-21
|
||||||
commands:
|
commands:
|
||||||
- mvn sonar:sonar --no-transfer-progress -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.host.url=$SONAR_INSTANCE_URL -Dsonar.login=$SONAR_LOGIN_KEY -B -V
|
- mvn sonar:sonar --no-transfer-progress -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.host.url=$SONAR_INSTANCE_URL -Dsonar.token=$SONAR_LOGIN_KEY -B -V
|
||||||
environment:
|
environment:
|
||||||
SONAR_PROJECT_KEY:
|
SONAR_PROJECT_KEY:
|
||||||
from_secret: sonar_project_key
|
from_secret: sonar_project_key
|
||||||
@@ -29,3 +43,32 @@ steps:
|
|||||||
from_secret: sonar_instance_url
|
from_secret: sonar_instance_url
|
||||||
SONAR_LOGIN_KEY:
|
SONAR_LOGIN_KEY:
|
||||||
from_secret: sonar_login_key
|
from_secret: sonar_login_key
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
kind: pipeline
|
||||||
|
name: deploy
|
||||||
|
type: docker
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- production
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# skip all previous steps because they were already ran in the "build" phase; we don't need to re-analyze the code.
|
||||||
|
|
||||||
|
# upload to maven repository
|
||||||
|
- name: maven-deploy
|
||||||
|
image: maven:3-eclipse-temurin-21
|
||||||
|
commands:
|
||||||
|
- mvn deploy --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -B -V -gs settings.xml -Dmaven.repo.username=$MAVEN_REPO_USERNAME -Dmaven.repo.password=$MAVEN_REPO_PASSWORD
|
||||||
|
environment:
|
||||||
|
MAVEN_REPO_USERNAME:
|
||||||
|
from_secret: maven_repo_username
|
||||||
|
MAVEN_REPO_PASSWORD:
|
||||||
|
from_secret: maven_repo_password
|
||||||
|
|||||||
62
pom.xml
62
pom.xml
@@ -6,73 +6,107 @@
|
|||||||
|
|
||||||
<groupId>wtf.beatrice</groupId>
|
<groupId>wtf.beatrice</groupId>
|
||||||
<artifactId>release-hive</artifactId>
|
<artifactId>release-hive</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.2-SNAPSHOT</version>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Logging Dependencies -->
|
<!-- Logging Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>2.23.1</version>
|
<version>2.25.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.23.1</version>
|
<version>2.25.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Web Dependencies -->
|
<!-- Web Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-json</artifactId>
|
<artifactId>spring-boot-starter-json</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Security and Auth -->
|
<!-- Security and Auth -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt-api</artifactId>
|
<artifactId>jjwt-api</artifactId>
|
||||||
<version>0.11.5</version>
|
<version>0.13.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt-impl</artifactId>
|
<artifactId>jjwt-impl</artifactId>
|
||||||
<version>0.11.5</version>
|
<version>0.13.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt-jackson</artifactId>
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
<version>0.11.5</version>
|
<version>0.13.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Database Dependencies -->
|
<!-- Database Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>42.7.3</version>
|
<version>42.7.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.owasp</groupId>
|
||||||
|
<artifactId>dependency-check-maven</artifactId>
|
||||||
|
<version>12.1.9</version>
|
||||||
|
<configuration>
|
||||||
|
<failBuildOnCVSS>8</failBuildOnCVSS>
|
||||||
|
<nvdApiKey>${nvdApiKey}</nvdApiKey>
|
||||||
|
<formats>
|
||||||
|
<format>html</format>
|
||||||
|
<format>json</format>
|
||||||
|
</formats>
|
||||||
|
<suppressionFiles>
|
||||||
|
<suppressionFile>./suppressions.xml</suppressionFile>
|
||||||
|
</suppressionFiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<sonar.dependencyCheck.htmlReportPath>./target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
|
||||||
|
<sonar.dependencyCheck.jsonReportPath>./target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
|
||||||
|
<sonar.dependencyCheck.summarize>true</sonar.dependencyCheck.summarize>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>nexus-releases</id>
|
||||||
|
<url>https://nexus.beatrice.wtf/repository/maven-releases/</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>nexus-snapshots</id>
|
||||||
|
<url>https://nexus.beatrice.wtf/repository/maven-snapshots/</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ this is currently the only supported database backend.
|
|||||||
## building
|
## building
|
||||||
### required tools
|
### required tools
|
||||||
|
|
||||||
- java 17+ sdk
|
- java 21+ sdk
|
||||||
- git
|
- git
|
||||||
- maven
|
- maven
|
||||||
|
|
||||||
|
|||||||
3
renovate.json
Normal file
3
renovate.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
||||||
20
settings.xml
Normal file
20
settings.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
|
||||||
|
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>nexus-snapshots</id>
|
||||||
|
<username>${maven.repo.username}</username>
|
||||||
|
<password>${maven.repo.password}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>nexus-releases</id>
|
||||||
|
<username>${maven.repo.username}</username>
|
||||||
|
<password>${maven.repo.password}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
|
||||||
|
</settings>
|
||||||
|
|
||||||
@@ -11,7 +11,6 @@ import wtf.beatrice.releasehive.models.User;
|
|||||||
import wtf.beatrice.releasehive.services.UserService;
|
import wtf.beatrice.releasehive.services.UserService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/users")
|
@RequestMapping("/api/v1/users")
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ package wtf.beatrice.releasehive.services;
|
|||||||
|
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
|
||||||
import io.jsonwebtoken.io.Decoders;
|
import io.jsonwebtoken.io.Decoders;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import io.jsonwebtoken.security.Keys;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import wtf.beatrice.releasehive.models.User;
|
import wtf.beatrice.releasehive.models.User;
|
||||||
|
|
||||||
import java.security.Key;
|
import javax.crypto.SecretKey;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -52,11 +51,11 @@ public class JWTService
|
|||||||
) {
|
) {
|
||||||
return Jwts
|
return Jwts
|
||||||
.builder()
|
.builder()
|
||||||
.setClaims(extraClaims)
|
.claims(extraClaims)
|
||||||
.setSubject(userDetails.getEmail())
|
.subject(userDetails.getEmail())
|
||||||
.setIssuedAt(new Date(System.currentTimeMillis()))
|
.issuedAt(new Date(System.currentTimeMillis()))
|
||||||
.setExpiration(new Date(System.currentTimeMillis() + expiration))
|
.expiration(new Date(System.currentTimeMillis() + expiration))
|
||||||
.signWith(getSignInKey(), SignatureAlgorithm.HS256)
|
.signWith(getSignInKey(), Jwts.SIG.HS256)
|
||||||
.compact();
|
.compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,14 +74,14 @@ public class JWTService
|
|||||||
|
|
||||||
private Claims extractAllClaims(String token) {
|
private Claims extractAllClaims(String token) {
|
||||||
return Jwts
|
return Jwts
|
||||||
.parserBuilder()
|
.parser()
|
||||||
.setSigningKey(getSignInKey())
|
.verifyWith(getSignInKey())
|
||||||
.build()
|
.build()
|
||||||
.parseClaimsJws(token)
|
.parseSignedClaims(token)
|
||||||
.getBody();
|
.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Key getSignInKey() {
|
private SecretKey getSignInKey() {
|
||||||
byte[] keyBytes = Decoders.BASE64.decode(secretKey);
|
byte[] keyBytes = Decoders.BASE64.decode(secretKey);
|
||||||
return Keys.hmacShaKeyFor(keyBytes);
|
return Keys.hmacShaKeyFor(keyBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public class UserServiceImpl implements UserService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteUser(UUID id) {
|
public boolean deleteUser(UUID id) {
|
||||||
if (userRepository.findById(id).isEmpty()) {
|
userRepository.delete(userRepository
|
||||||
throw new UsernameNotFoundException(id.toString());
|
.findById(id)
|
||||||
}
|
.orElseThrow(() -> new UsernameNotFoundException("User not found")));
|
||||||
userRepository.delete(userRepository.findById(id).get());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
suppressions.xml
Normal file
10
suppressions.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
|
||||||
|
<suppress>
|
||||||
|
<notes><![CDATA[
|
||||||
|
file name: snakeyaml-1.33.jar
|
||||||
|
]]></notes>
|
||||||
|
<packageUrl regex="true">^pkg:maven/org\.yaml/snakeyaml@.*$</packageUrl>
|
||||||
|
<cve>CVE-2021-4235</cve>
|
||||||
|
</suppress>
|
||||||
|
</suppressions>
|
||||||
Reference in New Issue
Block a user