JAAS其他LoginModules [英] JAAS additional LoginModules

查看:222
本文介绍了JAAS其他LoginModules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何结合这两个身份验证步骤:

I'd like to know how to combine these two authentication steps :


  1. 检查LDAP中的用户/密码

  2. 将DB中的主体(角色)添加到主题中。

LDAP用户存储库没有关于应用程序特定角色的想法,我不想管理应用程序数据库中的密码。所以我需要两者。

The LDAP user repository have no idea about application-specific roles and I don't want to manage the passwords in the application DB. So I need both.

JAAS配置文件允许有额外的LoginModules:

JAAS configuration file allows to have additional LoginModules :

<name used by application to refer to this entry> { 
    <LoginModule> <flag> <LoginModule options>;
    <optional additional LoginModules, flags and options>;
};

但我找不到解释我如何工作的例子。

but I can't find example that explains how I works.

这是好方法吗?

谢谢

====== ===================================

=========================================

这是我的答案:

确实,我们可以有额外的LoginModule。 JAAS配置文件是:

Indeed we can have additional LoginModules. The JAAS configuration file is :

Sample {
  com.sun.security.auth.module.LdapLoginModule Requisite
  userProvider="ldap://acme.org:389/OU=Users,OU=_ACME,DC=acmegis,DC=acme,DC=org"
  authIdentity="{USERNAME}"
  userFilter="(userPrincipalName={USERNAME})"
  storePass=true

  sample.module.SampleLoginModule required debug=true;
};

这里我们有两个LoginModule:

Here we have two LoginModules :

Sun的LdapLoginModule检查用户/密码,
和我的sample.module.SampleLoginModule查询我的数据库并填充主体。
重要的参数是storePass = true,它要求LdapLoginModule将用户名和密码存储在模块的共享状态中。 (参见 http://docs.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/module/LdapLoginModule.html )。

The Sun's LdapLoginModule that checks user/password, and mine sample.module.SampleLoginModule that query my db and fills the principals. The important parameter is storePass=true that asks the LdapLoginModule to store the username and password in the module's shared state. (see http://docs.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/module/LdapLoginModule.html).

因此,下一个LoginModules可以获取传递给sharedState Map参数中initialize方法的用户名。他们应该在login()中没有任何关系,并且在DB中用于填充Principales的查询是在commit()中完成的(就像Shimi Bandiel所说的那样)。

So the next LoginModules can get the username passed to the initialize method in the sharedState Map argument. They should have nothing to do in login() and the query in DB to fill the Principales is done in commit() (like Shimi Bandiel said).

我不知道使用它但是有一个由JBoss开发的DatabaseServerLoginModule(参见 http://community.jboss.org/wiki / DatabaseServerLoginModule )支持身份验证和角色映射。与password-stacking = useFirstPass一起使用,我们应该得到我的需要,而不需要写任何行代码(但是一个漂亮的JAAS配置文件)。

I don't use it yet but there is a DatabaseServerLoginModule developed by JBoss (see http://community.jboss.org/wiki/DatabaseServerLoginModule) that supports authentication and role mapping. Used with password-stacking=useFirstPass we should have the answer to my need without write any line-code (but a beautiful JAAS configuration file).

BR

推荐答案

您应该在 login <中实现 LoginModule / code>您访问LDAP并检查用户名/密码的方法,并在 commit 方法中访问数据库并填写主体。

这里不需要使用多个 LoginModule

You should implement a LoginModule which in the login method you access the LDAP and check username/password and in the commit method you access the DB and fill the principals.
There is no need here to use multiple LoginModule

这篇关于JAAS其他LoginModules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆