From 116767f27fcbbb7288d97ae5c214ff105b4a853c Mon Sep 17 00:00:00 2001 From: SebClem Date: Sat, 21 May 2022 01:14:50 +0200 Subject: [PATCH] Add jwt service + add liquibase --- build.gradle | 33 + .../Api/Controllers/AuthController.java | 37 +- src/main/java/net/Broken/Api/Data/Login.java | 5 +- .../DiscordAuthenticationProvider.java | 4 +- .../UnauthorizedHandler.java | 2 +- .../Security/Data/DiscordOauthUserInfo.java | 2 + .../Broken/Api/Security/SecurityConfig.java | 3 +- .../Services/DiscordOauthService.java | 10 +- .../Api/Security/Services/JwtService.java | 46 ++ .../DB/Entity/GuildPreferenceEntity.java | 2 +- .../DB/Entity/PendingPwdResetEntity.java | 57 -- .../Broken/DB/Entity/PendingUserEntity.java | 76 --- .../net/Broken/DB/Entity/PlaylistEntity.java | 2 +- .../net/Broken/DB/Entity/TrackEntity.java | 2 +- .../java/net/Broken/DB/Entity/UserEntity.java | 2 +- .../java/net/Broken/DB/Entity/UserStats.java | 2 +- .../Repository/PendingPwdResetRepository.java | 11 - .../DB/Repository/PendingUserRepository.java | 17 - .../Broken/Tools/UserManager/UserUtils.java | 14 - src/main/resources/application.yml | 45 +- .../db/changelog/db.changelog-master.yml | 567 ++++++++++++++++++ 21 files changed, 714 insertions(+), 225 deletions(-) rename src/main/java/net/Broken/Api/Security/{ => Components}/DiscordAuthenticationProvider.java (95%) rename src/main/java/net/Broken/Api/Security/{Services => Components}/UnauthorizedHandler.java (97%) create mode 100644 src/main/java/net/Broken/Api/Security/Services/JwtService.java delete mode 100644 src/main/java/net/Broken/DB/Entity/PendingPwdResetEntity.java delete mode 100644 src/main/java/net/Broken/DB/Entity/PendingUserEntity.java delete mode 100644 src/main/java/net/Broken/DB/Repository/PendingPwdResetRepository.java delete mode 100644 src/main/java/net/Broken/DB/Repository/PendingUserRepository.java create mode 100644 src/main/resources/db/changelog/db.changelog-master.yml diff --git a/build.gradle b/build.gradle index e8f0792..6a7e039 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'groovy' + id 'org.liquibase.gradle' version '2.0.4' } @@ -38,6 +39,8 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-log4j2") implementation("org.springframework.boot:spring-boot-starter-oauth2-client") + implementation('org.liquibase:liquibase-core') + implementation('io.jsonwebtoken:jjwt-api:0.11.5') implementation('io.jsonwebtoken:jjwt-impl:0.11.5') implementation('io.jsonwebtoken:jjwt-gson:0.11.5') @@ -50,6 +53,8 @@ dependencies { // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) implementation(platform("org.apache.logging.log4j:log4j-bom:2.17.1")) + implementation group: 'org.hibernate', name: 'hibernate-validator', version: '7.0.4.Final' + // Use MySQL Connector-J implementation 'mysql:mysql-connector-java' implementation 'org.reflections:reflections:0.9.12' @@ -59,8 +64,36 @@ dependencies { implementation group: 'org.jsoup', name: 'jsoup', version: '1.13.1' + liquibaseRuntime 'org.liquibase:liquibase-core:4.2.2' + liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.1.1' + liquibaseRuntime 'mysql:mysql-connector-java:5.1.34' + liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' + liquibaseRuntime group: 'org.liquibase.ext', name: 'liquibase-hibernate5', version: '4.10.0' + liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa' + liquibaseRuntime 'org.springframework.data:spring-data-jpa' + liquibaseRuntime 'org.springframework:spring-beans' + liquibaseRuntime 'net.dv8tion:JDA:4.4.0_350' + liquibaseRuntime 'com.sedmelluq:lavaplayer:1.3.77' + liquibaseRuntime sourceSets.main.output } +apply plugin: "org.liquibase.gradle" + +configurations { + liquibaseRuntime.extendsFrom runtime +} +liquibase { + activities { + main { + changeLogFile "src/main/resources/db/changelog/db.changelog-master.yml" + url System.getenv("DB_URL") + referenceUrl 'hibernate:spring:net.Broken?dialect=org.hibernate.dialect.MySQL5Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy' + username System.getenv("DB_USER") + password System.getenv("DB_PWD") + } + } +} + class Version { String major, minor, revision diff --git a/src/main/java/net/Broken/Api/Controllers/AuthController.java b/src/main/java/net/Broken/Api/Controllers/AuthController.java index 5ccb57e..356a70e 100644 --- a/src/main/java/net/Broken/Api/Controllers/AuthController.java +++ b/src/main/java/net/Broken/Api/Controllers/AuthController.java @@ -1,28 +1,61 @@ package net.Broken.Api.Controllers; import net.Broken.Api.Data.Login; +import net.Broken.Api.Security.Services.JwtService; +import net.Broken.DB.Entity.UserEntity; +import net.Broken.DB.Repository.UserRepository; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.Optional; + @RestController @RequestMapping("/api/v2") +@CrossOrigin(origins = "*", maxAge = 3600) public class AuthController { private final AuthenticationManager authenticationManager; - public AuthController(AuthenticationManager authenticationManager) { + private final UserRepository userRepository; + + private final JwtService jwtService; + + public AuthController(AuthenticationManager authenticationManager, UserRepository userRepository, JwtService jwtService) { this.authenticationManager = authenticationManager; + this.userRepository = userRepository; + this.jwtService = jwtService; } @PostMapping("login/discord") - public String helloUser(@RequestBody Login login) { + public String loginDiscord(@Validated @RequestBody Login login) { Authentication authentication = authenticationManager.authenticate( new UsernamePasswordAuthenticationToken(login.redirectUri(), login.code()) ); + authentication.getPrincipal(); + return "Hello User"; } + @GetMapping("login/discord") + public String helloUsertest() { + Optional user = userRepository.findById(5); + + return jwtService.buildJwt(user.get()); + } + + @RequestMapping( + value = "/**", + method = RequestMethod.OPTIONS + ) + public ResponseEntity handle() { + return new ResponseEntity(HttpStatus.OK); + } + + } diff --git a/src/main/java/net/Broken/Api/Data/Login.java b/src/main/java/net/Broken/Api/Data/Login.java index dc8b443..ffa13f1 100644 --- a/src/main/java/net/Broken/Api/Data/Login.java +++ b/src/main/java/net/Broken/Api/Data/Login.java @@ -1,5 +1,8 @@ package net.Broken.Api.Data; -public record Login (String code, String redirectUri){ +import javax.validation.constraints.NotBlank; + +public record Login( + @NotBlank String code, @NotBlank String redirectUri) { } diff --git a/src/main/java/net/Broken/Api/Security/DiscordAuthenticationProvider.java b/src/main/java/net/Broken/Api/Security/Components/DiscordAuthenticationProvider.java similarity index 95% rename from src/main/java/net/Broken/Api/Security/DiscordAuthenticationProvider.java rename to src/main/java/net/Broken/Api/Security/Components/DiscordAuthenticationProvider.java index de1fca7..34d10d1 100644 --- a/src/main/java/net/Broken/Api/Security/DiscordAuthenticationProvider.java +++ b/src/main/java/net/Broken/Api/Security/Components/DiscordAuthenticationProvider.java @@ -1,4 +1,4 @@ -package net.Broken.Api.Security; +package net.Broken.Api.Security.Components; import net.Broken.Api.Security.Data.DiscordOauthUserInfo; import net.Broken.Api.Security.Exception.OAuthLoginFail; @@ -17,7 +17,6 @@ import java.util.ArrayList; @Component public class DiscordAuthenticationProvider implements AuthenticationProvider { - private final Logger logger = LogManager.getLogger(); private final DiscordOauthService discordOauthService; public DiscordAuthenticationProvider(DiscordOauthService discordOauthService) { @@ -34,7 +33,6 @@ public class DiscordAuthenticationProvider implements AuthenticationProvider { discordOauthService.revokeToken(token); UserEntity userEntity = discordOauthService.loginOrRegisterDiscordUser(discordOauthUserInfo); return new UsernamePasswordAuthenticationToken(userEntity, null, new ArrayList<>()); - } catch (OAuthLoginFail e) { throw new BadCredentialsException("Bad response form Discord Oauth server ! Code expired ?"); } diff --git a/src/main/java/net/Broken/Api/Security/Services/UnauthorizedHandler.java b/src/main/java/net/Broken/Api/Security/Components/UnauthorizedHandler.java similarity index 97% rename from src/main/java/net/Broken/Api/Security/Services/UnauthorizedHandler.java rename to src/main/java/net/Broken/Api/Security/Components/UnauthorizedHandler.java index 7debb4e..1f3ef57 100644 --- a/src/main/java/net/Broken/Api/Security/Services/UnauthorizedHandler.java +++ b/src/main/java/net/Broken/Api/Security/Components/UnauthorizedHandler.java @@ -1,4 +1,4 @@ -package net.Broken.Api.Security.Services; +package net.Broken.Api.Security.Components; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/net/Broken/Api/Security/Data/DiscordOauthUserInfo.java b/src/main/java/net/Broken/Api/Security/Data/DiscordOauthUserInfo.java index 08398e3..128dd3d 100644 --- a/src/main/java/net/Broken/Api/Security/Data/DiscordOauthUserInfo.java +++ b/src/main/java/net/Broken/Api/Security/Data/DiscordOauthUserInfo.java @@ -3,4 +3,6 @@ package net.Broken.Api.Security.Data; public class DiscordOauthUserInfo { public String id; public String username; + public String discriminator; + public String avatar; } diff --git a/src/main/java/net/Broken/Api/Security/SecurityConfig.java b/src/main/java/net/Broken/Api/Security/SecurityConfig.java index 6c7abef..45db05b 100644 --- a/src/main/java/net/Broken/Api/Security/SecurityConfig.java +++ b/src/main/java/net/Broken/Api/Security/SecurityConfig.java @@ -1,7 +1,6 @@ package net.Broken.Api.Security; -import net.Broken.Api.Security.Services.UnauthorizedHandler; -import net.Broken.DB.Repository.UserRepository; +import net.Broken.Api.Security.Components.UnauthorizedHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; diff --git a/src/main/java/net/Broken/Api/Security/Services/DiscordOauthService.java b/src/main/java/net/Broken/Api/Security/Services/DiscordOauthService.java index 1eee8f3..c18fe1a 100644 --- a/src/main/java/net/Broken/Api/Security/Services/DiscordOauthService.java +++ b/src/main/java/net/Broken/Api/Security/Services/DiscordOauthService.java @@ -25,19 +25,19 @@ import java.util.Map; public class DiscordOauthService { private final Logger logger = LogManager.getLogger(); - @Value("${discord.client-id}") + @Value("${discord.oauth.client-id}") private String clientId; - @Value("${discord.client-secret}") + @Value("${discord.oauth.client-secret}") private String clientSecret; - @Value("${discord.token-endpoint}") + @Value("${discord.oauth.token-endpoint}") private String tokenEndpoint; - @Value("${discord.tokenRevokeEndpoint}") + @Value("${discord.oauth.tokenRevokeEndpoint}") private String tokenRevokeEndpoint; - @Value("${discord.userInfoEnpoint}") + @Value("${discord.oauth.userInfoEnpoint}") private String userInfoEnpoint; private final UserRepository userRepository; diff --git a/src/main/java/net/Broken/Api/Security/Services/JwtService.java b/src/main/java/net/Broken/Api/Security/Services/JwtService.java new file mode 100644 index 0000000..000d0d3 --- /dev/null +++ b/src/main/java/net/Broken/Api/Security/Services/JwtService.java @@ -0,0 +1,46 @@ +package net.Broken.Api.Security.Services; + + +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; +import net.Broken.DB.Entity.UserEntity; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.security.Key; +import java.time.LocalDateTime; +import java.util.Calendar; +import java.util.Date; + +@Service +public class JwtService { + @Value("${security.jwt.secret}") + private String jwtSecret; + + private final Key jwtKey; + + public JwtService() { + this.jwtKey = Keys.secretKeyFor(SignatureAlgorithm.HS256); + } + + public String buildJwt(UserEntity user){ + Date iat = new Date(); + Date nbf = new Date(); + Calendar expCal = Calendar.getInstance(); + expCal.add(Calendar.DATE, 7); + Date exp = expCal.getTime(); + + + return Jwts.builder() + .setSubject(user.getName()) + .setId(user.getJdaId()) + .setIssuedAt(iat) + .setNotBefore(nbf) + .setExpiration(exp) + .signWith(this.jwtKey) + .compact(); + + + } +} diff --git a/src/main/java/net/Broken/DB/Entity/GuildPreferenceEntity.java b/src/main/java/net/Broken/DB/Entity/GuildPreferenceEntity.java index 8ce6cc7..906a8c1 100644 --- a/src/main/java/net/Broken/DB/Entity/GuildPreferenceEntity.java +++ b/src/main/java/net/Broken/DB/Entity/GuildPreferenceEntity.java @@ -10,7 +10,7 @@ import javax.persistence.Id; @Entity public class GuildPreferenceEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String guildId; diff --git a/src/main/java/net/Broken/DB/Entity/PendingPwdResetEntity.java b/src/main/java/net/Broken/DB/Entity/PendingPwdResetEntity.java deleted file mode 100644 index 0badcf8..0000000 --- a/src/main/java/net/Broken/DB/Entity/PendingPwdResetEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.Broken.DB.Entity; - -import javax.persistence.*; -import java.util.Calendar; -import java.util.Date; - - -@Entity -public class PendingPwdResetEntity { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Integer id; - - @OneToOne - private UserEntity userEntity; - private String securityToken; - private Date expirationDate; - - - public PendingPwdResetEntity(UserEntity userEntity, String token) { - this.userEntity = userEntity; - this.securityToken = token; - Calendar cal = Calendar.getInstance(); - cal.setTime(new Date()); - cal.add(Calendar.HOUR, 24); - expirationDate = cal.getTime(); - - } - - public PendingPwdResetEntity() { - } - - - public UserEntity getUserEntity() { - return userEntity; - } - - public void setUserEntity(UserEntity userEntity) { - this.userEntity = userEntity; - } - - public String getSecurityToken() { - return securityToken; - } - - public void setSecurityToken(String securityToken) { - this.securityToken = securityToken; - } - - public Date getExpirationDate() { - return expirationDate; - } - - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } -} diff --git a/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java b/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java deleted file mode 100644 index 6100b27..0000000 --- a/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.Broken.DB.Entity; - - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -/** - * Entity for DB. Represent user who not yet confirmed her account. - */ -@Entity -public class PendingUserEntity { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Integer id; - - private String name; - - private String jdaId; - - private String checkToken; - - private String password; - - public PendingUserEntity() { - } - - public PendingUserEntity(String name, String jdaId, String checkToken, String password) { - this.name = name; - this.jdaId = jdaId; - this.checkToken = checkToken; - this.password = password; - } - - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getJdaId() { - return jdaId; - } - - public void setJdaId(String jdaId) { - this.jdaId = jdaId; - } - - public String getCheckToken() { - return checkToken; - } - - public void setCheckToken(String checkToken) { - this.checkToken = checkToken; - } -} diff --git a/src/main/java/net/Broken/DB/Entity/PlaylistEntity.java b/src/main/java/net/Broken/DB/Entity/PlaylistEntity.java index 64f9096..aff033d 100644 --- a/src/main/java/net/Broken/DB/Entity/PlaylistEntity.java +++ b/src/main/java/net/Broken/DB/Entity/PlaylistEntity.java @@ -12,7 +12,7 @@ import java.util.List; public class PlaylistEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; diff --git a/src/main/java/net/Broken/DB/Entity/TrackEntity.java b/src/main/java/net/Broken/DB/Entity/TrackEntity.java index 9b5f6c7..ee449cb 100644 --- a/src/main/java/net/Broken/DB/Entity/TrackEntity.java +++ b/src/main/java/net/Broken/DB/Entity/TrackEntity.java @@ -9,7 +9,7 @@ import javax.persistence.*; public class TrackEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String title; diff --git a/src/main/java/net/Broken/DB/Entity/UserEntity.java b/src/main/java/net/Broken/DB/Entity/UserEntity.java index d6110ba..e62e77d 100644 --- a/src/main/java/net/Broken/DB/Entity/UserEntity.java +++ b/src/main/java/net/Broken/DB/Entity/UserEntity.java @@ -16,7 +16,7 @@ import java.util.List; @Entity public class UserEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; diff --git a/src/main/java/net/Broken/DB/Entity/UserStats.java b/src/main/java/net/Broken/DB/Entity/UserStats.java index 3653c3d..20f0399 100644 --- a/src/main/java/net/Broken/DB/Entity/UserStats.java +++ b/src/main/java/net/Broken/DB/Entity/UserStats.java @@ -8,7 +8,7 @@ import javax.persistence.*; public class UserStats { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; diff --git a/src/main/java/net/Broken/DB/Repository/PendingPwdResetRepository.java b/src/main/java/net/Broken/DB/Repository/PendingPwdResetRepository.java deleted file mode 100644 index b072bde..0000000 --- a/src/main/java/net/Broken/DB/Repository/PendingPwdResetRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.Broken.DB.Repository; - -import net.Broken.DB.Entity.PendingPwdResetEntity; -import net.Broken.DB.Entity.UserEntity; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface PendingPwdResetRepository extends CrudRepository { - List findByUserEntity(UserEntity userEntity); -} diff --git a/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java b/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java deleted file mode 100644 index 9d6cf4a..0000000 --- a/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.Broken.DB.Repository; - -import net.Broken.DB.Entity.PendingUserEntity; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -/** - * Repository for PendingUserEntity - */ -public interface PendingUserRepository extends CrudRepository { - List findByJdaId(String jdaId); - - - PendingUserEntity findById(int id); - -} diff --git a/src/main/java/net/Broken/Tools/UserManager/UserUtils.java b/src/main/java/net/Broken/Tools/UserManager/UserUtils.java index 301a1d8..e7f39c9 100644 --- a/src/main/java/net/Broken/Tools/UserManager/UserUtils.java +++ b/src/main/java/net/Broken/Tools/UserManager/UserUtils.java @@ -1,24 +1,10 @@ package net.Broken.Tools.UserManager; -import net.Broken.DB.Entity.PendingUserEntity; import net.Broken.DB.Entity.UserEntity; -import net.Broken.DB.Repository.PendingUserRepository; import net.Broken.DB.Repository.UserRepository; -import net.Broken.MainBot; -import net.Broken.RestApi.Data.UserManager.UserInfoData; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.ResourceLoader; import net.Broken.Tools.UserManager.Exceptions.*; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.entities.User; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.springframework.security.crypto.password.PasswordEncoder; - -import java.io.FileNotFoundException; -import java.security.SecureRandom; -import java.util.List; -import java.util.UUID; public class UserUtils { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6f7ebe4..4a4c232 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,41 +3,24 @@ spring: username: ${DB_USER} url: ${DB_URL} password: ${DB_PWD} - thymeleaf: - cache: 'true' - jpa: - hibernate: - ddl-auto: update - security: - oauth2: - client: - registration: - discord: - client-id: ${CLIENT_ID} - client-secret: ${CLIENT_SECRET} - clientAuthenticationMethod: post - authorizationGrantType: authorization_code - scope: - - identify - redirect-uri: "http://localhost:8080/login/oauth2/code/discord" - clientName: FourScouts client - provider: - discord: - authorizationUri: https://discordapp.com/api/oauth2/authorize - tokenUri: https://discordapp.com/api/oauth2/token - userInfoUri: https://discordapp.com/api/users/@me - userNameAttribute: username + liquibase: + change-log: classpath:db/changelog/db.changelog-master.yml server: compression: - enabled: 'true' + enabled: true mime-types: application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css port: ${PORT} http2: - enabled: 'true' + enabled: true + +security: + jwt: + secret: ${JWT_SECRET} discord: - client-id: ${CLIENT_ID} - client-secret: ${CLIENT_SECRET} - token-endpoint: https://discord.com/api/oauth2/token - tokenRevokeEndpoint: https://discord.com/api/oauth2/token/revoke - userInfoEnpoint: https://discord.com/api/users/@me \ No newline at end of file + oauth: + client-id: ${CLIENT_ID} + client-secret: ${CLIENT_SECRET} + token-endpoint: https://discord.com/api/oauth2/token + tokenRevokeEndpoint: https://discord.com/api/oauth2/token/revoke + userInfoEnpoint: https://discord.com/api/users/@me \ No newline at end of file diff --git a/src/main/resources/db/changelog/db.changelog-master.yml b/src/main/resources/db/changelog/db.changelog-master.yml new file mode 100644 index 0000000..6411603 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-master.yml @@ -0,0 +1,567 @@ +databaseChangeLog: +- changeSet: + id: 1653065037086-1 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + constraints: + nullable: false + name: anti_spam + type: BIT + - column: + constraints: + nullable: false + name: default_role + type: BIT + - column: + name: default_role_id + type: VARCHAR(255) + - column: + name: guild_id + type: VARCHAR(255) + - column: + constraints: + nullable: false + name: welcome + type: BIT + - column: + name: welcome_chanelid + type: VARCHAR(255) + - column: + name: welcome_message + type: VARCHAR(255) + - column: + constraints: + nullable: false + name: daily_madame + type: BIT + - column: + constraints: + nullable: false + name: auto_voice + type: BIT + - column: + name: auto_voice_channelid + type: VARCHAR(255) + - column: + name: auto_voice_channel_title + type: VARCHAR(255) + tableName: guild_preference_entity +- changeSet: + id: 1653065037086-2 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + constraints: + nullable: false + name: guild_preference_entity_id + type: INT + - column: + name: visible_voice_chanel + type: VARCHAR(255) + tableName: guild_preference_entity_visible_voice_chanel +- changeSet: + id: 1653065037086-3 + author: seb65 (generated) + changes: + - createSequence: + columns: + - column: + defaultValueComputed: 'NULL' + name: next_val + type: BIGINT + tableName: hibernate_sequence +- changeSet: + id: 1653065037086-4 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + defaultValueComputed: 'NULL' + name: expiration_date + type: datetime + - column: + name: security_token + type: VARCHAR(255) + - column: + defaultValueComputed: 'NULL' + name: user_entity_id + type: INT + tableName: pending_pwd_reset_entity +- changeSet: + id: 1653065037086-5 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + name: check_token + type: VARCHAR(255) + - column: + name: jda_id + type: VARCHAR(255) + - column: + name: name + type: VARCHAR(255) + - column: + name: password + type: VARCHAR(255) + tableName: pending_user_entity +- changeSet: + id: 1653065037086-6 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + name: name + type: VARCHAR(255) + - column: + constraints: + nullable: false + name: user_entity_id + type: INT + tableName: playlist_entity +- changeSet: + id: 1653065037086-7 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + name: identifier + type: VARCHAR(255) + - column: + defaultValueComputed: 'NULL' + name: pos + type: INT + - column: + name: title + type: VARCHAR(255) + - column: + name: url + type: VARCHAR(255) + - column: + constraints: + nullable: false + name: playlist_entity_id + type: INT + tableName: track_entity +- changeSet: + id: 1653065037086-8 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: INT + - column: + name: api_token + type: VARCHAR(255) + - column: + name: jda_id + type: VARCHAR(255) + - column: + name: name + type: VARCHAR(255) + - column: + name: password + type: VARCHAR(255) + - column: + constraints: + nullable: false + name: is_bot_admin + type: BIT + tableName: user_entity +- changeSet: + id: 1653065037086-9 + author: seb65 (generated) + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + name: id + type: BIGINT + - column: + defaultValueNumeric: 0 + name: api_command_count + type: BIGINT + - column: + name: guild_id + type: VARCHAR(255) + - column: + defaultValueNumeric: 0 + name: message_count + type: BIGINT + - column: + defaultValueNumeric: 0 + name: vocal_time + type: BIGINT + - column: + constraints: + nullable: false + name: user_entity_id + type: INT + tableName: user_stats +- changeSet: + id: 1653065037086-10 + author: seb65 (generated) + changes: + - createIndex: + columns: + - column: + defaultValueComputed: 'NULL' + name: user_entity_id + indexName: FKatrj670ooxj9qiq230iacbt68 + tableName: pending_pwd_reset_entity +- changeSet: + id: 1653065037086-11 + author: seb65 (generated) + changes: + - createIndex: + columns: + - column: + name: user_entity_id + indexName: FKi0pu9fhjbhs223glek7baeuwm + tableName: playlist_entity +- changeSet: + id: 1653065037086-12 + author: seb65 (generated) + changes: + - createIndex: + columns: + - column: + name: playlist_entity_id + indexName: FKjrr0flblumxnll3re0apujvr + tableName: track_entity +- changeSet: + id: 1653065037086-13 + author: seb65 (generated) + changes: + - createIndex: + columns: + - column: + name: user_entity_id + indexName: FKjvpcyocfa9h3ybvr5loj4lfbk + tableName: user_stats +- changeSet: + id: 1653065037086-14 + author: seb65 (generated) + changes: + - createIndex: + columns: + - column: + name: guild_preference_entity_id + indexName: FKlyf6ksd3969rqtwm3bqupbniu + tableName: guild_preference_entity_visible_voice_chanel +- changeSet: + id: 1653065037086-15 + author: seb65 (generated) + changes: + - addForeignKeyConstraint: + baseColumnNames: user_entity_id + baseTableName: pending_pwd_reset_entity + constraintName: FKatrj670ooxj9qiq230iacbt68 + deferrable: false + initiallyDeferred: false + onDelete: RESTRICT + onUpdate: RESTRICT + referencedColumnNames: id + referencedTableName: user_entity + validate: true +- changeSet: + id: 1653065037086-16 + author: seb65 (generated) + changes: + - addForeignKeyConstraint: + baseColumnNames: user_entity_id + baseTableName: playlist_entity + constraintName: FKi0pu9fhjbhs223glek7baeuwm + deferrable: false + initiallyDeferred: false + onDelete: RESTRICT + onUpdate: RESTRICT + referencedColumnNames: id + referencedTableName: user_entity + validate: true +- changeSet: + id: 1653065037086-17 + author: seb65 (generated) + changes: + - addForeignKeyConstraint: + baseColumnNames: playlist_entity_id + baseTableName: track_entity + constraintName: FKjrr0flblumxnll3re0apujvr + deferrable: false + initiallyDeferred: false + onDelete: RESTRICT + onUpdate: RESTRICT + referencedColumnNames: id + referencedTableName: playlist_entity + validate: true +- changeSet: + id: 1653065037086-18 + author: seb65 (generated) + changes: + - addForeignKeyConstraint: + baseColumnNames: user_entity_id + baseTableName: user_stats + constraintName: FKjvpcyocfa9h3ybvr5loj4lfbk + deferrable: false + initiallyDeferred: false + onDelete: RESTRICT + onUpdate: RESTRICT + referencedColumnNames: id + referencedTableName: user_entity + validate: true +- changeSet: + id: 1653065037086-19 + author: seb65 (generated) + changes: + - addForeignKeyConstraint: + baseColumnNames: guild_preference_entity_id + baseTableName: guild_preference_entity_visible_voice_chanel + constraintName: FKlyf6ksd3969rqtwm3bqupbniu + deferrable: false + initiallyDeferred: false + onDelete: RESTRICT + onUpdate: RESTRICT + referencedColumnNames: id + referencedTableName: guild_preference_entity + validate: true + +databaseChangeLog: +- changeSet: + id: 1653073535100-14 + author: seb65 (generated) + changes: + - addUniqueConstraint: + columnNames: jda_id + constraintName: UC_USER_ENTITYJDA_ID_COL + tableName: user_entity +- changeSet: + id: 1653073535100-15 + author: seb65 (generated) + changes: + - dropForeignKeyConstraint: + baseTableName: pending_pwd_reset_entity + constraintName: FKatrj670ooxj9qiq230iacbt68 +- changeSet: + id: 1653073535100-16 + author: seb65 (generated) + changes: + - dropForeignKeyConstraint: + baseTableName: guild_preference_entity_visible_voice_chanel + constraintName: FKlyf6ksd3969rqtwm3bqupbniu +- changeSet: + id: 1653073535100-17 + author: seb65 (generated) + changes: + - dropTable: + tableName: guild_preference_entity_visible_voice_chanel +- changeSet: + id: 1653073535100-18 + author: seb65 (generated) + changes: + - dropTable: + tableName: hibernate_sequence +- changeSet: + id: 1653073535100-19 + author: seb65 (generated) + changes: + - dropTable: + tableName: pending_pwd_reset_entity +- changeSet: + id: 1653073535100-20 + author: seb65 (generated) + changes: + - dropTable: + tableName: pending_user_entity +- changeSet: + id: 1653073535100-21 + author: seb65 (generated) + changes: + - dropColumn: + columnName: api_token + tableName: user_entity +- changeSet: + id: 1653073535100-22 + author: seb65 (generated) + changes: + - dropColumn: + columnName: password + tableName: user_entity +- changeSet: + id: 1653073535100-1 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: auto_voice_channel_title + tableName: guild_preference_entity +- changeSet: + id: 1653073535100-2 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: auto_voice_channelid + tableName: guild_preference_entity +- changeSet: + id: 1653073535100-3 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: default_role_id + tableName: guild_preference_entity +- changeSet: + id: 1653073535100-4 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: guild_id + tableName: guild_preference_entity +- changeSet: + id: 1653073535100-5 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: guild_id + tableName: user_stats +- changeSet: + id: 1653073535100-6 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: identifier + tableName: track_entity +- changeSet: + id: 1653073535100-7 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: jda_id + tableName: user_entity +- changeSet: + id: 1653073535100-8 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: name + tableName: playlist_entity +- changeSet: + id: 1653073535100-9 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: name + tableName: user_entity +- changeSet: + id: 1653073535100-10 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: title + tableName: track_entity +- changeSet: + id: 1653073535100-11 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: url + tableName: track_entity +- changeSet: + id: 1653073535100-12 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: welcome_chanelid + tableName: guild_preference_entity +- changeSet: + id: 1653073535100-13 + author: seb65 (generated) + changes: + - dropDefaultValue: + columnDataType: varchar(255) + columnName: welcome_message + tableName: guild_preference_entity + +databaseChangeLog: +- changeSet: + id: 1653086152139-1 + author: seb65 (generated) + preConditions: + onFail: MARK_RAN + tableExists: + tableName: hibernate_sequence + changes: + - dropTable: + tableName: hibernate_sequence + - createSequence: + cycle: false + ordered: true + sequenceName: hibernate_sequence + startValue: 23608 + + +databaseChangeLog: [] +