Changeset 940
- Timestamp:
- Oct 12, 2010, 4:17:39 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/application.properties
r938 r940 5 5 app.servlet.version=2.4 6 6 app.version=0.5.0 7 plugins.aaaa=0.3.57 #plugins.aaaa=0.3.5 8 8 plugins.crypto=2.0 9 9 plugins.db-util=0.4 -
trunk/grails-app/controllers/RestController.groovy
r936 r940 25 25 class RestController { 26 26 27 28 29 27 /**************************************************/ 30 28 /** Rest resources for Simple Assay Module (SAM) **/ 31 29 /**************************************************/ 32 30 33 def authService31 def AuthenticationService 34 32 def beforeInterceptor = [action:this.&auth,except:["isUser"]] 35 33 def credentials 36 def requestUser = SecUser.findByName( "user" )34 def requestUser // = SecUser.findByName( "user" ) 37 35 38 36 /** 39 37 * Authorization closure, which is run before executing any of the REST resource actions 40 38 * It fetches a username/password combination from basic HTTP authentication and checks whether 41 * that is an active ( nimble) account39 * that is an active (SecuritySpring) account 42 40 * @return 43 41 */ 44 42 private def auth() { 45 43 46 credentials = BasicAuthentication.credentialsFromRequest(request) 47 //requestUser = authService.authUser(credentials.u,credentials.p) 48 // we circumvene the user 44 credentials = BasicAuthentication.credentialsFromRequest(request) 45 requestUser = AuthenticationService.authenticateUser(credentials.u, credentials.p) 46 47 // we circumvene the user 49 48 if(!requestUser) { 50 49 response.sendError(403) … … 66 65 boolean isUser 67 66 credentials = BasicAuthentication.credentialsFromRequest(request) 68 //def reqUser = authService.authUser(credentials.u,credentials.p) 69 if (reqUser) { 67 def reqUser = AuthenticationService.authenticateUser(credentials.u, credentials.p) 68 69 if (reqUser) { 70 70 isUser = true 71 71 } … … 277 277 } 278 278 279 /**280 * REST resource for dbNP modules.281 *282 * @param studyToken String, the external identifier of the study283 * @return List of all fields of this study284 * @return285 *286 * Example REST call (without authentication):287 * http://localhost:8080/gscf/rest/getStudy/study?studyToken=PPSH288 *289 * Returns the JSON object:290 * {"title":"NuGO PPS human study","studyToken":"PPSH","startDate":"2008-01-13T23:00:00Z",291 * "Description":"Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.",292 * "Objectives":null,"Consortium":null,"Cohort name":null,"Lab id":null,"Institute":null,293 * "Study protocol":null}294 */295 279 def getAuthorizationLevel = { 296 def items = [:]297 /*if( params.studyToken ) {298 def study = Study.find( "from Study as s where code=?",[params.studyToken])299 300 }301 render items as JSON*/302 }303 304 305 306 307 308 /**309 * REST resource for dbNP modules.310 *311 * @param studyToken String, the external identifier of the study312 *313 * Dummy for testing only. (Warning: to be replaced as soon as the authorization is implemented!)314 * @param Hash with exactly the values that will be returned315 *316 * @return Hash with keys 'isReader', 'isEditor', 'isOwner' }317 */318 319 /*def getAuthorizationLevel = {320 321 isReader = false322 isEditor = false323 isOwner = false324 325 280 // Warning: this case is only for testing! 326 281 // The code below should be used until the 327 282 // authorization works. 328 if( params.isOwner || params.isEditor || params.Owner ) {283 /*if( params.isOwner || params.isEditor || params.Owner ) { 329 284 return render ['isReader':params.isOwner, 330 285 'isEditor':params.isEditor, 'isOwner':params.isOwner] as JSON 331 } 332 333 334 // in future the users authorization level will be based on authorization model 335 /* 286 }*/ 287 288 // in future the users authorization level will be based on authorization model 336 289 if( params.studyToken ) { 337 290 def id = params.studyToken … … 340 293 } 341 294 342 def user295 /*def user 343 296 if( params.user ) { 344 297 def id = params.user 345 298 user = users.find( "from User as u where u.code=?", [id]) 346 } 347 348 if( study.readers.contains(user) ) isReader = true 349 if( study.editors.contains(user) ) isEditor = true 350 if( study.owner.contains(user) ) isOwner = true 351 352 353 354 render ['isReader':isOwner, 'isEditor':isEditor, 'isOwner':isOwner] as JSON 355 }*/ 356 357 299 }*/ 300 301 def perm = study.getPermissions(requestUser) 302 303 render ('isOwner': study.isOwner(requestUser), 304 'create': perm.create, 'read':perm.read, 305 'update': perm.update, 'delete':perm.delete 306 ) as JSON 307 } 358 308 }
Note: See TracChangeset
for help on using the changeset viewer.