Last active
March 1, 2019 18:42
-
-
Save vanjis/e13928751345cf3168e119bf595c024e to your computer and use it in GitHub Desktop.
Forcing HTTPS in spring boot 1
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
@Bean | |
public EmbeddedServletContainerFactory getEmbeddedServletContainerFactory() { | |
TomcatEmbeddedServletContainerFactory containerFactory = new TomcatEmbeddedServletContainerFactory(); | |
containerFactory.addContextCustomizers(new TomcatContextCustomizer() { | |
@Override | |
public void customize(Context context) { | |
SecurityConstraint constraint = new SecurityConstraint(); | |
constraint.setUserConstraint("CONFIDENTIAL"); | |
SecurityCollection collection = new SecurityCollection(); | |
collection.addPattern("/*"); | |
constraint.addCollection(collection); | |
context.addConstraint(constraint); | |
} | |
}); | |
return containerFactory; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment