标签: spnego

如何使用带有Kerberos身份验证的嵌入式Jetty Server 9?

我正在尝试使用Jetty嵌入式服务器来公开我的Rest API,现在我想实现Kerberos身份验证.这就是我创建SecurityHandler的方式

    String domainRealm = "MY.COM";

    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__SPNEGO_AUTH);
    constraint.setRoles(new String[]{domainRealm});
    constraint.setAuthenticate(true);

    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(constraint);
    cm.setPathSpec("/*");

    SpnegoLoginService loginService = new SpnegoLoginService();
    loginService.setConfig("/path/to/spnego.properties");
    loginService.setName(domainRealm);

    ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
    sh.setAuthenticator(new SpnegoAuthenticator());
    sh.setLoginService(loginService);
    sh.setConstraintMappings(new ConstraintMapping[]{cm});
    sh.setRealmName(domainRealm);
Run Code Online (Sandbox Code Playgroud)

这是我的spnego.properties:

targetName = HTTP/target.name.com
Run Code Online (Sandbox Code Playgroud)

我的krb5.ini:

[libdefaults]
default_realm = HW.COM
default_keytab_name = FILE:/path/to/target.name.com.keytab
permitted_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 
default_tgs_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 
default_tkt_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 

[realms]
MY.COM= {
    kdc = 12.13.14.222 #IP adress
    admin_server = 12.13.14.222 # IP …
Run Code Online (Sandbox Code Playgroud)

java rest kerberos jetty spnego

7
推荐指数
1
解决办法
3143
查看次数

我可以向客户表明支持SPNEGO但NTLM不支持HTTP请求吗?

微软利用我目前所知的两个WWW-Authenticate新增功能

  • NTLM
  • 谈判

如果从服务器发送Negotiate,则基于一组条件将使用Kerberos

  • 内联网区域
  • 使用主机名而不是IP访问服务器
  • IE中的集成Windows身份验证已启用,主机在Firefox中受信任
  • 服务器不是浏览器的本地服务器
  • 客户端的Kerberos系统通过域控制器进行身份验证

然后将在服务器和客户端之间尝试Kerberos,如果不满足上述条件,则将尝试NTLM.

我的问题是,是否有一些方法让服务器指示不应该发送NTLM?我目前通过跟踪会话中的请求来处理这个问题,如果收到NTLM消息,它会在其余的会话生命周期中禁用Kerberos和WWW-Authenticate.

ntlm kerberos spnego www-authenticate negotiate

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

通过NTLM从Windows上的Java SE6客户端进行HTTP"协商"身份验证

有没有人知道在Windows上运行的Java 6客户端是否能够在访问实现SPNEGO身份验证协议的Microsoft服务器时通过NTLM进行身份验证?

我的理解是,在Windows上运行的Java 6内置了对SPNEGO的支持,但似乎Java实现不会在无法进行kerberos身份验证的情况下尝试NTLM身份验证.Sun文档中提供的Authenticator示例在响应服务器发送WWW-Authenticate:Negotiate时发生401 Unauthorized错误失败.

以下是测试环境的说明:

目标服务器:

  • Windows 2008 R2独立服务器(不属于AD域)
  • 使用WCF实现的Microsoft SOAP服务
  • WCF配置为SPNEGO身份验证(kerberos和NTLM)
  • 无法重新配置WCF服务器以支持其他身份验证模式:(

客户端机器:

  • Windows 7 64位独立工作站(不属于域)
  • 运行Sun SPNEGO示例的Java SE6客户端

最终目标是使用Apache CXF 2.4.0在WCF服务器上调用SOAP服务.在添加CXF和SOAP的复杂性之前,我一直在尝试使用简单的Java测试应用程序从服务器检索WSDL来解决身份验证问题.

FWIW - 我可以使用Windows服务器的本地管理员登录从IE访问WCF服务器.我还能够创建一个没有任何特殊授权配置的Delphi XE SOAP客户端.Delphi SOAP客户端使用WinInet.

java soap ntlm cxf spnego

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

用于SPNEGO/Kerberos-http身份验证的clojure库

我知道这是一个很长的镜头但是,是否会碰巧有一个用于响应kerberos而不是http(又名spnego)请求的clojure库?

我目前正在考虑使用弹簧安全框架,但我想我会问一个更好的clojure友好的方法以防万一.

clojure spnego

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

当SPNEGO无法用于客户端时,如何回退到BASIC或FORM身份验证?

我最终将我的JBoss AS 7服务器配置为SPNEGO在针对Windows 2008 R2的AD域上使用.我正在使用Java 7.

当用户从域计算机以外的某个地方(例如,从移动电话或更广泛的Internet)访问服务器URL时,系统会提示他们输入用户名和密码,然后我收到错误消息:

Login failure: javax.security.auth.login.LoginException: Unsupported negotiation mechanism 'NTLM'
Run Code Online (Sandbox Code Playgroud)

当用户在登录域时访问URL时,一切正常.

SPNEGOsecurity-domain(standalone.xml)上我配置了2个登录模块:

第一: org.jboss.security.negotiation.spnego.SPNEGOLoginModule

第二:

<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
    <module-option name="password-stacking" value="useFirstPass"/>
    <module-option name="usersProperties" value="file:${jboss.server.config.dir}/spnego-users.properties"/>
    <module-option name="rolesProperties" value="file:${jboss.server.config.dir}/spnego-roles.properties"/>
    <module-option name="defaultUsersProperties" value="file:${jboss.server.config.dir}/spnego-users.properties"/>
    <module-option name="defaultRolesProperties" value="file:${jboss.server.config.dir}/spnego-roles.properties"/>
</login-module>
Run Code Online (Sandbox Code Playgroud)

问题是:我如何回退BASICFORM什么时候SPNEGO超出范围?

谢谢

完全例外如下:

00:40:23,751 ERROR [org.jboss.security.authentication.JBossCachedAuthenticationManager] (http--0.0.0.0-9090-8) Login failure: javax.security.auth.login.LoginException: Unsupported negotiation mechanism 'NTLM'.
        at org.jboss.security.negotiation.spnego.SPNEGOLoginModule.spnegoLogin(SPNEGOLoginModule.java:230) [jboss-negotiation-spnego-2.2.0.SP1.jar:2.2.0.SP1]
        at org.jboss.security.negotiation.spnego.SPNEGOLoginModule.innerLogin(SPNEGOLoginModule.java:194) [jboss-negotiation-spnego-2.2.0.SP1.jar:2.2.0.SP1]
        at org.jboss.security.negotiation.spnego.SPNEGOLoginModule.login(SPNEGOLoginModule.java:137) [jboss-negotiation-spnego-2.2.0.SP1.jar:2.2.0.SP1]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_05]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_05] …
Run Code Online (Sandbox Code Playgroud)

java jboss spnego jboss7.x

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

Windows客户端何时使用Initiator首选NegoEx for SPNEGO?

尝试通过SPNEGO和Kerberos对Windows客户端(IE/Firefox)进行身份验证.服务器端是Java/Tomcat,带有用于SPNEGO身份验证的JCIFS.在Win 2008 R2服务器上托管服务器端时,SSO(Kerberos)auth工作正常.但是,当在2012服务器上时,它失败了GSSException: Defective token detected.

通过网络跟踪深入挖掘我发现,在工作的情况下,IE客户端发送带有4个mechTypes的协商令牌:

  • 1.2.840.48018.1.2.2 - MS KRB5,
  • 1.2.840.113554.1.2.2 - KRB5,
  • 1.3.6.1.4.1.311.2.2.30 - NEGOEX,和
  • 1.3.6.1.4.1.311.2.2.10 - NTLMSSP

在这种情况下,我的服务器端将完成SPNEGO选择MS KRB5.但是,在问题的情况下,IE客户端只发送带有2个mechtypes的令牌 - NEGOEXNTLMSSP.这是首选的发起人.Java不支持NEGOEX,因此失败.

一些搜索显示此问题与JDK*中的错误或DNS问题有关.但是,我在最新的JDK和DNS似乎没问题.所以我的问题是,Windows中的浏览器什么时候切换到SPNEGO中的NEGOEX?为什么?我找到的最接近的答案是在msdn博客中说的Kerberos is not available since it's not in a domain environment.但是,客户端确实在域环境中并klist显示有效的Kerberos票证.如果它确实是一个域问题,究竟可能是根本原因,我该如何避免这个问题呢?


  • 脚注,一些背景研究信息:JDK8已经在GSS机制中看到了许多修复.在jdk8u40和jdk8u45中有些东西被破坏了.然后在jdku65中进一步修复.这本来是要实现NEGOEX一个错误报告被关闭了修复

    "修复SPNEGO,允许NEGOEX出现并绕过"

    但是,我不确定NEGOEX是否真的有效.NEGOEX IETF标准在RFC过期状态下被放弃了.所以我怀疑它是否真的得到了Java,库的支持.

java kerberos active-directory spnego single-sign-on

6
推荐指数
0
解决办法
590
查看次数

使用Spnego/Kerberos进行Spring启动 - 配置问题 - 需要ServletContext来配置默认的servlet处理

让spring-security-kerberos-web与Spring Boot应用程序一起工作,我似乎已经达到了一个死胡同.

我的项目中有一个@Configuration类,如下所示

package com.co.dept.bsc.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.FileSystemResource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider;
import org.springframework.security.kerberos.authentication.KerberosServiceAuthenticationProvider;
import org.springframework.security.kerberos.authentication.sun.GlobalSunJaasKerberosConfig;
import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosClient;
import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator;
import org.springframework.security.kerberos.web.authentication.SpnegoAuthenticationProcessingFilter;
import org.springframework.security.kerberos.web.authentication.SpnegoEntryPoint;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;

import com.co.dept.bsc.service.DummyUserDetailsService;

@Configuration
@EnableWebSecurity
public class AuthProviderConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http.exceptionHandling().authenticationEntryPoint(spnegoEntryPoint()).and().authorizeRequests().antMatchers("/", "/home")
            .permitAll().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout().permitAll()
            .and()
            .addFilterBefore(spnegoAuthenticationProcessingFilter(authenticationManagerBean()), BasicAuthenticationFilter.class);
    }

    @Override
    protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(kerberosAuthenticationProvider())
            .authenticationProvider(kerberosServiceAuthenticationProvider());
    }

    @Bean
    public KerberosAuthenticationProvider kerberosAuthenticationProvider() { …
Run Code Online (Sandbox Code Playgroud)

java kerberos spring-security spnego spring-boot

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

使用 requests_gssapi、Python 时 DLL 无法加载问题

在我的 Python 脚本中,我在应用请求包时需要 gssapi 作为身份验证机制。

我注意到包 requests_gssapi 似乎对我的目的很有希望。

在“pip install requests_gssapi”并导入之后,我得到了这个:

>>> from requests_gssapi import HTTPSPNEGOAuth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\opt\Python36\lib\site-packages\requests_gssapi\__init__.py", line 17, in <module>
    from .gssapi_ import HTTPSPNEGOAuth, REQUIRED, OPTIONAL, DISABLED  # noqa
  File "C:\opt\Python36\lib\site-packages\requests_gssapi\gssapi_.py", line 6, in <module>
    import gssapi
  File "C:\opt\Python36\lib\site-packages\gssapi\__init__.py", line 29, in <module>
    from gssapi.raw.types import NameType, RequirementFlag, AddressType  # noqa
  File "C:\opt\Python36\lib\site-packages\gssapi\raw\__init__.py", line 50, in <module>
    from gssapi.raw.creds import *  # noqa
ImportError: DLL load failed: …
Run Code Online (Sandbox Code Playgroud)

python spnego python-requests

6
推荐指数
0
解决办法
273
查看次数

Jetty + Programatic SPNEGO配置

我正在尝试配置嵌入式Jetty Web服务器以编程方式使用SPNEGO(不使用xml).

我试图将此转换为:http://www.eclipse.org/jetty/documentation/current/spnego-support.html到非基于xml的配置.这是我的尝试:

AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();

// ...

String domainRealm = "MY.DOMAIN.COM";

Constraint constraint = new Constraint();
constraint.setName(Constraint.__SPNEGO_AUTH);
constraint.setRoles(new String[] { domainRealm });
constraint.setAuthenticate(true);

ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/*");

SpnegoLoginService loginService = new SpnegoLoginService();
loginService.setConfig(System.getProperty("spnego.properties"));
loginService.setName(domainRealm);

ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
sh.setLoginService(loginService);
sh.setConstraintMappings(new ConstraintMapping[]{cm});
sh.setRealmName(domainRealm);

ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setErrorHandler(new ErrorHandler() { }); // TODO
contextHandler.setContextPath(contextPath);
contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), "/*");
contextHandler.addEventListener(new ContextLoaderListener(context));
contextHandler.setSecurityHandler(sh);

Server server = new Server(port);
server.setHandler(contextHandler);
Run Code Online (Sandbox Code Playgroud)

但是,当我点击服务器时,它正在尝试使用基本身份验证(base 64). …

java jetty spnego embedded-jetty

5
推荐指数
1
解决办法
1089
查看次数

SPNEGO / ActiveDirectory / AES256:校验失败

我正在尝试将 SPNEGO/Kerberos5 身份验证与 Active Directory 2008 和 Java 一起使用。我遵循了本指南:http : //spnego.sourceforge.net/ - “预检”进展顺利,但后来我得到了著名的例外:

Exception in thread "main" GSSException: Failure unspecified at GSS-API level (Mechanism level: Checksum failed)
    at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:856)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:342)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
    at sun.security.jgss.spnego.SpNegoContext.GSS_acceptSecContext(SpNegoContext.java:906)
    at sun.security.jgss.spnego.SpNegoContext.acceptSecContext(SpNegoContext.java:556)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:342)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
    at de.meona.auth.spnego.TestSpnegoAes.main(TestSpnegoAes.java:45)
Caused by: KrbException: Checksum failed
    at sun.security.krb5.internal.crypto.Aes256CtsHmacSha1EType.decrypt(Aes256CtsHmacSha1EType.java:102)
Run Code Online (Sandbox Code Playgroud)

我仔细查看了这篇文章,因为问题似乎很相似: 校验和失败:Kerberos / Spring / Active Directory (2008)

为了使问题可重现,我编写了一个小的 Java 类。我能够单步到发生异常的那一行。我认为这是因为用于解密的秘密服务密钥与 Active Directory 用于加密服务票证的秘密服务密钥不同。怎么会这样?

public class TestSpnegoAes {

    private static Oid spnegoOid = null;
    private static String negotiate = …
Run Code Online (Sandbox Code Playgroud)

java kerberos spnego

5
推荐指数
1
解决办法
2729
查看次数