upgrade spring boot and dependencies, migrate spring boot, add dyndns draft
This commit is contained in:
parent
9ea02f8208
commit
5286d4f171
@ -22,6 +22,11 @@
|
|||||||
<artifactId>webstly-core</artifactId>
|
<artifactId>webstly-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.bstly.we</groupId>
|
||||||
|
<artifactId>webstly-dyndns</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.bstly.we</groupId>
|
<groupId>de.bstly.we</groupId>
|
||||||
<artifactId>webstly-email</artifactId>
|
<artifactId>webstly-email</artifactId>
|
||||||
|
@ -15,6 +15,7 @@ import org.springframework.util.Assert;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import de.bstly.we.model.QUserAlias;
|
import de.bstly.we.model.QUserAlias;
|
||||||
|
import de.bstly.we.model.User;
|
||||||
import de.bstly.we.model.UserAlias;
|
import de.bstly.we.model.UserAlias;
|
||||||
import de.bstly.we.model.UserData;
|
import de.bstly.we.model.UserData;
|
||||||
import de.bstly.we.repository.UserAliasRepository;
|
import de.bstly.we.repository.UserAliasRepository;
|
||||||
@ -110,6 +111,19 @@ public class UserAliasManager implements UserDataProvider {
|
|||||||
return userAliasRepository.findAll(PageRequest.of(page, size, sort));
|
return userAliasRepository.findAll(PageRequest.of(page, size, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User getUser(String name) {
|
||||||
|
User user = userManager.getByUsername(name);
|
||||||
|
|
||||||
|
if (user == null) {
|
||||||
|
UserAlias userAlias = getByAlias(name);
|
||||||
|
if (userAlias != null) {
|
||||||
|
user = userManager.get(userAlias.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
|
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
|
||||||
*/
|
*/
|
||||||
|
@ -5,8 +5,8 @@ package de.bstly.we.controller;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.SplittableRandom;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -124,6 +124,7 @@ public class UserProfileFieldController extends BaseController {
|
|||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throttleForbidden();
|
throttleForbidden();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UserProfileField> profileFields = Lists.newArrayList();
|
List<UserProfileField> profileFields = Lists.newArrayList();
|
||||||
@ -188,18 +189,21 @@ public class UserProfileFieldController extends BaseController {
|
|||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throttleForbidden();
|
throttleForbidden();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserProfileField userProfileField = userProfileFieldManager.get(user.getId(), name);
|
UserProfileField userProfileField = userProfileFieldManager.get(user.getId(), name);
|
||||||
|
|
||||||
if (userProfileField == null) {
|
if (userProfileField == null) {
|
||||||
throttleForbidden();
|
throttleForbidden();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long currentUserId = getCurrentUserId();
|
Long currentUserId = getCurrentUserId();
|
||||||
|
|
||||||
if (currentUserId == null && !Visibility.PUBLIC.equals(userProfileField.getVisibility())) {
|
if (currentUserId == null && !Visibility.PUBLIC.equals(userProfileField.getVisibility())) {
|
||||||
throttleForbidden();
|
throttleForbidden();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUserId != null && !currentUserId.equals(user.getId())
|
if (currentUserId != null && !currentUserId.equals(user.getId())
|
||||||
@ -284,7 +288,7 @@ public class UserProfileFieldController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
protected void throttleForbidden() {
|
protected void throttleForbidden() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(RandomUtils.nextInt(10, 500));
|
Thread.sleep(new SplittableRandom().nextInt(10, 500));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ package de.bstly.we.controller.support;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.NestedExceptionUtils;
|
|
||||||
import org.springframework.core.NestedRuntimeException;
|
import org.springframework.core.NestedRuntimeException;
|
||||||
import org.springframework.http.HttpStatusCode;
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -82,8 +81,7 @@ public class EntityResponseStatusException extends NestedRuntimeException {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
String msg = this.status + (this.body != null ? " \"" + this.body + "\"" : "");
|
return this.status + (this.body != null ? " \"" + this.body + "\"" : "");
|
||||||
return NestedExceptionUtils.buildMessage(msg, getCause());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,12 @@ import jakarta.persistence.Convert;
|
|||||||
import jakarta.persistence.Converter;
|
import jakarta.persistence.Converter;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class PermissionMapping.
|
* The Class PermissionMapping.
|
||||||
*/
|
*/
|
||||||
@ -39,8 +37,7 @@ public class PermissionMapping {
|
|||||||
private String product;
|
private String product;
|
||||||
@Column(name = "item", nullable = false)
|
@Column(name = "item", nullable = false)
|
||||||
private Integer item;
|
private Integer item;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "permission_mappings_names")
|
@CollectionTable(name = "permission_mappings_names")
|
||||||
private Set<String> names;
|
private Set<String> names;
|
||||||
@Column(name = "addon", columnDefinition = "boolean default false")
|
@Column(name = "addon", columnDefinition = "boolean default false")
|
||||||
|
@ -9,14 +9,12 @@ import jakarta.persistence.CollectionTable;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class QuotaMapping.
|
* The Class QuotaMapping.
|
||||||
*/
|
*/
|
||||||
@ -28,12 +26,10 @@ public class QuotaMapping {
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id", updatable = false)
|
@Column(name = "id", updatable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "quota_mappings_products")
|
@CollectionTable(name = "quota_mappings_products")
|
||||||
private Set<String> products;
|
private Set<String> products;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "quota_mappings_items")
|
@CollectionTable(name = "quota_mappings_items")
|
||||||
private Set<Integer> items;
|
private Set<Integer> items;
|
||||||
@Column(name = "name", nullable = false)
|
@Column(name = "name", nullable = false)
|
||||||
|
@ -20,7 +20,7 @@ public class SystemProperty {
|
|||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
private String key;
|
private String key;
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "value")
|
@Column(name = "value", length = 100000)
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,15 +9,13 @@ import jakarta.persistence.CollectionTable;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class UserTotp.
|
* The Class UserTotp.
|
||||||
*/
|
*/
|
||||||
@ -35,8 +33,7 @@ public class UserTotp implements SecondFactor {
|
|||||||
private String secret;
|
private String secret;
|
||||||
@Column(name = "totp_qr_data", nullable = false)
|
@Column(name = "totp_qr_data", nullable = false)
|
||||||
private String qrData;
|
private String qrData;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "user_totps_recovery_codes")
|
@CollectionTable(name = "user_totps_recovery_codes")
|
||||||
private List<String> recoveryCodes;
|
private List<String> recoveryCodes;
|
||||||
|
|
||||||
|
@ -90,19 +90,22 @@ public class SecurityConfig {
|
|||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
// anonymous
|
// anonymous
|
||||||
.anonymous().authenticationFilter(localAnonymousAuthenticationFilter()).and()
|
.anonymous((anonymous) -> anonymous.authenticationFilter(localAnonymousAuthenticationFilter()))
|
||||||
// session
|
// session
|
||||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
|
.sessionManagement((anonymous) -> anonymous.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
|
||||||
.sessionAuthenticationStrategy(new SessionFixationProtectionStrategy()).and()
|
.sessionAuthenticationStrategy(new SessionFixationProtectionStrategy()))
|
||||||
// disable deprectated xss protection
|
// disable deprectated xss protection, x-frame
|
||||||
.headers().xssProtection().disable().and()
|
.headers((headers) -> headers.xssProtection((xssProtection) -> xssProtection.disable())
|
||||||
|
.frameOptions((frameOptions) -> frameOptions.disable()
|
||||||
|
.referrerPolicy((referrerPolicy) -> referrerPolicy.policy(ReferrerPolicy.UNSAFE_URL))))
|
||||||
// form login
|
// form login
|
||||||
.formLogin().loginPage(loginUrl).usernameParameter("username").passwordParameter("password")
|
.formLogin((formLogin) -> formLogin.loginPage(loginUrl).usernameParameter("username")
|
||||||
|
.passwordParameter("password")
|
||||||
.loginProcessingUrl("/auth/login").defaultSuccessUrl(loginTargetUrl)
|
.loginProcessingUrl("/auth/login").defaultSuccessUrl(loginTargetUrl)
|
||||||
.successHandler(formAuthenticationSuccessHandler())
|
.successHandler(formAuthenticationSuccessHandler())
|
||||||
.failureHandler(new SimpleUrlAuthenticationFailureHandler(loginUrl + "?error")).and()
|
.failureHandler(new SimpleUrlAuthenticationFailureHandler(loginUrl + "?error")))
|
||||||
// remember me
|
// remember me
|
||||||
.rememberMe().rememberMeServices(rememberMeServices()).and()
|
.rememberMe((rememberMe) -> rememberMe.rememberMeServices(rememberMeServices()))
|
||||||
// form totp
|
// form totp
|
||||||
.addFilterBefore(formSecondFactorAuthenticationFilter(http), LocalAnonymousAuthenticationFilter.class)
|
.addFilterBefore(formSecondFactorAuthenticationFilter(http), LocalAnonymousAuthenticationFilter.class)
|
||||||
// rest login
|
// rest login
|
||||||
@ -110,21 +113,20 @@ public class SecurityConfig {
|
|||||||
// rest totp
|
// rest totp
|
||||||
.addFilterAfter(restSecondFactorAuthenticationFilter(http), UsernamePasswordAuthenticationFilter.class)
|
.addFilterAfter(restSecondFactorAuthenticationFilter(http), UsernamePasswordAuthenticationFilter.class)
|
||||||
// Logout
|
// Logout
|
||||||
.logout().logoutUrl("/auth/logout").logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler())
|
.logout((logout) -> logout.logoutUrl("/auth/logout")
|
||||||
.and()
|
.logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()))
|
||||||
// exception
|
// exception
|
||||||
.exceptionHandling().accessDeniedHandler(localAccessDeniedHandler)
|
.exceptionHandling(
|
||||||
.authenticationEntryPoint(localAuthenticationEntryPoint()).and()
|
(exceptionHandling) -> exceptionHandling.accessDeniedHandler(localAccessDeniedHandler)
|
||||||
|
.authenticationEntryPoint(localAuthenticationEntryPoint()))
|
||||||
// crsf
|
// crsf
|
||||||
.csrf().disable()
|
.csrf((csrf) -> csrf.disable());
|
||||||
// x-frame
|
|
||||||
.headers().frameOptions().disable().referrerPolicy(ReferrerPolicy.UNSAFE_URL);
|
|
||||||
|
|
||||||
if (disableCors) {
|
if (disableCors) {
|
||||||
http.cors().disable();
|
http.cors((cors) -> cors.disable());
|
||||||
} else if (!allowedOriginPatterns.isEmpty()) {
|
} else if (!allowedOriginPatterns.isEmpty()) {
|
||||||
// cors
|
// cors
|
||||||
http.cors().configurationSource(corsConfigurationSource());
|
http.cors((cors) -> cors.configurationSource(corsConfigurationSource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
|
35
dyndns/pom.xml
Executable file
35
dyndns/pom.xml
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
|
<name>dyndns</name>
|
||||||
|
<artifactId>webstly-dyndns</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.bstly.we</groupId>
|
||||||
|
<artifactId>webstly-core</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dnsjava</groupId>
|
||||||
|
<artifactId>dnsjava</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Query DSL -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.querydsl</groupId>
|
||||||
|
<artifactId>querydsl-apt</artifactId>
|
||||||
|
<version>${querydsl.version}</version>
|
||||||
|
<classifier>jakarta</classifier>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,128 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.businesslogic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import de.bstly.we.businesslogic.QuotaManager;
|
||||||
|
import de.bstly.we.businesslogic.UserDataProvider;
|
||||||
|
import de.bstly.we.dyndns.model.DyndnsToken;
|
||||||
|
import de.bstly.we.dyndns.repository.DyndnsTokenRepository;
|
||||||
|
import de.bstly.we.model.Quota;
|
||||||
|
import de.bstly.we.model.UserData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DyndnsTokenManager.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class DyndnsTokenManager implements UserDataProvider {
|
||||||
|
|
||||||
|
public static final int TOKEN_LENGTH = 32;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PasswordEncoder passwordEncoder;
|
||||||
|
@Autowired
|
||||||
|
private QuotaManager quotaManager;
|
||||||
|
@Autowired
|
||||||
|
private DyndnsTokenRepository dyndnsTokenRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the.
|
||||||
|
*
|
||||||
|
* @param code the code
|
||||||
|
* @return the shortened url
|
||||||
|
*/
|
||||||
|
public DyndnsToken get(Long owner) {
|
||||||
|
return dyndnsTokenRepository.findById(owner).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the.
|
||||||
|
*
|
||||||
|
* @param owner the owner
|
||||||
|
* @param quota the quota
|
||||||
|
* @return the shortened url
|
||||||
|
*/
|
||||||
|
public DyndnsToken create(Long owner, boolean quota) {
|
||||||
|
DyndnsToken dyndnsToken = new DyndnsToken();
|
||||||
|
String token = RandomStringUtils.random(TOKEN_LENGTH, true, true);
|
||||||
|
dyndnsToken.setOwner(owner);
|
||||||
|
dyndnsToken.setToken(token);
|
||||||
|
dyndnsToken.setTokenHash(passwordEncoder.encode(dyndnsToken.getToken()));
|
||||||
|
|
||||||
|
dyndnsToken = dyndnsTokenRepository.save(dyndnsToken);
|
||||||
|
|
||||||
|
if (quota) {
|
||||||
|
Quota dyndnsTokensQuota = quotaManager.get(dyndnsToken.getOwner(), DyndnsTokenQuotas.DYNDNS);
|
||||||
|
if (dyndnsTokensQuota != null) {
|
||||||
|
dyndnsTokensQuota.setValue(dyndnsTokensQuota.getValue() - 1);
|
||||||
|
quotaManager.update(dyndnsTokensQuota);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dyndnsToken.setToken(token);
|
||||||
|
return dyndnsToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete.
|
||||||
|
*
|
||||||
|
* @param dyndnsToken the shortened url
|
||||||
|
* @param quota the quota
|
||||||
|
*/
|
||||||
|
public void delete(DyndnsToken dyndnsToken, boolean quota) {
|
||||||
|
if (quota) {
|
||||||
|
Quota dyndnsTokensQuota = quotaManager.get(dyndnsToken.getOwner(), DyndnsTokenQuotas.DYNDNS);
|
||||||
|
if (dyndnsTokensQuota == null) {
|
||||||
|
dyndnsTokensQuota = quotaManager.create(dyndnsToken.getOwner(), DyndnsTokenQuotas.DYNDNS, 0,
|
||||||
|
"#", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
dyndnsTokensQuota.setValue(dyndnsTokensQuota.getValue() + 1);
|
||||||
|
quotaManager.update(dyndnsTokensQuota);
|
||||||
|
}
|
||||||
|
|
||||||
|
dyndnsTokenRepository.delete(dyndnsToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return "dyndns-tokens";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<UserData> getUserData(Long userId) {
|
||||||
|
List<UserData> result = Lists.newArrayList();
|
||||||
|
DyndnsToken dyndnsToken = get(userId);
|
||||||
|
if (dyndnsToken != null) {
|
||||||
|
result.add(dyndnsToken);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void purgeUserData(Long userId) {
|
||||||
|
DyndnsToken dyndnsToken = get(userId);
|
||||||
|
if (dyndnsToken != null) {
|
||||||
|
dyndnsTokenRepository.delete(dyndnsToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.businesslogic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface DyndnsTokenPermissions.
|
||||||
|
*/
|
||||||
|
public interface DyndnsTokenPermissions {
|
||||||
|
public static final String DYNDNS = "dyndns";
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.businesslogic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface DyndnsTokenQuotas.
|
||||||
|
*/
|
||||||
|
public interface DyndnsTokenQuotas {
|
||||||
|
|
||||||
|
public static final String DYNDNS = "dyndns";
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.controller;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
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.SystemPropertyManager;
|
||||||
|
import de.bstly.we.businesslogic.UserAliasManager;
|
||||||
|
import de.bstly.we.controller.BaseController;
|
||||||
|
import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||||
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenManager;
|
||||||
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenPermissions;
|
||||||
|
import de.bstly.we.dyndns.model.DyndnsToken;
|
||||||
|
import de.bstly.we.model.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DyndnsController.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dyndns")
|
||||||
|
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
|
||||||
|
private UserAliasManager userAliasManager;
|
||||||
|
@Autowired
|
||||||
|
private DyndnsTokenManager dyndnsTokenManager;
|
||||||
|
@Autowired
|
||||||
|
private PermissionManager permissionManager;
|
||||||
|
@Autowired
|
||||||
|
private PasswordEncoder passwordEncoder;
|
||||||
|
@Autowired
|
||||||
|
private SystemPropertyManager systemPropertyManager;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public void updateDns(@RequestParam("username") String name, @RequestParam("token") String token,
|
||||||
|
@RequestParam("ip") Optional<String> ip, @RequestParam("ipv6") Optional<String> ipv6) {
|
||||||
|
User user = userAliasManager.getUser(name);
|
||||||
|
|
||||||
|
if (user == null) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!permissionManager.hasPermission(user.getId(), DyndnsTokenPermissions.DYNDNS)
|
||||||
|
|| !permissionManager.isFullUser(user.getId())) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
DyndnsToken dyndnsToken = dyndnsTokenManager.get(user.getId());
|
||||||
|
if (dyndnsToken == null) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.PRECONDITION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!passwordEncoder.matches(token, dyndnsToken.getTokenHash())) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ip.isEmpty() && ipv6.isEmpty()) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
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) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.controller;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import de.bstly.we.businesslogic.PermissionManager;
|
||||||
|
import de.bstly.we.businesslogic.QuotaManager;
|
||||||
|
import de.bstly.we.controller.BaseController;
|
||||||
|
import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||||
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenManager;
|
||||||
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenPermissions;
|
||||||
|
import de.bstly.we.dyndns.businesslogic.DyndnsTokenQuotas;
|
||||||
|
import de.bstly.we.dyndns.model.DyndnsToken;
|
||||||
|
import de.bstly.we.model.Quota;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DyndnsTokenController.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dyndns/token")
|
||||||
|
public class DyndnsTokenController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DyndnsTokenManager dyndnsTokenManager;
|
||||||
|
@Autowired
|
||||||
|
private PermissionManager permissionManager;
|
||||||
|
@Autowired
|
||||||
|
private QuotaManager quotaManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the shortened url.
|
||||||
|
* @return the shortened url
|
||||||
|
*/
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@GetMapping()
|
||||||
|
public DyndnsToken getDyndnsToken() {
|
||||||
|
DyndnsToken dyndnsToken = dyndnsTokenManager.get(getCurrentUserId());
|
||||||
|
if (dyndnsToken == null) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.hasText(dyndnsToken.getTokenHash())) {
|
||||||
|
dyndnsToken.setTokenHash(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dyndnsToken;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the shortened url.
|
||||||
|
* @return the shortened url
|
||||||
|
*/
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@PostMapping
|
||||||
|
public DyndnsToken createDyndnsToken() {
|
||||||
|
if (!permissionManager.hasPermission(getCurrentUserId(), DyndnsTokenPermissions.DYNDNS)
|
||||||
|
|| !permissionManager.isFullUser(getCurrentUserId())) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
DyndnsToken dyndnsToken = dyndnsTokenManager.get(getCurrentUserId());
|
||||||
|
if (dyndnsToken != null) {
|
||||||
|
dyndnsTokenManager.delete(dyndnsToken, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Quota shortenedUrlsQuota = quotaManager.get(getCurrentUserId(), DyndnsTokenQuotas.DYNDNS);
|
||||||
|
if (shortenedUrlsQuota == null || shortenedUrlsQuota.getValue() < 1) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dyndnsTokenManager.create(getCurrentUserId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete shortened url.
|
||||||
|
*/
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@DeleteMapping
|
||||||
|
public void deleteDyndnsToken() {
|
||||||
|
if (!permissionManager.hasPermission(getCurrentUserId(), DyndnsTokenPermissions.DYNDNS)
|
||||||
|
|| !permissionManager.isFullUser(getCurrentUserId())) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
DyndnsToken dyndnsToken = dyndnsTokenManager.get(getCurrentUserId());
|
||||||
|
if (dyndnsToken != null) {
|
||||||
|
dyndnsTokenManager.delete(dyndnsToken, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import de.bstly.we.controller.BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DyndnsTokenManagementController.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dyndns/token/manage")
|
||||||
|
public class DyndnsTokenManagementController extends BaseController {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
import de.bstly.we.businesslogic.support.AbstractModelEventListener;
|
||||||
|
import de.bstly.we.model.UserData;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.persistence.Transient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DyndnsToken.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "dyndns_tokens")
|
||||||
|
@EntityListeners(AbstractModelEventListener.class)
|
||||||
|
public class DyndnsToken implements UserData {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "owner")
|
||||||
|
private Long owner;
|
||||||
|
@JsonIgnore
|
||||||
|
@Column(name = "token", nullable = true)
|
||||||
|
private String tokenHash;
|
||||||
|
@Transient
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the owner.
|
||||||
|
*
|
||||||
|
* @return the owner
|
||||||
|
*/
|
||||||
|
public Long getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the owner.
|
||||||
|
*
|
||||||
|
* @param owner the new owner
|
||||||
|
*/
|
||||||
|
public void setOwner(Long owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the token hash.
|
||||||
|
*
|
||||||
|
* @return the token hash
|
||||||
|
*/
|
||||||
|
public String getTokenHash() {
|
||||||
|
return tokenHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the token hash.
|
||||||
|
*
|
||||||
|
* @param tokenHash the new token hash
|
||||||
|
*/
|
||||||
|
public void setTokenHash(String tokenHash) {
|
||||||
|
this.tokenHash = tokenHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the token.
|
||||||
|
*
|
||||||
|
* @return the token
|
||||||
|
*/
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the token.
|
||||||
|
*
|
||||||
|
* @param token the new token
|
||||||
|
*/
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package de.bstly.we.dyndns.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import de.bstly.we.dyndns.model.DyndnsToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface DyndnsTokenRepository.
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface DyndnsTokenRepository
|
||||||
|
extends JpaRepository<DyndnsToken, Long>, QuerydslPredicateExecutor<DyndnsToken> {
|
||||||
|
}
|
@ -28,7 +28,7 @@ public class I18n {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "label")
|
@Column(name = "label", length = 100000)
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,19 +5,18 @@ package de.bstly.we.jwt.model;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import com.nimbusds.jose.JWSAlgorithm;
|
||||||
|
import com.nimbusds.jose.jwk.Curve;
|
||||||
|
import com.nimbusds.jose.jwk.KeyType;
|
||||||
|
import com.nimbusds.jose.jwk.KeyUse;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Lob;
|
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import com.nimbusds.jose.JWSAlgorithm;
|
|
||||||
import com.nimbusds.jose.jwk.Curve;
|
|
||||||
import com.nimbusds.jose.jwk.KeyType;
|
|
||||||
import com.nimbusds.jose.jwk.KeyUse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class JwtKey.
|
* The Class JwtKey.
|
||||||
*/
|
*/
|
||||||
|
@ -9,14 +9,12 @@ import jakarta.persistence.CollectionTable;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class OidcAuthorization.
|
* The Class OidcAuthorization.
|
||||||
*/
|
*/
|
||||||
@ -32,8 +30,7 @@ public class OidcAuthorization {
|
|||||||
private Long client;
|
private Long client;
|
||||||
@Column(name = "subject")
|
@Column(name = "subject")
|
||||||
private Long subject;
|
private Long subject;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "oidc_authorizations_scopes")
|
@CollectionTable(name = "oidc_authorizations_scopes")
|
||||||
private Set<String> scopes;
|
private Set<String> scopes;
|
||||||
|
|
||||||
|
@ -5,23 +5,20 @@ package de.bstly.we.oidc.model;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import de.bstly.we.oidc.businesslogic.model.OidcAuthorizationGrantType;
|
||||||
|
import de.bstly.we.oidc.businesslogic.model.OidcClientAuthenticationMethod;
|
||||||
import jakarta.persistence.CollectionTable;
|
import jakarta.persistence.CollectionTable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
import de.bstly.we.oidc.businesslogic.model.OidcAuthorizationGrantType;
|
|
||||||
import de.bstly.we.oidc.businesslogic.model.OidcClientAuthenticationMethod;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class OidcClient.
|
* The Class OidcClient.
|
||||||
*/
|
*/
|
||||||
@ -39,22 +36,18 @@ public class OidcClient {
|
|||||||
private String clientId;
|
private String clientId;
|
||||||
@Column(name = "client_secret")
|
@Column(name = "client_secret")
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "oidc_clients_methods")
|
@CollectionTable(name = "oidc_clients_methods")
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Set<OidcClientAuthenticationMethod> clientAuthenticationMethods;
|
private Set<OidcClientAuthenticationMethod> clientAuthenticationMethods;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "oidc_clients_grant_types")
|
@CollectionTable(name = "oidc_clients_grant_types")
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Set<OidcAuthorizationGrantType> authorizationGrantTypes;
|
private Set<OidcAuthorizationGrantType> authorizationGrantTypes;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "oidc_clients_redirect_uris")
|
@CollectionTable(name = "oidc_clients_redirect_uris")
|
||||||
private Set<String> redirectUris;
|
private Set<String> redirectUris;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "oidc_clients_scopes")
|
@CollectionTable(name = "oidc_clients_scopes")
|
||||||
private Set<String> scopes;
|
private Set<String> scopes;
|
||||||
@Column(name = "token_lifetime")
|
@Column(name = "token_lifetime")
|
||||||
|
@ -6,19 +6,17 @@ package de.bstly.we.oidc.model;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class OidcToken.
|
* The Class OidcToken.
|
||||||
*/
|
*/
|
||||||
@ -47,8 +45,7 @@ public class OidcToken {
|
|||||||
@Column(name = "id_token", length = 4000)
|
@Column(name = "id_token", length = 4000)
|
||||||
private String idToken;
|
private String idToken;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
private Set<String> scopes;
|
private Set<String> scopes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,19 +5,17 @@ package de.bstly.we.partey.model;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import jakarta.persistence.CollectionTable;
|
import jakarta.persistence.CollectionTable;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ParteyMap.
|
* The Class ParteyMap.
|
||||||
*/
|
*/
|
||||||
@ -29,8 +27,7 @@ public class ParteyMap {
|
|||||||
private String id;
|
private String id;
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private GameRoomPolicyTypes policyType = GameRoomPolicyTypes.MEMBERS_ONLY_POLICY;
|
private GameRoomPolicyTypes policyType = GameRoomPolicyTypes.MEMBERS_ONLY_POLICY;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "partey_maps_tags")
|
@CollectionTable(name = "partey_maps_tags")
|
||||||
private List<String> tags = Lists.newArrayList();
|
private List<String> tags = Lists.newArrayList();
|
||||||
|
|
||||||
|
@ -5,20 +5,17 @@ package de.bstly.we.partey.model;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import de.bstly.we.model.UserData;
|
||||||
import jakarta.persistence.CollectionTable;
|
import jakarta.persistence.CollectionTable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import de.bstly.we.model.UserData;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ParteyUserTextures.
|
* The Class ParteyUserTextures.
|
||||||
*/
|
*/
|
||||||
@ -30,8 +27,7 @@ public class ParteyUserTextures implements UserData {
|
|||||||
private Long target;
|
private Long target;
|
||||||
@Column(name = "username", nullable = false)
|
@Column(name = "username", nullable = false)
|
||||||
private String username;
|
private String username;
|
||||||
@ElementCollection
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@CollectionTable(name = "partey_user_textures_list")
|
@CollectionTable(name = "partey_user_textures_list")
|
||||||
private List<String> textures = Lists.newArrayList();
|
private List<String> textures = Lists.newArrayList();
|
||||||
|
|
||||||
|
4
pom.xml
4
pom.xml
@ -13,8 +13,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<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.1</nimbus.version>
|
<nimbus.version>9.37.3</nimbus.version>
|
||||||
<hibernate.version>6.4.0.Final</hibernate.version>
|
|
||||||
<revision>3.0.0-SNAPSHOT</revision>
|
<revision>3.0.0-SNAPSHOT</revision>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -29,6 +28,7 @@
|
|||||||
<module>application</module>
|
<module>application</module>
|
||||||
<module>borrow</module>
|
<module>borrow</module>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
|
<module>dyndns</module>
|
||||||
<module>email</module>
|
<module>email</module>
|
||||||
<module>i18n</module>
|
<module>i18n</module>
|
||||||
<module>invite</module>
|
<module>invite</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user