NCP-3 add UserContent entity #5

Merged
backdev merged 29 commits from NCP-3 into dev 2025-12-05 17:58:17 +08:00
3 changed files with 79 additions and 0 deletions
Showing only changes of commit 5425681ac2 - Show all commits
+4
View File
@@ -27,6 +27,10 @@ services:
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432 POSTGRES_PORT: 5432
POSTGRES_HOST: db POSTGRES_HOST: db
SERVER_PORT: 8080
CORS_ALLOWED_ORIGINS: http://92.242.61.23:2998,http://localhost:3000,http://localhost:2998
SPRING_SESSION_COOKIE_SAMESITE: none
SPRING_SESSION_COOKIE_SECURE: false
depends_on: depends_on:
- db - db
ports: ports:
@@ -0,0 +1,34 @@
package ru.soune.no_copy.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.util.Arrays;
@Configuration
public class CorsConfig {
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(Arrays.asList(
"http://92.242.61.23:2998",
"http://localhost:3000",
"http://localhost:2998"
));
config.setAllowedMethods(Arrays.asList("*"));
config.setAllowedHeaders(Arrays.asList("*"));
config.setExposedHeaders(Arrays.asList("Set-Cookie", "Authorization"));
config.setAllowCredentials(true); // ВАЖНО!
config.setMaxAge(3600L);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
+41
View File
@@ -1,4 +1,27 @@
spring: spring:
session:
timeout: 7d
cookie:
name: SESSION_ID
http-only: true
secure: false
same-site: none
max-age: 604800
cors:
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://92.242.61.23:2998,http://localhost:3000}
allowed-methods: GET,POST,PUT,DELETE,OPTIONS,PATCH,HEAD
allowed-headers: "*"
exposed-headers: Set-Cookie,Authorization,Content-Type
allow-credentials: true # ВАЖНО для кук!
max-age: 3600
logging:
level:
org.springframework.web.cors: DEBUG
org.springframework.security: DEBUG
org.springframework.web: DEBUG
datasource: datasource:
url: jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} url: jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
username: ${POSTGRES_USER} username: ${POSTGRES_USER}
@@ -9,10 +32,28 @@ spring:
hibernate: hibernate:
ddl-auto: update ddl-auto: update
show-sql: true show-sql: true
properties:
hibernate:
format_sql: true
server: server:
port: ${SERVER_PORT:8080} port: ${SERVER_PORT:8080}
servlet:
session:
cookie:
same-site: none
encoding:
charset: UTF-8
enabled: true
logging: logging:
level: level:
root: INFO root: INFO
org.springframework.web.cors: TRACE # Более детальные логи
org.springframework.session: DEBUG
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
file:
name: ./logs/app.log
max-size: 10MB
max-history: 30