Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 1.28 KB

README.md

File metadata and controls

62 lines (47 loc) · 1.28 KB

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
      }
    }       
  }