Spring Security and Struts 2

I have a struts2 s action @Secured({"ROLE_ADMIN"})to protect the execute method. In the execute method, I assign the message to a member variable of the action, then return SUCCESS and end on the jsp page. On the page, I retrieve the action member variable with <sproperty>.

private String greeting;

public String execute() throws Exception {
    this.greeting="Hello";
    return SUCCESS;
}

// getters and setters for greeting
...

<s:property value="greeting" />

The problem is when there is a protected annotation, jsp does not show anything for the member variable, but when @Secureddeleted, the whole thing behaves correctly and shows the message that was set to the member variable.

Actual security seems to be working fine, but when it is enabled using annotation, the member variable (or perhaps an action instance) does not get on the value stack.

I do not see error messages.

+3
1

, <s:property value="greeting" /> "ROLE_ADMIN", SecurityContextHolder.getContext().

, " " , , . , http, HttpSessionContextIntegrationFilter.

, , Spring , , , .

+1

Source: https://habr.com/ru/post/1720877/


All Articles