小编Joã*_*ves的帖子

通过Spring安全性进行基本身份验证,无需登录表单

我正在尝试创建一个将由其他Web服务使用的restful Web服务.理想情况下,当客户端访问服务并且未经过身份验证时,他们应该获得401.我希望用户能够通过向请求添加身份验证标头来进行身份验证.我不希望用户填写登录表单,然后发布.我也不希望它在cookie中存储任何登录凭证(即保持状态)它应该在每个请求的auth头发送中.我使用spring roo来创建Web服务.

我目前所拥有的(取自一个spring security 3.1教程),当用户获得401时,他们会被提交一个登录页面,然后发布页面,获得他们随每个请求发送的cookie.

这是我的spring security xml.

 <http use-expressions="true">
   <intercept-url pattern="/customers/**" access="isAuthenticated()" />
 <intercept-url pattern="/**" access="denyAll" />
<form-login />
 </http>
<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="alice" password="other" authorities="user" />
            <user name="custome1" password="other" authorities="user" />
        </user-service>
    </authentication-provider>
</authentication-manager>
Run Code Online (Sandbox Code Playgroud)

当我从curl发送请求时,我得到以下内容:

 $ curl -i -H "Accept: application/json" -H "Authorization: Basic Y3VzdG9tZXIxOm90aGVy" http://localhost:8080/Secured/customers

 HTTP/1.1 302 Found
 Server: Apache-Coyote/1.1
 Set-Cookie: JSESSIONID=B4F983464F68199FA0160DBE6279F440; Path=/Secured/; HttpOnly
 Location:      http://localhost:8080/Secured/spring_security_login;jsessionid=B4F983464F68199FA0160DBE6279F440
 Content-Length: 0
 Date: Thu, 25 Apr 2013 17:18:48 GMT
Run Code Online (Sandbox Code Playgroud)

我的基本标头令牌是base64(customer1:other)

如何让Web服务接受auth标头,而不是将我重定向到登录页面?

当我从security.xml中删除时,我得到以下内容:

excpetion:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
    Configuration problem: No AuthenticationEntryPoint could be …
Run Code Online (Sandbox Code Playgroud)

spring spring-security basic-authentication

13
推荐指数
2
解决办法
2万
查看次数

Xcode 15 无法连接到装有 iOS 17 的 iPhone 11

我一直在使用 iPhone 11 开发 iPhone 应用程序。直到最近发布 Xcode 15 和 iOS 17 为止,一切都很顺利,但突然间,更新几周后,我的 Xcode 不再能够连接到 iPhone。它卡在“等待重新连接”上。

在此输入图像描述

到目前为止,这是我尝试过的:

  1. 多次取消与 iPhone 的配对并重新配对
  2. 卸载并重新安装 Xcode
  3. 尝试使用不同的电缆将 iPhone 连接到 Mac
  4. 重新启动了我的 Mac 和手机
  5. 在 iPhone 上禁用并重新启用程序员模式

这些都没有帮助。我真的需要连接手机,因为这是一个相机应用程序,因为模拟器不运行相机。

我在装有 macOS Ventura 13.6 的 Apple M1 上运行 Xcode 15。

我该怎么做才能将我的 iPhone 再次连接到 Xcode?

编辑:我用我的 iPad 5 和 iPhone 14 进行了尝试,得到了相同的结果,这让我认为 Mac 本身有问题。Mac 具有 Perimeter 81 VPN 和 Vanta 软件,这两种软件都可能影响通过 Wi-Fi 的连接。不过,禁用 VPN 似乎并不能解决问题。我不确定是否可以卸载 Vanta,因为它是公司拥有的 Mac。即使在更新到 Xcode 15 之前,我也从未能够通过 Wi-Fi 连接我的 iPhone。

根据发行说明, VPN 存在一个已知问题,但我不确定这里是否属于这种情况。

在此输入图像描述

iphone xcode ios

6
推荐指数
1
解决办法
4346
查看次数

处理抛出Throwable的方法时,应该避免抛出Throwable吗?

我有一个带@Aspect注释的类正在调用ProceedingJoinPoint#proceed()。此方法throws Throwable以及类的外观如下所示:

@Aspect
@Component
public class MyClass{

    @Around("@annotation(myAnnotation)")
    public Object myMethod(final ProceedingJoinPoint joinPoint) throws Throwable {
        //some code here
        try {
            return joinPoint.proceed();
        } finally {
            //some more code here
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它是确定了myMehtod投掷Throwable在这种情况下,我必须调用另一个方法是throws Throwable?我应该避免抛出Throwable并以某种方式将其转换为Exceptionor Error吗?

无论哪种情况,我都想知道为什么。谢谢。

java aop aspectj throwable throws

3
推荐指数
1
解决办法
1734
查看次数