mirror of
https://github.com/AJMicke/KickerELO.git
synced 2026-03-11 13:31:02 +01:00
First try in oidc implementation
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -68,6 +68,10 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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
|
||||
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/
|
||||
|
||||
@@ -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
|
||||
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/
|
||||
|
||||
Reference in New Issue
Block a user