【问题标题】:Spring Boot 2 Actuator Httptrace Principal is nullSpring Boot 2 Actuator Httptrace 主体为空
【发布时间】:2019-11-02 11:10:10
【问题描述】:

我有一个使用 spring boot 2、执行器和 spring security 的宁静 Web 应用程序。

在进行一些测试时,我检查了 /httptrace 路径并意识到主体返回为空。我很困惑为什么会这样,因为当我调试日志时 SecurityContextHolder.getContext().getAuthentication().getPrincipal() 我找回了实现 UserDetails 的 Application 对象。

所以我很好奇为什么当我有一个委托人时委托人会返回为空。如果我可以提供更多详细信息来帮助解决此问题,请在 cmets 中告诉我,我会将它们包括在内。

{
    "traces":[
        {
            "timestamp":"2019-06-19T16:14:33.252994100Z",
            "principal":null,
            "session":null,
            "request":{
                "method":"GET",
                "uri":"http://localhost:8080/api/ims/oneroster/v1p1/orgs",
                "headers":{
                    "cookie":[
                        "JSESSIONID=095BD749...."
                    ],
                    "postman-token":[
                        "54c241d7-8810-459c-b62a-bd64e9c73e9f"
                    ],
                    "host":[
                        "localhost:8080"
                    ],
                    "connection":[
                        "keep-alive"
                    ],
                    "cache-control":[
                        "no-cache"
                    ],
                    "accept-encoding":[
                        "gzip, deflate"
                    ],
                    "user-agent":[
                        "PostmanRuntime/7.15.0"
                    ],
                    "accept":[
                        "*/*"
                    ]
                },
                "remoteAddress":null
            },
            "response":{
                "status":"200",
                "headers":{
                    "X-Frame-Options":[
                        "DENY"
                    ],
                    "Transfer-Encoding":[
                        "chunked"
                    ],
                    "Cache-Control":[
                        "no-cache, no-store, max-age=0, must-revalidate"
                    ],
                    "X-Content-Type-Options":[
                        "nosniff"
                    ],
                    "Pragma":[
                        "no-cache"
                    ],
                    "Expires":[
                        "0"
                    ],
                    "X-XSS-Protection":[
                        "1; mode=block"
                    ],
                    "Date":[
                        "Wed, 19 Jun 2019 16:14:33 GMT"
                    ],
                    "Content-Type":[
                        "application/json;charset=UTF-8"
                    ]
                }
            },
            "timeTaken":"389"
        }
    ]
}

【问题讨论】:

  • 您找到解决方案了吗?
  • @don-prog 还没有。

标签: spring-boot spring-security spring-boot-actuator


【解决方案1】:

默认情况下,Spring Actuator HTTP 跟踪仅包含值的子集。你必须configure Spring来包含原理,例如:

management.trace.http.include=principal,request-headers,response-headers,cookie-headers,time-taken,authorization-header,remote-address,session-id

【讨论】:

  • 抱歉回复晚了,但我只想说谢谢你的正确答案。对于任何查看此内容并使用 Boot 2.2+ 的人,您需要使用以下链接来启用 httptrace。 stackoverflow.com/questions/59115578/…
猜你喜欢
  • 2020-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-01
  • 2018-09-10
  • 1970-01-01
  • 2019-02-08
  • 2019-01-08
相关资源
最近更新 更多