diff --git a/.gitignore b/.gitignore
index fac9f1f..b7a847d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@ target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
+data.mv.db
+src/main/bundles
### IntelliJ IDEA ###
.idea/modules.xml
diff --git a/pom.xml b/pom.xml
index ef2bdd1..cf6098d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,10 @@
spring-boot-starter-test
test
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-client
+
diff --git a/src/main/java/org/kickerelo/kickerelo/layout/KickerAppLayout.java b/src/main/java/org/kickerelo/kickerelo/layout/KickerAppLayout.java
index ee8a1e8..176a842 100644
--- a/src/main/java/org/kickerelo/kickerelo/layout/KickerAppLayout.java
+++ b/src/main/java/org/kickerelo/kickerelo/layout/KickerAppLayout.java
@@ -14,6 +14,11 @@ import com.vaadin.flow.dom.Style;
import com.vaadin.flow.router.Layout;
import org.kickerelo.kickerelo.views.*;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.authentication.AnonymousAuthenticationToken;
+
+
@Layout
@JsModule("./prefers-color-scheme.js")
public class KickerAppLayout extends AppLayout {
@@ -26,6 +31,24 @@ public class KickerAppLayout extends AppLayout {
addToNavbar(drawerToggle, title);
+ // Add login/logout button
+ Authentication auth = SecurityContextHolder.getContext().getAuthentication();
+ if (auth != null && auth.isAuthenticated() && !(auth instanceof AnonymousAuthenticationToken)) {
+ Anchor logoutLink = new Anchor("/logout", "Logout (" + auth.getName() + ")");
+ logoutLink.getElement().getStyle()
+ .set("margin-left", "auto")
+ .set("margin-right", "10px")
+ .set("align-self", "center");
+ addToNavbar(logoutLink);
+ } else {
+ Anchor loginLink = new Anchor("/oauth2/authorization/oidc", "Login");
+ loginLink.getElement().getStyle()
+ .set("margin-left", "auto")
+ .set("margin-right", "10px")
+ .set("align-self", "center");
+ addToNavbar(loginLink);
+ }
+
SideNav general = new SideNav("Allgemein");
general.setCollapsible(true);
general.addItem(new SideNavItem("Spielerliste", PlayerListView.class, VaadinIcon.GROUP.create()),
diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties
index 292a868..2dfcd30 100644
--- a/src/main/resources/application-prod.properties
+++ b/src/main/resources/application-prod.properties
@@ -8,4 +8,12 @@ spring.datasource.password=${DATABASE_PASSWORD}
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=false
-spring.jpa.open-in-view=false
\ No newline at end of file
+spring.jpa.open-in-view=false
+
+# == OIDC Configuration ==
+spring.security.oauth2.client.registration.oidc.client-id=client-id
+spring.security.oauth2.client.registration.oidc.client-secret=client-secret
+spring.security.oauth2.client.registration.oidc.scope=openid,profile,email
+spring.security.oauth2.client.registration.oidc.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
+
+spring.security.oauth2.client.provider.oidc.issuer-uri=https://auth.fs.cs.uni-frankfurt.de/application/o/oidc/
diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties
index 9306521..0eece6b 100644
--- a/src/main/resources/application-test.properties
+++ b/src/main/resources/application-test.properties
@@ -7,4 +7,12 @@ spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
-spring.jpa.show-sql=true
\ No newline at end of file
+spring.jpa.show-sql=true
+
+# == OIDC Configuration ==
+spring.security.oauth2.client.registration.oidc.client-id=client-id
+spring.security.oauth2.client.registration.oidc.client-secret=client-secret
+spring.security.oauth2.client.registration.oidc.scope=openid,profile,email
+spring.security.oauth2.client.registration.oidc.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
+
+spring.security.oauth2.client.provider.oidc.issuer-uri=https://auth.fs.cs.uni-frankfurt.de/application/o/oidc/