Changeset 2081
- Timestamp:
- Nov 4, 2011, 2:57:26 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/authentication/LoginController.groovy
r2080 r2081 58 58 } 59 59 return 60 } else if (request.getHeaderNames().find{ it.toLowerCase() == 'useShibboleth' }) {60 } else if (request.getHeaderNames().find{ it.toLowerCase() == 'useShibboleth'.toLowerCase() }) { 61 61 // authenticated through shibboleth? 62 62 if (request.getHeaderNames().find{ it.toLowerCase() == 'persistent-id'.toLowerCase() }) { 63 63 // get shibboleth data 64 def shibPersistentId = request.getHeader("persistent-id") 64 // note: sometimes apache makes the request headers lowercase, sometimes 65 // it doesn't. To make sure it always works we use a case insensitive 66 // finder to find the request header name 67 def shibPersistentId = request.getHeader(request.getHeaderNames().find{ it.toLowerCase() == 'persistent-id'.toLowerCase() }) 65 68 def shibUid = request.getHeader("uid") 66 def shibEmail = request.getHeader( "Shib-InetOrgPerson-mail")67 def shibOrganization = request.getHeader( "schacHomeOrganization")68 def shibDisplayName = request.getHeader( "displayName")69 def shibEmail = request.getHeader(request.getHeaderNames().find{ it.toLowerCase() == 'Shib-InetOrgPerson-mail'.toLowerCase() }) 70 def shibOrganization = request.getHeader(request.getHeaderNames().find{ it.toLowerCase() == 'schacHomeOrganization'.toLowerCase() }) 71 def shibDisplayName = request.getHeader(request.getHeaderNames().find{ it.toLowerCase() == 'displayName'.toLowerCase() }) 69 72 70 73 // does a user exist with this username? … … 74 77 user = new SecUser() 75 78 user.username = shibPersistentId 79 user.password = springSecurityService.encodePassword("myDummyPassword", shibPersistentId) 80 user.email = shibEmail 81 user.displayName = shibDisplayName 82 user.organization = shibOrganization 83 user.uid = shibUid 84 user.shibbolethUser = true 76 85 user.enabled = true 77 86 user.userConfirmed = true … … 79 88 user.accountExpired = false 80 89 user.accountLocked = false 81 user.save() 82 83 // refresh user 84 user.refresh() 90 user.save(failOnError:true) 85 91 } 86 92 87 93 // login user 88 //user. 89 90 } 94 springSecurityService.reauthenticate(user.username, user.password) 95 96 // redirect user 97 if (params.returnURI) { 98 // see basefilters 99 redirect uri: params.returnURI 100 } else { 101 redirect uri: config.successHandler.defaultTargetUrl 102 } 103 } 104 } else { 105 println "nope..." 91 106 } 92 107 -
trunk/grails-app/domain/dbnp/authentication/SecUser.groovy
r1939 r2081 2 2 3 3 class SecUser implements Serializable { 4 5 String username 6 String password 4 String username // for shibboleth this is request header: persistent-id 5 String password // for shibboleth this is springSecurityService.encodePassword("myDummyPassword", shibPersistentId) 6 String displayName // shibboleth request header: displayName 7 String organization // shibboleth request header: schacHomeOrganization 8 String uid // shibboleth request header: uid 9 String voName // shibboleth request header: coin-vo-name 10 String userStatus // shibboleth request header: coin-user-status 7 11 String email 8 12 Date dateCreated 13 boolean shibbolethUser = false 9 14 boolean enabled 10 15 boolean accountExpired … … 16 21 static constraints = { 17 22 username blank: false, unique: true 18 password blank: false23 password blank: true 19 24 email blank: false 25 displayName nullable: true 26 organization nullable: true 27 uid nullable: true 28 voName nullable: true 29 userStatus nullable: true 20 30 } 21 31 -
trunk/grails-app/views/common/_login_panel.gsp
r2080 r2081 62 62 <ul class="login"> 63 63 <li class="left"> </li> 64 <li>Hello <sec:ifLoggedIn><sec:username/></sec:ifLoggedIn> 64 <li>Hello <sec:ifLoggedIn> 65 <g:if test="${session.gscfUser.shibbolethUser && session.gscfUser.displayName}"> 66 ${session.gscfUser.displayName} 67 </g:if><g:else> 68 <sec:username/> 69 </g:else> 70 </sec:ifLoggedIn> 65 71 <sec:ifNotLoggedIn>Guest</sec:ifNotLoggedIn>!</li> 66 72 <sec:ifLoggedIn> -
trunk/grails-app/views/userRegistration/profile.gsp
r1430 r2081 1 1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 4 <meta name="layout" content="main" /> 5 <title>User profile</title> 6 </head> 7 <body> 8 <div class="body" id="register"> 9 <div class="inner"> 10 <g:if test="${flash.message}"> <div class='login_message'>${flash.message}</div></g:if> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 4 <meta name="layout" content="main"/> 5 <title>User profile</title> 6 </head> 11 7 12 <div class='fheader'>You can change your user details here. If you don't want to change your password, keep it empty. </div> 8 <body> 9 <div class="body" id="register"> 10 <g:if test="${user.shibbolethUser}"> 11 <table> 12 <tr> 13 <td>Username</td> 14 <td>${user.uid}</td> 15 </tr> 16 <tr> 17 <td>Email</td> 18 <td>${user.email}</td> 19 </tr> 20 <tr> 21 <td>Organization</td> 22 <td>${user.organization}</td> 23 </tr> 24 </table> 25 </g:if> 26 <g:else> 27 <div class="inner"> 28 <g:if test="${flash.message}"><div class='login_message'>${flash.message}</div></g:if> 13 29 14 <g:hasErrors bean="${command}"> 15 <g:renderErrors bean="${command}" as="list" /> 16 </g:hasErrors> 30 <div class='fheader'>You can change your user details here. If you don't want to change your password, keep it empty.</div> 17 31 18 <form action='<g:createLink controller="userRegistration" action="updateProfile" />' method='POST' id='loginForm' class='cssform' autocomplete='off'> 19 <div class="dialog"> 20 <table> 21 <tbody> 32 <g:hasErrors bean="${command}"> 33 <g:renderErrors bean="${command}" as="list"/> 34 </g:hasErrors> 22 35 23 <tr class="prop"> 24 <td valign="top" class="name"> 25 <label for="username">Username</label> 26 </td> 27 <td valign="top" class="value ${hasErrors(bean: command, field: 'username', 'errors')}"> 28 <g:textField disabled="disabled" name="title" value="${user?.username}" /> 29 </td> 30 </tr> 31 <tr class="prop"> 32 <td valign="top" class="name"> 33 <label for="password">Password</label> 34 </td> 35 <td valign="top" class="value ${hasErrors(bean: command, field: 'password', 'errors')}"> 36 <g:passwordField name="password" value="" /> 37 </td> 38 </tr> 39 <tr class="prop"> 40 <td valign="top" class="name"> 41 <label for="password2">Repeat password</label> 42 </td> 43 <td valign="top" class="value ${hasErrors(bean: command, field: 'password2', 'errors')}"> 44 <g:passwordField name="password2" value="" /> 45 </td> 46 </tr> 47 <tr class="prop"> 48 <td valign="top" class="name"> 49 <label for="email">Email address</label> 50 </td> 51 <td valign="top" class="value ${hasErrors(bean: command, field: 'email', 'errors')}"> 52 <g:textField name="email" value="${user?.email}" /> 53 </td> 54 </tr> 55 </tbody> 56 </table> 57 </div> 58 <div class="buttons"> 59 <g:each in="${extraparams}" var="param"> 60 <input type="hidden" name="${param.key}" value="${param.value}"> 61 </g:each> 62 <span class="button"><g:submitButton name="edit" class="save" value="Change profile" /></span> 63 <span class="button"><g:link class="cancel" controller="home">Cancel</g:link></span> 64 </div> 65 </form> 66 </div> 67 </body> 36 <form action='<g:createLink controller="userRegistration" action="updateProfile"/>' method='POST' id='loginForm' 37 class='cssform' autocomplete='off'> 38 <div class="dialog"> 39 <table> 40 <tbody> 41 42 <tr class="prop"> 43 <td valign="top" class="name"> 44 <label for="username">Username</label> 45 </td> 46 <td valign="top" class="value ${hasErrors(bean: command, field: 'username', 'errors')}"> 47 <g:textField disabled="disabled" name="title" value="${user?.username}"/> 48 </td> 49 </tr> 50 <tr class="prop"> 51 <td valign="top" class="name"> 52 <label for="password">Password</label> 53 </td> 54 <td valign="top" class="value ${hasErrors(bean: command, field: 'password', 'errors')}"> 55 <g:passwordField name="password" value=""/> 56 </td> 57 </tr> 58 <tr class="prop"> 59 <td valign="top" class="name"> 60 <label for="password2">Repeat password</label> 61 </td> 62 <td valign="top" class="value ${hasErrors(bean: command, field: 'password2', 'errors')}"> 63 <g:passwordField name="password2" value=""/> 64 </td> 65 </tr> 66 <tr class="prop"> 67 <td valign="top" class="name"> 68 <label for="email">Email address</label> 69 </td> 70 <td valign="top" class="value ${hasErrors(bean: command, field: 'email', 'errors')}"> 71 <g:textField name="email" value="${user?.email}"/> 72 </td> 73 </tr> 74 </tbody> 75 </table> 76 </div> 77 78 <div class="buttons"> 79 <g:each in="${extraparams}" var="param"> 80 <input type="hidden" name="${param.key}" value="${param.value}"> 81 </g:each> 82 <span class="button"><g:submitButton name="edit" class="save" value="Change profile"/></span> 83 <span class="button"><g:link class="cancel" controller="home">Cancel</g:link></span> 84 </div> 85 </form> 86 </g:else> 87 88 </div> 89 </body> 68 90 </html>
Note: See TracChangeset
for help on using the changeset viewer.