This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from ImisDevelopers/ssl_cleanup
some cleanup regarding ssl config
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
server/src/main/java/de/coronavirus/imis/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |