feat: BAC-39 Authentication (#114)
Reviewed-on: #114 Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
@@ -22,3 +22,28 @@ play.filters.cors {
|
||||
allowedHttpMethods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
allowedHttpHeaders = ["Accept", "Content-Type", "Origin", "X-Requested-With"]
|
||||
}
|
||||
|
||||
# Local Development OpenID Connect Configuration
|
||||
openid {
|
||||
selectUserRoute="http://localhost:5173/select-username"
|
||||
|
||||
discord {
|
||||
clientId = ${?DISCORD_CLIENT_ID}
|
||||
clientId = "1462555597118509126"
|
||||
clientSecret = ${?DISCORD_CLIENT_SECRET}
|
||||
clientSecret = "xZZrdd7_tNpfJgnk-6phSG53DSTy-eMK"
|
||||
redirectUri = ${?DISCORD_REDIRECT_URI}
|
||||
redirectUri = "http://localhost:9000/auth/discord/callback"
|
||||
}
|
||||
|
||||
keycloak {
|
||||
clientId = ${?KEYCLOAK_CLIENT_ID}
|
||||
clientId = "your-keycloak-client-id"
|
||||
clientSecret = ${?KEYCLOAK_CLIENT_SECRET}
|
||||
clientSecret = "your-keycloak-client-secret"
|
||||
redirectUri = ${?KEYCLOAK_REDIRECT_URI}
|
||||
redirectUri = "http://localhost:9000/auth/keycloak/callback"
|
||||
authUrl = ${?KEYCLOAK_AUTH_URL}
|
||||
authUrl = "http://localhost:8080/realms/master"
|
||||
}
|
||||
}
|
||||
|
||||
28
knockoutwhistweb/conf/db.conf
Normal file
28
knockoutwhistweb/conf/db.conf
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
# Database configuration - PostgreSQL with environment variables
|
||||
db.default.driver=org.postgresql.Driver
|
||||
db.default.url=${?DATABASE_URL}
|
||||
db.default.username=${?DB_USER}
|
||||
db.default.password=${?DB_PASSWORD}
|
||||
db.default.password=""
|
||||
|
||||
# JPA/Hibernate configuration
|
||||
jpa.default=defaultPersistenceUnit
|
||||
|
||||
# Hibernate specific settings
|
||||
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
hibernate.hbm2ddl.auto=update
|
||||
hibernate.show_sql=false
|
||||
hibernate.format_sql=true
|
||||
hibernate.use_sql_comments=true
|
||||
|
||||
# Connection pool settings
|
||||
db.default.hikaricp.maximumPoolSize=20
|
||||
db.default.hikaricp.minimumIdle=5
|
||||
db.default.hikaricp.connectionTimeout=30000
|
||||
db.default.hikaricp.idleTimeout=600000
|
||||
db.default.hikaricp.maxLifetime=1800000
|
||||
|
||||
# PostgreSQL specific settings
|
||||
db.default.hikaricp.connectionTestQuery="SELECT 1"
|
||||
db.default.hikaricp.poolName="KnockOutWhistPool"
|
||||
38
knockoutwhistweb/conf/persistence.xml
Normal file
38
knockoutwhistweb/conf/persistence.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
|
||||
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
|
||||
version="3.0">
|
||||
|
||||
<persistence-unit name="defaultPersistenceUnit">
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
|
||||
<class>model.users.UserEntity</class>
|
||||
|
||||
<properties>
|
||||
<!-- Database connection settings -->
|
||||
<property name="jakarta.persistence.jdbc.driver" value="org.postgresql.Driver"/>
|
||||
<property name="jakarta.persistence.jdbc.url" value="${DATABASE_URL}"/>
|
||||
<property name="jakarta.persistence.jdbc.user" value="${DB_USER}"/>
|
||||
<property name="jakarta.persistence.jdbc.password" value="${DB_PASSWORD}"/>
|
||||
|
||||
<!-- Hibernate specific settings -->
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
|
||||
<property name="hibernate.hbm2ddl.auto" value="update"/>
|
||||
<property name="hibernate.show_sql" value="false"/>
|
||||
<property name="hibernate.format_sql" value="true"/>
|
||||
<property name="hibernate.use_sql_comments" value="true"/>
|
||||
|
||||
<!-- Connection pool settings -->
|
||||
<property name="hibernate.connection.provider_class" value="org.hibernate.hikaricp.internal.HikariCPConnectionProvider"/>
|
||||
<property name="hibernate.hikari.maximumPoolSize" value="20"/>
|
||||
<property name="hibernate.hikari.minimumIdle" value="5"/>
|
||||
<property name="hibernate.hikari.connectionTimeout" value="30000"/>
|
||||
<property name="hibernate.hikari.idleTimeout" value="600000"/>
|
||||
<property name="hibernate.hikari.maxLifetime" value="1800000"/>
|
||||
<property name="hibernate.hikari.poolName" value="KnockOutWhistPool"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
@@ -1,4 +1,5 @@
|
||||
include "application.conf"
|
||||
include "db.conf"
|
||||
|
||||
play.http.secret.key="zg8^v0R*:7-m.>^8T2B1q)sE3MV_9=M{K9zx8,<3}"
|
||||
|
||||
@@ -7,8 +8,29 @@ play.http.context="/api"
|
||||
play.modules.enabled += "modules.GatewayModule"
|
||||
|
||||
play.filters.cors {
|
||||
allowedOrigins = ["https://knockout.janis-eccarius.de"]
|
||||
allowedOrigins = ["http://localhost:5173"]
|
||||
allowedCredentials = true
|
||||
allowedHttpMethods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
allowedHttpHeaders = ["Accept", "Content-Type", "Origin", "X-Requested-With"]
|
||||
}
|
||||
|
||||
# OpenID Connect Configuration
|
||||
openid {
|
||||
|
||||
selectUserRoute="https://knockout.janis-eccarius.de/select-username"
|
||||
|
||||
discord {
|
||||
clientId = ${?DISCORD_CLIENT_ID}
|
||||
clientSecret = ${?DISCORD_CLIENT_SECRET}
|
||||
redirectUri = ${?DISCORD_REDIRECT_URI}
|
||||
redirectUri = "https://knockout.janis-eccarius.de/auth/discord/callback"
|
||||
}
|
||||
|
||||
keycloak {
|
||||
clientId = "your-keycloak-client-id"
|
||||
clientSecret = "your-keycloak-client-secret"
|
||||
redirectUri = "https://knockout.janis-eccarius.de/api/auth/keycloak/callback"
|
||||
authUrl = ${?KEYCLOAK_AUTH_URL}
|
||||
authUrl = "https://identity.janis-eccarius.de/realms/master"
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,18 @@
|
||||
# Routes
|
||||
# This file defines all application routes (Higher priority routes first)
|
||||
# https://www.playframework.com/documentation/latest/ScalaRouting
|
||||
# ~~~~
|
||||
|
||||
# For the javascript routing
|
||||
GET /assets/js/routes controllers.JavaScriptRoutingController.javascriptRoutes()
|
||||
# Primary routes
|
||||
GET / controllers.MainMenuController.index()
|
||||
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
|
||||
|
||||
# Main menu routes
|
||||
GET /mainmenu controllers.MainMenuController.mainMenu()
|
||||
GET /rules controllers.MainMenuController.rules()
|
||||
GET /navSPA/:pType controllers.MainMenuController.navSPA(pType)
|
||||
|
||||
# Create game rounds
|
||||
POST /createGame controllers.MainMenuController.createGame()
|
||||
POST /joinGame/:gameId controllers.MainMenuController.joinGame(gameId: String)
|
||||
|
||||
# User authentication routes
|
||||
POST /login controllers.UserController.login_Post()
|
||||
POST /register controllers.UserController.register()
|
||||
POST /logout controllers.UserController.logoutPost()
|
||||
GET /userInfo controllers.UserController.getUserInfo()
|
||||
|
||||
# In-game routes
|
||||
GET /game/:id controllers.IngameController.game(id: String)
|
||||
# OpenID Connect routes
|
||||
GET /auth/:provider controllers.OpenIDController.loginWithProvider(provider: String)
|
||||
GET /auth/:provider/callback controllers.OpenIDController.callback(provider: String)
|
||||
GET /select-username controllers.OpenIDController.selectUsername()
|
||||
POST /submit-username controllers.OpenIDController.submitUsername()
|
||||
|
||||
# Websocket
|
||||
GET /websocket controllers.WebsocketController.socket()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
include "application.conf"
|
||||
include "db.conf"
|
||||
|
||||
play.http.context="/api"
|
||||
|
||||
@@ -9,4 +10,24 @@ play.filters.cors {
|
||||
allowedCredentials = true
|
||||
allowedHttpMethods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
allowedHttpHeaders = ["Accept", "Content-Type", "Origin", "X-Requested-With"]
|
||||
}
|
||||
}
|
||||
|
||||
openid {
|
||||
|
||||
selectUserRoute="https://st.knockout.janis-eccarius.de/select-username"
|
||||
|
||||
discord {
|
||||
clientId = ${?DISCORD_CLIENT_ID}
|
||||
clientSecret = ${?DISCORD_CLIENT_SECRET}
|
||||
redirectUri = ${?DISCORD_REDIRECT_URI}
|
||||
redirectUri = "https://st.knockout.janis-eccarius.de/auth/discord/callback"
|
||||
}
|
||||
|
||||
keycloak {
|
||||
clientId = "your-keycloak-client-id"
|
||||
clientSecret = "your-keycloak-client-secret"
|
||||
redirectUri = "https://st.knockout.janis-eccarius.de/api/auth/keycloak/callback"
|
||||
authUrl = ${?KEYCLOAK_AUTH_URL}
|
||||
authUrl = "https://identity.janis-eccarius.de/realms/master"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user