1

Merge branch 'master' into spring-profiles

This commit is contained in:
Christoph
2020-03-05 13:39:04 +01:00
committed by GitHub
3 changed files with 37 additions and 7 deletions

View File

@ -1,17 +1,12 @@
package mops.gruppen2.security;
import javax.servlet.http.HttpServletRequest;
import org.keycloak.KeycloakPrincipal;
import org.keycloak.adapters.springsecurity.KeycloakSecurityComponents;
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider;
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
import org.keycloak.representations.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.context.annotation.*;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
@ -25,6 +20,8 @@ import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class)
@ -62,6 +59,10 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
http.authorizeRequests()
.antMatchers("/actuator/**")
.hasRole("monitoring")
.and()
.authorizeRequests()
.antMatchers("h2-console/**")
.permitAll()
.anyRequest()
.permitAll();
}

View File

@ -0,0 +1,4 @@
-- noinspection SqlNoDataSourceInspectionForFile
insert into TEILNEHMER (VORNAME, NACHNAME, EMAIL) values
('Peter', 'Müller', 'Peter@123.de');

View File

@ -0,0 +1,25 @@
-- noinspection SqlNoDataSourceInspectionForFile
DROP TABLE IF EXISTS teilnehmer;
CREATE TABLE teilnehmer (
teilnehmer_id INT PRIMARY KEY AUTO_INCREMENT,
vorname VARCHAR(50) NOT NULL,
nachname VARCHAR(50) NOT NULL ,
email VARCHAR(255) NOT NULL
);
DROP TABLE IF EXISTS gruppe;
CREATE TABLE gruppe
(
gruppe_id INTEGER PRIMARY KEY auto_increment,
titel TEXT NOT NULL,
beschreibung TEXT NOT NULL
);
DROP TABLE IF EXISTS teilnahme;
CREATE TABLE teilnahme
(
id INTEGER PRIMARY KEY auto_increment,
teilnehmer_dto INTEGER REFERENCES teilnehmer(teilnehmer_id),
gruppe_dto INTEGER REFERENCES gruppe(gruppe_id)
);