Compare commits
No commits in common. "main" and "spring-boot-upgrade" have entirely different histories.
main
...
spring-boo
20
.gitignore
vendored
20
.gitignore
vendored
@ -8,4 +8,24 @@ hs_err*.log
|
|||||||
application.properties
|
application.properties
|
||||||
usernames.txt
|
usernames.txt
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
.idea/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
.vscode
|
.vscode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history/*
|
||||||
|
|
||||||
|
# System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
@ -109,9 +109,6 @@
|
|||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>db-mysql</id>
|
<id>db-mysql</id>
|
||||||
@ -133,16 +130,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
|
||||||
<id>developer</id>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.bstly.we</groupId>
|
|
||||||
<artifactId>webstly-developer</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -167,4 +154,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -38,7 +38,7 @@ public class BorrowItem implements UserData {
|
|||||||
@Column(name = "name", nullable = false)
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "description", nullable = true, length = 100000)
|
@Column(name = "description", nullable = true)
|
||||||
private String description;
|
private String description;
|
||||||
@Column(name = "url", nullable = true)
|
@Column(name = "url", nullable = true)
|
||||||
private String url;
|
private String url;
|
||||||
|
@ -41,10 +41,10 @@ public class BorrowRequest implements UserData {
|
|||||||
@Column(name = "ends", nullable = false)
|
@Column(name = "ends", nullable = false)
|
||||||
private Instant ends;
|
private Instant ends;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "reply", nullable = true, length = 100000)
|
@Column(name = "reply", nullable = true)
|
||||||
private String reply;
|
private String reply;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "comment", nullable = true, length = 100000)
|
@Column(name = "comment", nullable = true)
|
||||||
private String comment;
|
private String comment;
|
||||||
@Transient
|
@Transient
|
||||||
private BorrowItem borrowItem;
|
private BorrowItem borrowItem;
|
||||||
|
14
core/pom.xml
14
core/pom.xml
@ -56,13 +56,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-validator</groupId>
|
<groupId>commons-validator</groupId>
|
||||||
<artifactId>commons-validator</artifactId>
|
<artifactId>commons-validator</artifactId>
|
||||||
<version>1.9.0</version>
|
<version>1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>33.3.1-jre</version>
|
<version>31.1-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.passay</groupId>
|
<groupId>org.passay</groupId>
|
||||||
<artifactId>passay</artifactId>
|
<artifactId>passay</artifactId>
|
||||||
<version>1.6.5</version>
|
<version>1.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -84,8 +84,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk18on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>1.78.1</version>
|
<version>1.70</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -96,13 +96,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.measure</groupId>
|
<groupId>javax.measure</groupId>
|
||||||
<artifactId>unit-api</artifactId>
|
<artifactId>unit-api</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-csv</artifactId>
|
<artifactId>commons-csv</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -416,15 +416,16 @@ public class PermissionManager implements UserDataProvider {
|
|||||||
List<Permission> existingPermissions = get(target, name);
|
List<Permission> existingPermissions = get(target, name);
|
||||||
|
|
||||||
for (Permission existingPermission : existingPermissions) {
|
for (Permission existingPermission : existingPermissions) {
|
||||||
if (additional && (starts == null && (existingPermission.getStarts() == null
|
if (existingPermission.getExpires().isBefore(permissionsExpires)) {
|
||||||
|| existingPermission.getStarts().isBefore(Instant.now()))
|
if (starts != null) {
|
||||||
|| starts != null && (starts.isBefore(existingPermission.getExpires())
|
if (existingPermission.getStarts() == null || existingPermission.getStarts().isAfter(starts)
|
||||||
|| existingPermission.getStarts() != null
|
|| existingPermission.getExpires().isAfter(starts)) {
|
||||||
&& starts.isAfter(existingPermission.getStarts())))) {
|
permission = existingPermission;
|
||||||
if (permission == null) {
|
break;
|
||||||
permission = existingPermission;
|
}
|
||||||
} else if (existingPermission.getExpires().isAfter(permission.getExpires())) {
|
} else if (existingPermission.getStarts() == null) {
|
||||||
permission = existingPermission;
|
permission = existingPermission;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,26 +434,23 @@ public class PermissionManager implements UserDataProvider {
|
|||||||
permission = new Permission();
|
permission = new Permission();
|
||||||
permission.setTarget(target);
|
permission.setTarget(target);
|
||||||
permission.setName(name);
|
permission.setName(name);
|
||||||
permission.setAddon(permissionMapping.isAddon()); // TODO: check for ROLE_MEMBER
|
permission.setAddon(permissionMapping.isAddon());
|
||||||
permission.setStarts(permissionStarts);
|
permission.setStarts(permissionStarts);
|
||||||
permission.setExpires(permissionsExpires);
|
permission.setExpires(permissionsExpires);
|
||||||
} else {
|
} else {
|
||||||
if (permission.getExpires() == null || permission.getExpires().isBefore(Instant.now())) {
|
if (permission.getStarts() != null && permission.getStarts().isBefore(Instant.now())) {
|
||||||
permission.setExpires(Instant.now());
|
permission.setStarts(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
permission.setExpires(InstantHelper.plus(permission.getExpires(), permissionMapping.getLifetime(),
|
permission.setExpires(InstantHelper.plus(permission.getExpires(), permissionMapping.getLifetime(),
|
||||||
permissionMapping.getLifetimeUnit()));
|
permissionMapping.getLifetimeUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission.getStarts() != null && permission.getStarts().isBefore(Instant.now())) {
|
|
||||||
permission.setStarts(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permissionMapping.isLifetimeRound()) {
|
if (permissionMapping.isLifetimeRound()) {
|
||||||
permission.setExpires(
|
permission.setExpires(
|
||||||
InstantHelper.truncate(permission.getExpires(), permissionMapping.getLifetimeUnit()));
|
InstantHelper.truncate(permission.getExpires(), permissionMapping.getLifetimeUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
permissions.add(permission);
|
permissions.add(permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -525,15 +525,11 @@ public class PretixManager implements SmartInitializingSingleton {
|
|||||||
if (payload != null) {
|
if (payload != null) {
|
||||||
request.bodyValue(gson.toJson(payload));
|
request.bodyValue(gson.toJson(payload));
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
String jsonString = request.retrieve().bodyToMono(String.class).block();
|
|
||||||
|
|
||||||
if (StringUtils.hasText(jsonString)) {
|
String jsonString = request.retrieve().bodyToMono(String.class).block();
|
||||||
return JsonParser.parseString(jsonString);
|
|
||||||
}
|
if (StringUtils.hasText(jsonString)) {
|
||||||
} catch (WebClientResponseException e) {
|
return JsonParser.parseString(jsonString);
|
||||||
logger.warn("Error response: " + e.getResponseBodyAsString(), e);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -20,8 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.beust.jcommander.internal.Lists;
|
|
||||||
|
|
||||||
import de.bstly.we.businesslogic.PretixManager;
|
import de.bstly.we.businesslogic.PretixManager;
|
||||||
import de.bstly.we.controller.support.EntityResponseStatusException;
|
import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||||
import de.bstly.we.model.SystemProperty;
|
import de.bstly.we.model.SystemProperty;
|
||||||
@ -92,17 +90,6 @@ public class SystemController extends BaseController {
|
|||||||
return systemPropertyRepository.save(systemProperty);
|
return systemPropertyRepository.save(systemProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
||||||
@PostMapping("/properties/list")
|
|
||||||
public List<SystemProperty> createOrUpdateList(@RequestBody List<SystemProperty> systemProperties) {
|
|
||||||
List<SystemProperty> result = Lists.newArrayList();
|
|
||||||
for (SystemProperty systemProperty : systemProperties) {
|
|
||||||
result.add(
|
|
||||||
systemPropertyRepository.save(systemProperty));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete property.
|
* Delete property.
|
||||||
*
|
*
|
||||||
|
@ -7,19 +7,19 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpInputMessage;
|
import org.springframework.http.HttpInputMessage;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
import org.springframework.http.server.ServerHttpResponse;
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
import org.springframework.util.MimeType;
|
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class JsonStringBodyControllerAdvice.
|
* The Class JsonStringBodyControllerAdvice.
|
||||||
@ -27,6 +27,8 @@ import com.google.gson.JsonParser;
|
|||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, ResponseBodyAdvice<String> {
|
public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, ResponseBodyAdvice<String> {
|
||||||
|
|
||||||
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#
|
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#
|
||||||
* supports(org.springframework.core.MethodParameter, java.lang.reflect.Type,
|
* supports(org.springframework.core.MethodParameter, java.lang.reflect.Type,
|
||||||
@ -47,11 +49,6 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
|
|||||||
@Override
|
@Override
|
||||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
|
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
|
||||||
Class<? extends HttpMessageConverter<?>> converterType) throws IOException {
|
Class<? extends HttpMessageConverter<?>> converterType) throws IOException {
|
||||||
if (inputMessage.getHeaders() == null || inputMessage.getHeaders().getContentType() == null || !inputMessage
|
|
||||||
.getHeaders().getContentType().equalsTypeAndSubtype(MimeType.valueOf("application/json"))) {
|
|
||||||
throw new EntityResponseStatusException(HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputMessage;
|
return inputMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +84,7 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||||
return returnType.getParameterType() == String.class;
|
return converterType == StringHttpMessageConverter.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -102,11 +99,8 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
|
|||||||
public String beforeBodyWrite(String body, MethodParameter returnType, MediaType selectedContentType,
|
public String beforeBodyWrite(String body, MethodParameter returnType, MediaType selectedContentType,
|
||||||
Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request,
|
Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request,
|
||||||
ServerHttpResponse response) {
|
ServerHttpResponse response) {
|
||||||
if (body == null) {
|
response.getHeaders().set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
return "";
|
return gson.toJson(new JsonPrimitive(body));
|
||||||
}
|
|
||||||
JsonElement json = JsonParser.parseString(body);
|
|
||||||
return json.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -260,9 +260,9 @@ public class TokenSessionManager {
|
|||||||
for (String token : ((String) sessionAttribute).split(",")) {
|
for (String token : ((String) sessionAttribute).split(",")) {
|
||||||
if (!token.equals(secret)) {
|
if (!token.equals(secret)) {
|
||||||
if (StringUtils.hasLength(tokens)) {
|
if (StringUtils.hasLength(tokens)) {
|
||||||
tokens += "," + token;
|
tokens += "," + secret;
|
||||||
} else {
|
} else {
|
||||||
tokens = token;
|
tokens = secret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class UserProfileField implements UserData {
|
|||||||
@Column(name = "value", nullable = true)
|
@Column(name = "value", nullable = true)
|
||||||
private String value;
|
private String value;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "blob_value", nullable = true, length = 100000)
|
@Column(name = "blob_value", nullable = true)
|
||||||
private String blob;
|
private String blob;
|
||||||
@Column(name = "type", nullable = false)
|
@Column(name = "type", nullable = false)
|
||||||
private ProfileFieldType type;
|
private ProfileFieldType type;
|
||||||
|
@ -95,7 +95,9 @@ public class SecurityConfig {
|
|||||||
.sessionManagement((anonymous) -> anonymous.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
|
.sessionManagement((anonymous) -> anonymous.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
|
||||||
.sessionAuthenticationStrategy(new SessionFixationProtectionStrategy()))
|
.sessionAuthenticationStrategy(new SessionFixationProtectionStrategy()))
|
||||||
// disable deprectated xss protection, x-frame
|
// disable deprectated xss protection, x-frame
|
||||||
.headers((headers) -> headers.xssProtection((xssProtection) -> xssProtection.disable()))
|
.headers((headers) -> headers.xssProtection((xssProtection) -> xssProtection.disable())
|
||||||
|
.frameOptions((frameOptions) -> frameOptions.disable()
|
||||||
|
.referrerPolicy((referrerPolicy) -> referrerPolicy.policy(ReferrerPolicy.UNSAFE_URL))))
|
||||||
// form login
|
// form login
|
||||||
.formLogin((formLogin) -> formLogin.loginPage(loginUrl).usernameParameter("username")
|
.formLogin((formLogin) -> formLogin.loginPage(loginUrl).usernameParameter("username")
|
||||||
.passwordParameter("password")
|
.passwordParameter("password")
|
||||||
@ -117,13 +119,8 @@ public class SecurityConfig {
|
|||||||
.exceptionHandling(
|
.exceptionHandling(
|
||||||
(exceptionHandling) -> exceptionHandling.accessDeniedHandler(localAccessDeniedHandler)
|
(exceptionHandling) -> exceptionHandling.accessDeniedHandler(localAccessDeniedHandler)
|
||||||
.authenticationEntryPoint(localAuthenticationEntryPoint()))
|
.authenticationEntryPoint(localAuthenticationEntryPoint()))
|
||||||
// x-frame
|
|
||||||
.headers((headers) -> headers.frameOptions((frameOptions) -> frameOptions.disable()
|
|
||||||
.referrerPolicy((referrerPolicy) -> referrerPolicy.policy(ReferrerPolicy.UNSAFE_URL))))
|
|
||||||
// crsf
|
// crsf
|
||||||
.csrf((csrf) -> csrf.disable())
|
.csrf((csrf) -> csrf.disable());
|
||||||
// TODO: update
|
|
||||||
.securityContext((securityContext) -> securityContext.requireExplicitSave(false));
|
|
||||||
|
|
||||||
if (disableCors) {
|
if (disableCors) {
|
||||||
http.cors((cors) -> cors.disable());
|
http.cors((cors) -> cors.disable());
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
<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>de.bstly.we</groupId>
|
|
||||||
<artifactId>webstly-main</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<springdoc-openapi-ui.version>1.6.9</springdoc-openapi-ui.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<name>developer</name>
|
|
||||||
<artifactId>webstly-developer</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.bstly.we</groupId>
|
|
||||||
<artifactId>webstly-core</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
|
||||||
<version>${springdoc-openapi-ui.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.bstly.we.developer;
|
|
||||||
|
|
||||||
import org.springdoc.core.GroupedOpenApi;
|
|
||||||
import org.springdoc.core.GroupedOpenApi.Builder;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.info.BuildProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
|
||||||
import io.swagger.v3.oas.models.info.Contact;
|
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The SpringDocConfig Class.
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SpringDocConfig {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BuildProperties buildProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* api.
|
|
||||||
*
|
|
||||||
* @return GroupedOpenApi
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public GroupedOpenApi api() {
|
|
||||||
Builder builder = GroupedOpenApi.builder();
|
|
||||||
builder.group("<ALL MODULES>").packagesToScan("de.bstly.we");
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiInfo.
|
|
||||||
*
|
|
||||||
* @return OpenAPI
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public OpenAPI apiInfo() {
|
|
||||||
return new OpenAPI()
|
|
||||||
.info(new Info()
|
|
||||||
.title("we.bstly - Api").contact(new Contact().name("Bastelei e. V.")
|
|
||||||
.url("https://www.bstly.de").email("api@bstly.de"))
|
|
||||||
.version(buildProperties.getVersion()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.bstly.we.dyndns.businesslogic;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.xbill.DNS.Message;
|
|
||||||
import org.xbill.DNS.Name;
|
|
||||||
import org.xbill.DNS.Resolver;
|
|
||||||
import org.xbill.DNS.SimpleResolver;
|
|
||||||
import org.xbill.DNS.TSIG;
|
|
||||||
import org.xbill.DNS.Type;
|
|
||||||
import org.xbill.DNS.Update;
|
|
||||||
|
|
||||||
import de.bstly.we.businesslogic.SystemPropertyManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class DyndnsTokenManager.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class DyndnsManager {
|
|
||||||
|
|
||||||
public static final String SYSTEM_PROPERTY_DYNDNS_HOSTNAME = "dyndns.hostname";
|
|
||||||
public static final String SYSTEM_PROPERTY_DYNDNS_KEY_NAME = "dyndns.keyname";
|
|
||||||
public static final String SYSTEM_PROPERTY_DYNDNS_KEY = "dyndns.key";
|
|
||||||
public static final String SYSTEM_PROPERTY_DYNDNS_ZONE = "dyndns.zone";
|
|
||||||
public static final String SYSTEM_PROPERTY_DYNDNS_TTL = "dyndns.ttl";
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(DyndnsManager.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SystemPropertyManager systemPropertyManager;
|
|
||||||
|
|
||||||
public void setRecord(String name, Optional<String> ip, Optional<String> ipv6) throws Exception {
|
|
||||||
String zoneValue = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_ZONE);
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(zoneValue)) {
|
|
||||||
logger.warn("Missing DynDNS zone, cannot set record");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long ttl = systemPropertyManager.getLong(SYSTEM_PROPERTY_DYNDNS_TTL, 300);
|
|
||||||
|
|
||||||
Name zone = Name.fromString(zoneValue);
|
|
||||||
Name host = Name.fromString(name.toLowerCase(), zone);
|
|
||||||
Update update = new Update(zone);
|
|
||||||
if (ip.isPresent()) {
|
|
||||||
update.replace(host, Type.A, ttl, ip.get());
|
|
||||||
}
|
|
||||||
if (ipv6.isPresent()) {
|
|
||||||
update.replace(host, Type.AAAA, ttl, ipv6.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
String hostname = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_HOSTNAME, "127.0.0.1");
|
|
||||||
String keyName = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_KEY_NAME, "");
|
|
||||||
String key = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_KEY, "");
|
|
||||||
|
|
||||||
Resolver res = new SimpleResolver(hostname);
|
|
||||||
res.setTSIGKey(new TSIG(TSIG.HMAC_SHA512, keyName, key));
|
|
||||||
res.setTCP(true);
|
|
||||||
|
|
||||||
Message response = res.send(update);
|
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
"\nDynDNS for '" + name + "' with\nIP:\t" + ip.orElse("-") + "\nIPV6:\t" + ipv6.orElse("-") + "\n\n" +
|
|
||||||
response.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -12,12 +12,18 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.xbill.DNS.Name;
|
||||||
|
import org.xbill.DNS.Resolver;
|
||||||
|
import org.xbill.DNS.SimpleResolver;
|
||||||
|
import org.xbill.DNS.TSIG;
|
||||||
|
import org.xbill.DNS.Type;
|
||||||
|
import org.xbill.DNS.Update;
|
||||||
|
|
||||||
import de.bstly.we.businesslogic.PermissionManager;
|
import de.bstly.we.businesslogic.PermissionManager;
|
||||||
|
import de.bstly.we.businesslogic.SystemPropertyManager;
|
||||||
import de.bstly.we.businesslogic.UserAliasManager;
|
import de.bstly.we.businesslogic.UserAliasManager;
|
||||||
import de.bstly.we.controller.BaseController;
|
import de.bstly.we.controller.BaseController;
|
||||||
import de.bstly.we.controller.support.EntityResponseStatusException;
|
import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||||
import de.bstly.we.dyndns.businesslogic.DyndnsManager;
|
|
||||||
import de.bstly.we.dyndns.businesslogic.DyndnsTokenManager;
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenManager;
|
||||||
import de.bstly.we.dyndns.businesslogic.DyndnsTokenPermissions;
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenPermissions;
|
||||||
import de.bstly.we.dyndns.model.DyndnsToken;
|
import de.bstly.we.dyndns.model.DyndnsToken;
|
||||||
@ -30,16 +36,19 @@ import de.bstly.we.model.User;
|
|||||||
@RequestMapping("/dyndns")
|
@RequestMapping("/dyndns")
|
||||||
public class DyndnsController extends BaseController {
|
public class DyndnsController extends BaseController {
|
||||||
|
|
||||||
|
public static final String SYSTEM_PROPERTY_DYNDNS_HOSTNAME = "dyndns.hostname";
|
||||||
|
public static final String SYSTEM_PROPERTY_DYNDNS_KEY = "dyndns.key";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserAliasManager userAliasManager;
|
private UserAliasManager userAliasManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DyndnsTokenManager dyndnsTokenManager;
|
private DyndnsTokenManager dyndnsTokenManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DyndnsManager dyndnsManager;
|
|
||||||
@Autowired
|
|
||||||
private PermissionManager permissionManager;
|
private PermissionManager permissionManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
@Autowired
|
||||||
|
private SystemPropertyManager systemPropertyManager;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public void updateDns(@RequestParam("username") String name, @RequestParam("token") String token,
|
public void updateDns(@RequestParam("username") String name, @RequestParam("token") String token,
|
||||||
@ -69,9 +78,25 @@ public class DyndnsController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dyndnsManager.setRecord(name, ip, ipv6);
|
Name zone = Name.fromString(name + ".we.bstly.de.");
|
||||||
|
Name host = Name.fromString("host", zone);
|
||||||
|
Update update = new Update(zone);
|
||||||
|
if (ip.isPresent()) {
|
||||||
|
update.replace(host, Type.A, 3600, ip.get());
|
||||||
|
}
|
||||||
|
if (ipv6.isPresent()) {
|
||||||
|
update.replace(host, Type.AAAA, 3600, ipv6.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
String hostname = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_HOSTNAME, "127.0.0.1");
|
||||||
|
String key = systemPropertyManager.get(SYSTEM_PROPERTY_DYNDNS_KEY, "");
|
||||||
|
|
||||||
|
Resolver res = new SimpleResolver(hostname);
|
||||||
|
res.setTSIGKey(new TSIG(TSIG.HMAC_SHA512, host, key));
|
||||||
|
res.setTCP(true);
|
||||||
|
|
||||||
|
res.send(update);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY);
|
throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ public class Invite implements UserData {
|
|||||||
private Instant starts;
|
private Instant starts;
|
||||||
private Instant expires;
|
private Instant expires;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String message;
|
private String message;
|
||||||
private String note;
|
private String note;
|
||||||
private boolean redeemed;
|
private boolean redeemed;
|
||||||
|
@ -37,22 +37,17 @@ public class JitsiRoom implements UserData {
|
|||||||
private Instant expires;
|
private Instant expires;
|
||||||
@Lob
|
@Lob
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Column(length = 100000)
|
|
||||||
private String token;
|
private String token;
|
||||||
@Lob
|
@Lob
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Column(length = 100000)
|
|
||||||
private String moderationToken;
|
private String moderationToken;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String url;
|
private String url;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String moderationUrl;
|
private String moderationUrl;
|
||||||
@Reference
|
@Reference
|
||||||
private String code;
|
private String code;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String orgUrl;
|
private String orgUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,27 +458,11 @@ public class MembershipManager {
|
|||||||
|
|
||||||
membershipFeeOrder = pretixManager.createOrder(membershipFeeOrder);
|
membershipFeeOrder = pretixManager.createOrder(membershipFeeOrder);
|
||||||
|
|
||||||
|
JsonObject expire = new JsonObject();
|
||||||
|
expire.addProperty("expires", pretixDateFormat.format(Date.from(expires)));
|
||||||
|
membershipFeeOrder = pretixManager.extendOrder(membershipFeeOrder.get("code").getAsString(), expire);
|
||||||
|
|
||||||
logger.debug("Create membership fee order: " + membershipFeeOrder.toString());
|
logger.debug("Create membership fee order: " + membershipFeeOrder.toString());
|
||||||
|
|
||||||
/*
|
|
||||||
* JsonObject expire = new JsonObject();
|
|
||||||
* expire.addProperty("expires", pretixDateFormat.format(Date.from(expires)));
|
|
||||||
* membershipFeeOrder =
|
|
||||||
* pretixManager.extendOrder(membershipFeeOrder.get("code").getAsString(),
|
|
||||||
* expire);
|
|
||||||
*
|
|
||||||
* logger.debug("Extend membership fee order: " +
|
|
||||||
* membershipFeeOrder.get("code").getAsString() + " to "
|
|
||||||
* + pretixDateFormat.format(Date.from(expires)));
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if (orderSendmail) {
|
|
||||||
* pretixManager.sendEmail(membershipFeeOrder.get("code").getAsString());
|
|
||||||
* logger.debug("Resend link membership fee order: " +
|
|
||||||
* membershipFeeOrder.get("code").getAsString());
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
} else
|
} else
|
||||||
// send reminder mail for membership fee order
|
// send reminder mail for membership fee order
|
||||||
if (membershipfeeReminderDays > 0 && membershipfeeReminderQuestion > 0
|
if (membershipfeeReminderDays > 0 && membershipfeeReminderQuestion > 0
|
||||||
|
@ -17,13 +17,5 @@
|
|||||||
<artifactId>webstly-core</artifactId>
|
<artifactId>webstly-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Query DSL -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.querydsl</groupId>
|
|
||||||
<artifactId>querydsl-apt</artifactId>
|
|
||||||
<version>${querydsl.version}</version>
|
|
||||||
<classifier>jakarta</classifier>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -24,7 +24,7 @@ public class MinetestAccount implements UserData {
|
|||||||
@Column(name = "owner")
|
@Column(name = "owner")
|
||||||
private Long owner;
|
private Long owner;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "skin", length = 100000)
|
@Column(name = "skin")
|
||||||
private String skin;
|
private String skin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ public class ParteyUserReport {
|
|||||||
private Long reporter;
|
private Long reporter;
|
||||||
private Long user;
|
private Long user;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String comment;
|
private String comment;
|
||||||
private String world;
|
private String world;
|
||||||
private Instant created;
|
private Instant created;
|
||||||
|
@ -43,8 +43,8 @@ public class Timeslot implements UserData {
|
|||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
@Column(name = "title", nullable = true)
|
@Column(name = "title", nullable = true)
|
||||||
private String title;
|
private String title;
|
||||||
|
@Column(name = "description", nullable = true)
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "description", nullable = true, length = 100000)
|
|
||||||
private String description;
|
private String description;
|
||||||
@Column(name = "share", nullable = true)
|
@Column(name = "share", nullable = true)
|
||||||
private String share;
|
private String share;
|
||||||
|
5
pom.xml
5
pom.xml
@ -14,13 +14,13 @@
|
|||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<querydsl.version>5.0.0</querydsl.version>
|
<querydsl.version>5.0.0</querydsl.version>
|
||||||
<nimbus.version>9.37.3</nimbus.version>
|
<nimbus.version>9.37.3</nimbus.version>
|
||||||
<revision>3.0.6-SNAPSHOT</revision>
|
<revision>3.0.0-SNAPSHOT</revision>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.2.0</version>
|
||||||
<relativePath />
|
<relativePath />
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@ -28,7 +28,6 @@
|
|||||||
<module>application</module>
|
<module>application</module>
|
||||||
<module>borrow</module>
|
<module>borrow</module>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>developer</module>
|
|
||||||
<module>dyndns</module>
|
<module>dyndns</module>
|
||||||
<module>email</module>
|
<module>email</module>
|
||||||
<module>i18n</module>
|
<module>i18n</module>
|
||||||
|
@ -34,7 +34,6 @@ public class ShortenedUrl implements UserData {
|
|||||||
private String code;
|
private String code;
|
||||||
private Long owner;
|
private Long owner;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String url;
|
private String url;
|
||||||
private Instant expires;
|
private Instant expires;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ -42,7 +41,6 @@ public class ShortenedUrl implements UserData {
|
|||||||
private String passwordHash;
|
private String passwordHash;
|
||||||
private String link;
|
private String link;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(length = 100000)
|
|
||||||
private String note;
|
private String note;
|
||||||
@Column(name = "addon", columnDefinition = "boolean default false")
|
@Column(name = "addon", columnDefinition = "boolean default false")
|
||||||
private boolean queryParameters;
|
private boolean queryParameters;
|
||||||
|
Loading…
Reference in New Issue
Block a user