Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #100 from ImisDevelopers/ssl_cleanup
Browse files Browse the repository at this point in the history
some cleanup regarding ssl config
  • Loading branch information
JohannesGuenther authored Mar 26, 2020
2 parents 6092993 + f6211b7 commit 055ee01
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.coronavirus.imis.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

//Ensures redirect from http -> https
@Configuration
@Profile("production")
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private Environment environment;

@Override
protected void configure(HttpSecurity http) throws Exception {
http.portMapper()
.http(Integer.parseInt(environment.getProperty("server.http.port", "8080"))) // http port defined in yml config file
.mapsTo(Integer.parseInt(environment.getProperty("server.port", "443"))); // https port defined in yml config file

http.requiresChannel()
.antMatchers("/actuator/health").requiresInsecure()
.anyRequest()
.requiresSecure();
http.authorizeRequests().antMatchers("/**").permitAll()
.and().httpBasic().disable();
}
}

0 comments on commit 055ee01

Please sign in to comment.