Skip to content

Instantly share code, notes, and snippets.

@rdmueller
Last active January 24, 2018 08:14
Show Gist options
  • Save rdmueller/c754f9a2de05434ef4e0e0f1f953831c to your computer and use it in GitHub Desktop.
Save rdmueller/c754f9a2de05434ef4e0e0f1f953831c to your computer and use it in GitHub Desktop.

this is how you get a good grails starter application with social login up and running

first create a basic app with the web-profile:

grails create-app myStarter
cd myStarter

now follow these steps to install spring-security-core

open build.gradle and add to the second dependencies-section the following line:
    compile 'org.grails.plugins:spring-security-core:3.2.0' //(1)
<1> make sure that the version is the http://plugins.grails.org/plugin/grails/spring-security-core[current one].
grails s2-quickstart security User Role --groupClassName=RoleGroup
grails s2-create-persistent-token security.PersistentLogin
grails s2-create-role-hierarchy-entry security.RoleHierarchyEntry
add the following lines to grails-app/conf/logback.groovy
logger 'org.springframework.security', DEBUG, ['STDOUT'], false
logger 'grails.plugin.springsecurity', DEBUG, ['STDOUT'], false
to get the app started, add the following lines to the ìnit`-closure in grails-app/init/../bootstrap.groovy
         def adminRole = new Role(authority: 'ROLE_ADMIN').save()

         def testUser = new User(username: 'me', password: 'password').save()

         UserRole.create testUser, adminRole

         UserRole.withSession {
            it.flush()
            it.clear()
         }

         assert User.count() == 1
         assert Role.count() == 1
         assert UserRole.count() == 1

…​and on top of the file, right after the package name:

import security.UserRole
import security.Role
import security.User

next let’s add [spring-security-ui]

open build.gradle and add to the second dependencies-section the following line:
    compile 'org.grails.plugins:spring-security-ui:3.1.1'

again, make sure that you have the latest version specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment