Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion shiro-basic/src/main/resources/shiro.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
# Usernames/passwords are based on the classic Mel Brooks' film "Spaceballs" :)
# =============================================================================

# -----------------------------------------------------------------------------
# Shiro objects and settings
#
# This example authenticates programmatically in LoginAction rather than letting
# Shiro's form filter do it, so authc only needs to know where to send an
# unauthenticated visitor. Shiro's default is /login.jsp, which does not exist
# here — the login form is rendered by the "login" Struts action.
# -----------------------------------------------------------------------------
[main]
authc.loginUrl = /login.action

# -----------------------------------------------------------------------------
# Users and their (optional) assigned roles
# username = password, role1, role2, ..., roleN
Expand All @@ -22,4 +33,19 @@ lonestarr = vespa, goodguy, schwartz
[roles]
admin = *
schwartz = lightsaber:*
goodguy = winnebago:drive:eagle5
goodguy = winnebago:drive:eagle5

# -----------------------------------------------------------------------------
# Filter chain, evaluated top-down — the first matching path wins.
#
# Without this section Shiro protects every path, including the login page and
# the form it posts to, which leaves an unauthenticated visitor in a redirect
# loop. Note that shiroFilter is mapped for FORWARD as well as REQUEST, so the
# JSPs the Struts actions forward to must be listed too, not just the actions.
# -----------------------------------------------------------------------------
[urls]
/index.jsp = anon
/login.action = anon
/authuser.action = anon
/pages/login.jsp = anon
/** = authc
8 changes: 8 additions & 0 deletions shiro-basic/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<display-name>struts2shiro</display-name>

<!-- Track sessions with a cookie only. Without this the container rewrites
redirect URLs as ...;jsessionid=... on a visitor's first request, and
Jetty 11 rejects its own rewritten URI with HTTP 400 Invalid request. -->
<session-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>

<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
Expand Down
Loading