-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable user management API when OIDC security is used.
- Loading branch information
Showing
6 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
target | ||
node_modules | ||
build | ||
logs | ||
**/generated-sources | ||
**/npm-debug.log | ||
.DS_store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/cz/cvut/kbss/study/rest/OidcUserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cz.cvut.kbss.study.rest; | ||
|
||
import cz.cvut.kbss.study.model.User; | ||
import cz.cvut.kbss.study.security.SecurityConstants; | ||
import cz.cvut.kbss.study.service.UserService; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* API for getting basic user info. | ||
* <p> | ||
* Enabled when OIDC security is used. | ||
*/ | ||
@ConditionalOnProperty(prefix = "security", name = "provider", havingValue = "oidc") | ||
@RestController | ||
@RequestMapping("/users") | ||
public class OidcUserController extends BaseController { | ||
|
||
private final UserService userService; | ||
|
||
public OidcUserController(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
@PreAuthorize("hasRole('" + SecurityConstants.ROLE_USER + "')") | ||
@GetMapping(value = "/current", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public User getCurrent() { | ||
return userService.getCurrentUser(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters