Skip to content

Model PreAuthorize authentication and ownership - #8

Open
misonijnik wants to merge 1 commit into
demo/basefrom
demo/auth
Open

misonijnik wants to merge 1 commit into
demo/basefrom
demo/auth

Conversation

@misonijnik

Copy link
Copy Markdown
Member

No description provided.

@misonijnik
misonijnik changed the base branch from main to demo/base October 13, 2026 14:49
if (!authorization.isOwner(id, authentication)) {
throw new ResponseStatusException(HttpStatus.FORBIDDEN);
}
return notes.readById(id);

@Transactional
public void deleteById(long id) {
notes.delete(readById(id));
@GetMapping("/{id}")
@PreAuthorize("isAuthenticated()")
public UserNote read(@PathVariable("id") long id) {
return notes.readById(id);
Comment thread src/main/java/org/seqra/spring/auth/VulnerableNoteController.java Fixed
@GetMapping("/forged-owner/{id}")
public UserNote forgedOwner(@PathVariable("id") long id,
@RequestParam("ownerEmail") String ownerEmail) {
return notes.readOwnedById(id, ownerEmail);
Comment thread src/main/java/org/seqra/spring/auth/VulnerableNoteController.java Fixed
@PreAuthorize("@noteAuthorization.isOwner(#id, authentication)")
public UserNote wrongGuard(@P("id") @PathVariable("id") long id,
@RequestParam("otherId") long otherId) {
return notes.readById(otherId);
Comment thread src/main/java/org/seqra/spring/auth/VulnerableNoteController.java Fixed
@GetMapping("/weak-guard/{id}")
@PreAuthorize("@noteAuthorization.isOwner(#id, authentication) or isAuthenticated()")
public UserNote weakGuard(@P("id") @PathVariable("id") long id) {
return notes.readById(id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants