0

The requirepermissions in each controller method is inconsistent with the required permissions path. Is it possible to use Aspect to obtain the name of the class object, complete the permissions path, and verify the permissions see code

@RequestMapping(value = "/delete", method - RequestMethod.POST) 
@RequiresPermissions("sys:" + getNameT(clazz) + ":delete")
public BaseResult<?> delete(String[] ids) {
    try {
        return baseservice.delete(ids);
    } catch (Exception e) {
        e.printStackTrace();
        return BaseResult.fail(); 
   }
}

public static String getNameT(Class<?> cls){
    return cls.getSimpleName().toLowerCase();
}
Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60
  • 1
    Please [don't upload text as image](https://meta.stackoverflow.com/a/285557/13447). Edit your question to contain all the information in text form - consider to use the editor's formatting options. Also see [ask]. – Olaf Kock Feb 18 '22 at 08:28
  • Please clarify your question. – pxcv7r Feb 18 '22 at 08:56
  • Not possible (AFAIK), make your own annotation extending RequiresPermisssions with Class and string "delete" as parameter. – Joop Eggen Feb 18 '22 at 09:12
  • The question is interesting but could use some better formulation. As far as I understand, you want subclasses that have different values for your annotation? – kutschkem Feb 18 '22 at 09:12
  • I found some Shiro AOP juggling magic here: https://stackoverflow.com/questions/7743749/shiro-authorization-permission-check-using-annotation-not-working – Adriaan Koster Feb 18 '22 at 09:15
  • Annotation parameters should only be static – HUTUTU Feb 18 '22 at 09:22

1 Answers1

0

In case you are using the default WildcardPermission class, you can just ignore the case of your class name.

Benjamin Marwell
  • 1,173
  • 1
  • 13
  • 36