From 66b251b1d966446d3cbc7f4d76d87b36c5711dff Mon Sep 17 00:00:00 2001
From: grimsi <9295182+grimsi@users.noreply.github.com>
Date: Sat, 6 Aug 2022 13:44:04 +0200
Subject: [PATCH] Final polishing steps
---
.gitignore | 1 +
backend/pom.xml | 42 +++++++++++--------
.../gameyfin/config/FrontendConfig.java | 29 +++++++++++++
.../config/SecurityConfiguration.java | 6 ++-
.../main/resources/config/gameyfin.properties | 4 +-
frontend/pom.xml | 6 +--
.../components/header/header.component.html | 8 ++--
pom.xml | 3 +-
8 files changed, 69 insertions(+), 30 deletions(-)
create mode 100644 backend/src/main/java/de/grimsi/gameyfin/config/FrontendConfig.java
diff --git a/.gitignore b/.gitignore
index 6fc8d71..f4e172e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,4 @@ build/
### Custom ###
/data/
+/backend/src/main/resources/static/
diff --git a/backend/pom.xml b/backend/pom.xml
index 8b471f9..5ebb7f5 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -10,7 +10,9 @@
1.0.0
- backend
+ gameyfin-backend
+
+ jar
18
@@ -23,6 +25,14 @@
+
+
+ de.grimsi
+ gameyfin-frontend
+ ${project.parent.version}
+ runtime
+
+
org.springframework.boot
@@ -133,9 +143,11 @@
**/*.js
**/*.css
**/*.html
+ **/*.ico
+
org.springframework.boot
@@ -151,30 +163,26 @@
-
+
diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/FrontendConfig.java b/backend/src/main/java/de/grimsi/gameyfin/config/FrontendConfig.java
new file mode 100644
index 0000000..4fc7142
--- /dev/null
+++ b/backend/src/main/java/de/grimsi/gameyfin/config/FrontendConfig.java
@@ -0,0 +1,29 @@
+package de.grimsi.gameyfin.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.lang.NonNull;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.resource.PathResourceResolver;
+
+import java.io.IOException;
+
+@Configuration
+public class FrontendConfig implements WebMvcConfigurer {
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("/**")
+ .addResourceLocations("classpath:/static/")
+ .resourceChain(true)
+ .addResolver(new PathResourceResolver() {
+ @Override
+ protected Resource getResource(@NonNull String resourcePath, @NonNull Resource location) throws IOException {
+ Resource requestedResource = location.createRelative(resourcePath);
+ return requestedResource.exists() && requestedResource.isReadable() ? requestedResource : new ClassPathResource("/static/index.html");
+ }
+ }
+ );
+ }
+}
diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/SecurityConfiguration.java b/backend/src/main/java/de/grimsi/gameyfin/config/SecurityConfiguration.java
index e16a3e4..22d2812 100644
--- a/backend/src/main/java/de/grimsi/gameyfin/config/SecurityConfiguration.java
+++ b/backend/src/main/java/de/grimsi/gameyfin/config/SecurityConfiguration.java
@@ -10,6 +10,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
@@ -40,9 +42,9 @@ public class SecurityConfiguration {
@Bean
public InMemoryUserDetailsManager userDetailsService() {
UserDetails user = User
- .withDefaultPasswordEncoder()
+ .builder()
.username(username)
- .password(password)
+ .password("{noop}" + password) // FIXME: not very secure
.authorities("ADMIN_API_ACCESS")
.build();
return new InMemoryUserDetailsManager(user);
diff --git a/backend/src/main/resources/config/gameyfin.properties b/backend/src/main/resources/config/gameyfin.properties
index 40fd1d7..048b187 100644
--- a/backend/src/main/resources/config/gameyfin.properties
+++ b/backend/src/main/resources/config/gameyfin.properties
@@ -8,8 +8,8 @@ gameyfin.password=
# Root folder of your game library
gameyfin.root=
# Folders where gameyfin will store cached images and the database
-gameyfin.cache=${gameyfin.root}\.gameyfin\cache
-gameyfin.db=${gameyfin.root}\.gameyfin\db
+gameyfin.cache=${gameyfin.root}/.gameyfin/cache
+gameyfin.db=${gameyfin.root}/.gameyfin/db
# File extensions which gameyfin will recognize as game files
gameyfin.file-extensions=iso, zip, rar, 7z, exe
diff --git a/frontend/pom.xml b/frontend/pom.xml
index 6d5dce8..f53d4db 100644
--- a/frontend/pom.xml
+++ b/frontend/pom.xml
@@ -9,7 +9,7 @@
4.0.0
- frontend
+ gameyfin-frontend
jar
@@ -72,8 +72,8 @@
-
- dist/frontend
+ ./dist/frontend
+ static
diff --git a/frontend/src/app/components/header/header.component.html b/frontend/src/app/components/header/header.component.html
index 5744633..0b5618b 100644
--- a/frontend/src/app/components/header/header.component.html
+++ b/frontend/src/app/components/header/header.component.html
@@ -5,14 +5,14 @@
-
-
+
+
diff --git a/pom.xml b/pom.xml
index 66b415a..57ab03d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,9 +12,8 @@
pom
- backend
- backend
frontend
+ backend