[Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode

Đang mở
#2,962 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@AndrewG10i đang làm issue này rồi.

Từ ngày 18/11/2026.

  • #2963 của @AndrewG10i — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

java valid
Search before asking
Environment

Description

In Shiro 3.0.1, setting org.apache.shiro.ee.secure-session-cookie.disabled=true does not prevent the Jakarta EE integration from forcing secure session cookies when Jakarta Faces runs in Production mode.

The Jakarta EE integration documentation describes this parameter as a way to disable that behaviour.

Environment

  • Apache Shiro: 3.0.1
  • Integration: shiro-jakarta-ee
  • Jakarta Faces project stage: Production
  • Servlet container-managed sessions
  • Local application accessed over HTTP at http://localhost:8080
Shiro version
  1. Initially was reproduced with Apache Shiro: 3.0.1;
  2. Seems in version 3.0.2 code was not changed - so assuming it is still valid.
What was the actual outcome?

Shiro still forces the session cookie’s Secure flag even with org.apache.shiro.ee.secure-session-cookie.disabled=true in web.xml.

What was the expected outcome?

The explicit override prevents Shiro from forcing the session cookie’s Secure flag. Faces Production mode should remain usable for local HTTP testing.

How to reproduce
  1. Configure the following in web.xml:

    <context-param>
        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    
    <context-param>
        <param-name>org.apache.shiro.ee.secure-session-cookie.disabled</param-name>
        <param-value>true</param-value>
    </context-param>
    
  2. Start the application.

  3. Access a page that creates a session over HTTP.

  4. Inspect the session cookie’s Set-Cookie header.

Debug logs

Suspected cause

In org.apache.shiro.ee.listeners.EnvironmentLoaderListener, modifySecureSessionConfiguration() contains:

if (!Boolean.parseBoolean(sce.getServletContext()
        .getInitParameter(SHIRO_EE_DISABLE_SECURE_SESSION_COOKIE_PARAM))
        && !hasFacesContext() || !Faces.isDevelopment()) {
    sce.getServletContext().getSessionCookieConfig().setSecure(true);
}

Because && has higher precedence than ||, the condition evaluates as:

(!disabled && !hasFacesContext()) || !Faces.isDevelopment()

Consequently, when Faces is in Production mode, the final operand is true, regardless of the explicit override.

Suggested fix

Group the stage check so the override applies to the entire condition:

if (!Boolean.parseBoolean(sce.getServletContext()
        .getInitParameter(SHIRO_EE_DISABLE_SECURE_SESSION_COOKIE_PARAM))
        && (!hasFacesContext() || !Faces.isDevelopment())) {
    sce.getServletContext().getSessionCookieConfig().setSecure(true);
}

A regression test should verify that disabled=true prevents Shiro from forcing secure cookies in Faces Production mode, while the default Production behavior remains secure.

Ngôn ngữ chính
Java
Star
4.5k
Fork
2.3k
Merge trung bình
1 ngày 5 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/shiro

Tất cả issue của apache/shiro

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.