emr_demo
@ 2
emr_demo / web_emr - Copy / src / main / java / com / bestray / security / controller / MethodProtectedRestController.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
package com.bestray.security.controller; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("protected") public class MethodProtectedRestController { /** * This is an example of some different kinds of granular restriction for endpoints. You can use the built-in SPEL expressions * in @PreAuthorize such as 'hasRole()' to determine if a user has access. Remember that the hasRole expression assumes a * 'ROLE_' prefix on all role names. So 'ADMIN' here is actually stored as 'ROLE_ADMIN' in database! **/ @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") public ResponseEntity<?> getProtectedGreeting() { return ResponseEntity.ok("Greetings from admin protected method!"); } } |
Commits for emr_demo/web_emr - Copy/src/main/java/com/bestray/security/controller/MethodProtectedRestController.java
Revision | Author | Commited | Message |
---|---|---|---|
2 | girijabapi | Thu 11 Oct, 2018 04:44:08 +0000 | initial commit |