-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Authorization Denied Handlers for Method Security
Closes gh-14601
- Loading branch information
1 parent
19d66c0
commit d85857f
Showing
36 changed files
with
2,461 additions
and
61 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ringframework/security/config/annotation/method/configuration/MethodSecuritySelector.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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2002-2023 the original author or authors. | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -18,6 +18,7 @@ | |
|
||
import java.util.List; | ||
|
||
import org.springframework.security.access.AccessDeniedException; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
|
@@ -126,4 +127,74 @@ public List<String> allAnnotations(List<String> list) { | |
public void repeatedAnnotations() { | ||
} | ||
|
||
@Override | ||
public String postAuthorizeGetCardNumberIfAdmin(String cardNumber) { | ||
return cardNumber; | ||
} | ||
|
||
@Override | ||
public String preAuthorizeGetCardNumberIfAdmin(String cardNumber) { | ||
return cardNumber; | ||
} | ||
|
||
@Override | ||
public String preAuthorizeWithHandlerChildGetCardNumberIfAdmin(String cardNumber) { | ||
return cardNumber; | ||
} | ||
|
||
@Override | ||
public String preAuthorizeThrowAccessDeniedManually() { | ||
throw new AccessDeniedException("Access Denied"); | ||
} | ||
|
||
@Override | ||
public String postAuthorizeThrowAccessDeniedManually() { | ||
throw new AccessDeniedException("Access Denied"); | ||
} | ||
|
||
@Override | ||
public String preAuthorizeDeniedMethodWithMaskAnnotation() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String preAuthorizeDeniedMethodWithNoMaskAnnotation() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String postAuthorizeDeniedWithNullDenied() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String postAuthorizeDeniedMethodWithMaskAnnotation() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String postAuthorizeDeniedMethodWithNoMaskAnnotation() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String preAuthorizeWithMaskAnnotationUsingBean() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public String postAuthorizeWithMaskAnnotationUsingBean() { | ||
return "ok"; | ||
} | ||
|
||
@Override | ||
public UserRecordWithEmailProtected getUserRecordWithEmailProtected() { | ||
return new UserRecordWithEmailProtected("username", "[email protected]"); | ||
} | ||
|
||
@Override | ||
public UserRecordWithEmailProtected getUserWithFallbackWhenUnauthorized() { | ||
return new UserRecordWithEmailProtected("username", "[email protected]"); | ||
} | ||
|
||
} |
Oops, something went wrong.