title: Grails: How to get username of currently logged in user, and what imports does that require?
body: <p>I simply need the name of the currently logged in user. The same that gets displayed in gsp with <code>&lt;sec:username/&gt;</code>. I'm at a loss as to what to do.
  Here's previous answers and questions - they all seem to require some import and none of the solutions works for me:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/23279897/grails-spring-security-get-current-user">Grails Spring Security (get current user)</a></li>
  <li><a href="https://stackoverflow.com/questions/10294015/how-to-get-id-of-the-current-user-logged-in-grails">How to get id of the current user logged in grails?</a></li>
  <li><a href="https://stackoverflow.com/questions/17526402/how-to-get-current-user-by-using-spring-security-grails-plugin-in-gsp">How to get current_user by using Spring Security Grails plugin in GSP</a></li>
  <li><a href="https://stackoverflow.com/questions/775053/grails-and-spring-security-how-do-i-get-the-authenticated-user-from-within-a-co">Grails and Spring Security: How do I get the authenticated user from within a controller?</a></li>
  </ul>
  
  <p>Specifically, I want to access the username insides a controller and put it into a variable of a domain instance in order to persist it (alongsides other information) into the database for logging purposes. Insides that controller, there's nothing to be seen that even remotely refers to Person/User classes, spring security or any other thing that sounds like it might do what I intend.</p>