com.gruelbox:dropwizard-https-redirect

A small dropwizard bundle which will redirect any income HTTP requests to the equivalent HTTPS URL.

License

License

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.gruelbox
ArtifactId

ArtifactId

dropwizard-https-redirect
Last Version

Last Version

0.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

com.gruelbox:dropwizard-https-redirect
A small dropwizard bundle which will redirect any income HTTP requests to the equivalent HTTPS URL.
Project URL

Project URL

https://github.com/gruelbox/dropwizard-https-redirect
Project Organization

Project Organization

Graham Crockford
Source Code Management

Source Code Management

https://github.com/gruelbox/dropwizard-https-redirect

Download dropwizard-https-redirect

How to add to project

<!-- https://jarcasting.com/artifacts/com.gruelbox/dropwizard-https-redirect/ -->
<dependency>
    <groupId>com.gruelbox</groupId>
    <artifactId>dropwizard-https-redirect</artifactId>
    <version>0.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.gruelbox/dropwizard-https-redirect/
implementation 'com.gruelbox:dropwizard-https-redirect:0.0.6'
// https://jarcasting.com/artifacts/com.gruelbox/dropwizard-https-redirect/
implementation ("com.gruelbox:dropwizard-https-redirect:0.0.6")
'com.gruelbox:dropwizard-https-redirect:jar:0.0.6'
<dependency org="com.gruelbox" name="dropwizard-https-redirect" rev="0.0.6">
  <artifact name="dropwizard-https-redirect" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gruelbox', module='dropwizard-https-redirect', version='0.0.6')
)
libraryDependencies += "com.gruelbox" % "dropwizard-https-redirect" % "0.0.6"
[com.gruelbox/dropwizard-https-redirect "0.0.6"]

Dependencies

compile (2)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar 1.3.15
org.apache.commons : commons-collections4 jar 4.4

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19
org.hamcrest : hamcrest-core jar 2.2

Project Modules

There are no modules declared in this project.

Dropwizard HTTPS redirection bundle

Build Status Sonarcloud Security Rating Sonarcloud Vulnerabilities Sonarcloud Coverage CodeFactor

Maven Central Javadocs

A small DropWizard bundle which will redirect any incoming HTTP requests to the equivalent HTTPS URL. Handles both the cases where the application is hosting both HTTP and HTTPS directly or where it is sitting behind an SSL proxy and receiving all traffic as HTTP.

Also protects against HTTP Response Splitting attacks.

Usage

Add to your pom.xml

<dependency>
  <groupId>com.gruelbox</groupId>
  <artifactId>dropwizard-https-redirect</artifactId>
  <version>0.0.4</version>
</dependency>

Set up configuration

Modify your application configuration class so that it implements HttpEnforcementConfiguration.

The isHttpsOnly() property enables or disables the redirection. It usually makes sense to disable it in configuration when testing locally.

The getHttpResponsibility() property is extremely important:

  • If your application is exposed directly to the internet without any sort of proxy (so your application manages its own SSL certificates) set this to HTTPS_DIRECT. The bundle will check the servlet request directly to ensure that it is secure.
  • If your application is hosted behind a proxy, and the proxy is managing the SSL side of things and forwarding both HTTP and HTTPS to your application as plain old HTTP (common with platforms such as Heroku), we have to rely on the proxy to tell us what the original protocol was using the X-Forwarded-Proto header. Most proxies do this, but do check yours. To enabled this, use HTTPS_AT_PROXY.

Install the bundle

In your Application, modify initialise():

  @Override
  public void initialize(final Bootstrap<MyConfiguration> bootstrap) {
    bootstrap.addBundle(new HttpsEnforcementBundle());
  }

That's it!

Credit

The POM and Travis build borrow heavily from other projects. See oss-archetype for credits.

com.gruelbox

The Gruelbox

Simple, nutritious open source tools.

Versions

Version
0.0.6
0.0.5
0.0.4
0.0.3