Show Navigation

force-ssl

Creates a simple annotation to mark controller/actions as SSL restricted and performs the appropriate redirect.

Owner: bertramlabs | 3.1.1 | Nov 7, 2017 | Package | Issues | Source | License: Apache-2.0


dependencies {
    compile 'com.bertramlabs.plugins:force-ssl:3.1.1'
}

            

Grails Force SSL

The Grails Force SSL Plugin provides an annotation for controllers to force ssl url endpoints. For example, you may want to restrict a shopping cart page or login page to SSL.

Configuration

By default, the SSL plugin is enabled for all environments, with the exception of Development. This can be overridden by adjusting your Config.groovy

grails.plugin.forceSSL.enabled = false

Grails 3

grails:
    plugin:
        forceSSL:
            enabled: true

It is also possible to override the https port for the redirect if you want to via:

grails.plugin.forceSSL.sslPort = 6443 //optional

Usage

Simply import the SSL annotation and apply at the controller level or at the annotation level.

import com.bertramlabs.plugins.SSLRequired

@SSLRequired //Will encrypt entire controller
class SessionController {
  @SSLRequired //Or here for action level
  def signin() {
    //Signin Code Here
  }
}

Another option is to use a configuration mapping to identify which controllers you wish to be restricted to SSL:

  grails {
    plugin {
      forceSSL {
        enabled = true
        dashboard {
          index = true
        }
        home = true
      }
    }       
  }