title: Injecting springSecurityService into Controller with Grails 3.0.3
body: <p>I am trying to get current user inside a controller in a Grails 3.0.3 application. 
  I have used <a href="https://github.com/dspies/grails-3-with-security" rel="nofollow noreferrer">this</a> repo as a base for my security setup - security is GORM based. I am using following line in build.gradle in order to include Spring Security Framework:</p>
  
  <pre><code>compile "org.springframework.boot:spring-boot-starter-security"
  </code></pre>
  
  <p>but when I try to inject springSecurityService like it was recommended in other SO threads (see for example: <a href="https://stackoverflow.com/questions/23279897/grails-spring-security-get-current-user">this one</a>) in my controller, I get only a null object. It is not initiated like it should be. </p>
  
  <pre><code>class RestapiController {
      def springSecurityService
  
      def currentUser(){
          def user = springSecurityService.currentUser
          render user
      }
  }
  </code></pre>
  
  <p>How can I inject springSecurityService into a controller in Grails 3.0.3?</p>
  
  <p>UPDATE:
  In the end I used following line to get the current user:</p>
  
  <pre><code>SecurityContextHolder.context.authentication.name
  </code></pre>