SAMLRequest Error on gheimdall2

266 views
Skip to first unread message

F500

unread,
Oct 17, 2012, 10:48:52 PM10/17/12
to gheimd...@googlegroups.com
後藤と申します。CentOS6上にGHeimdall2をインストールしようとしています。
http://code.google.com/p/gheimdall2/wiki/GHeimdall2OnDebianLenny
のaptitudeをyumに読み替えて、足りないパッケージもどこかで拾ってきて何とか
パッケージ導入まで終わりましたが、ブラウザでアクセスすると、
「SAMLRequestの値が不正です」とエラーになってしまいます。
/var/log/gheimdall2/error.log には下記メッセージが記録されています。

2012-10-18 11:31:21,105: /usr/lib/python2.6/site-packages/gheimdall2/idp/views.py: 98: root: ERROR: a2b_base64() argument 1 must be string or read-only character buffer, not None


設定ファイルの設定項目不足かとは思いますが、どう追いかければよいか、分かりません。

どなたかアドバイスいただけると助かります。
よろしくお願いします。

Takashi Matsuo

unread,
Oct 29, 2012, 1:42:47 AM10/29/12
to gheimd...@googlegroups.com
2012年10月18日 11:48 F500 <r1g1...@gmail.com>:

> 後藤と申します。CentOS6上にGHeimdall2をインストールしようとしています。
> http://code.google.com/p/gheimdall2/wiki/GHeimdall2OnDebianLenny
> のaptitudeをyumに読み替えて、足りないパッケージもどこかで拾ってきて何とか
> パッケージ導入まで終わりましたが、ブラウザでアクセスすると、
> 「SAMLRequestの値が不正です」とエラーになってしまいます。

「ブラウザでアクセス」というのは具体的にどのようにしているのでしょうか?

> /var/log/gheimdall2/error.log には下記メッセージが記録されています。
>
> 2012-10-18 11:31:21,105:
> /usr/lib/python2.6/site-packages/gheimdall2/idp/views.py: 98: root: ERROR:
> a2b_base64() argument 1 must be string or read-only character buffer, not
> None
>
>
> 設定ファイルの設定項目不足かとは思いますが、どう追いかければよいか、分かりません。

設定ファイルがどうなっているかどうか教えてもらわないと誰も助けられませんよ :)

>
> どなたかアドバイスいただけると助かります。
> よろしくお願いします。
>
> --
> このメールは Google グループのグループ「GHeimdall-ja」の登録者に送られています。
> このディスカッションをウェブ上で閲覧するには、https://groups.google.com/d/msg/gheimdall-ja/-/UbBDmHgL5GMJ
> にアクセスしてください。
> このグループに投稿するには、gheimd...@googlegroups.com にメールを送信してください。
> このグループから退会するには、gheimdall-ja...@googlegroups.com にメールを送信してください。
> 詳細については、http://groups.google.com/group/gheimdall-ja?hl=ja
> からこのグループにアクセスしてください。

Tulip Marlowe

unread,
Oct 29, 2012, 7:50:31 AM10/29/12
to gheimd...@googlegroups.com
すみません、その後色々進転がありまして、現在はログイン画面までは何とか
出るようになりました。
現在は、ログイン画面でユーザ名とパスワードを設定すると、クライアントのブラウザに「サーバエラー(500)」
が表示され、/var/log/gheimdall2/error.logに添付ログの内容が表示されます。

config関係は添付したとおりです。あまり手は加えていません。
それと、/usr/lib64/python2.6/site-packages/mod_python/importer.py について、md5関係のエラーが
発生していました。
/usr/lib64/python2.6/site-packages/mod_python/importer.py:32:
DeprecationWarning: the md5 module is deprecated; use hashlib
instead import md5
と出てましたので、ネットで見かけた
http://www.empitsu.com/wp/?p=847
に倣って以下のとおり書き換えています。

[root@gh mod_python]# diff importer.py importer.py.org.20121026
32c32
< import hashlib
---
> import md5
972,975c972
< # return self._prefix + md5.new(file).hexdigest()
< m = hashlib.md5()
< m.update(file)
< return self._prefix + m.hexdigest()
---
> return self._prefix + md5.new(file).hexdigest()
[root@gh mod_python]#

同様に Session.py も書換えています。

OS: CentOS6.3
python-2.6.6-29.el6_3.3.i686


どうぞ宜しくお願いいたします。


それと、settings.py で指定する "SECRET_KEY" の作り方が判らず、
デフォルトのままにしてあります。本来、どのような文字列を生成して
設定すべきでしょうか?
etc_gheumdall2_gheimdall2.conf
etc_httpd_conf.d_gheimdall2.conf
settings.py
var_log_gheimdall2_error.log

Tulip Marlowe

unread,
Oct 29, 2012, 7:52:02 AM10/29/12
to gheimd...@googlegroups.com
すみません、F500とTulip Marloweは同一人物です。


2012年10月29日 20:50 Tulip Marlowe <r1g1...@gmail.com>:

Takashi Matsuo

unread,
Oct 29, 2012, 8:23:59 AM10/29/12
to gheimd...@googlegroups.com
作成した ldapauth_rootbind.py はどこにありますか?
GHeimdall2 現状の作りだと、GHeimdall2 をインストールした中の auth サブディレクトリ内に置く必要がありますよ。

--
Takashi Matsuo
matsuo....@gmail.com
Kay's daddy


2012年10月29日 20:52 Tulip Marlowe <r1g1...@gmail.com>:

> --
> このメールは Google グループのグループ「GHeimdall-ja」の登録者に送られています。

Takashi Matsuo

unread,
Oct 29, 2012, 8:33:35 AM10/29/12
to gheimd...@googlegroups.com
SECRET_KEY にはランダム文字列を生成して使ってください。下記も見てください。
https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SECRET_KEY

# django SECRET_KEY で検索すればヒットしますよ

--
Takashi Matsuo
matsuo....@gmail.com
Kay's daddy


2012年10月29日 21:23 Takashi Matsuo <matsuo....@gmail.com>:

Tulip Marlowe

unread,
Oct 29, 2012, 5:06:34 PM10/29/12
to gheimd...@googlegroups.com
「ldapauth_rootbind.py を作る」と言う意識はありませんでした。
作り方について、どこか説明されたサイトはございますでしょうか。

 インストールしたままの状態で、

/usr/lib/python2.6/site-packages/gheimdall2/auth/ldapauth.py

と言うファイルは存在しています。

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# GHeimdall2 - A small web application for Google Apps SSO service.
# Copyright (C) 2008 SIOS Technology, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = 'tma...@sios.com (Takashi MATSUO)'

from gheimdall2 import auth, utils
import ldap

ERR_LDAP = 2

class LdapAuthEngine(auth.BaseAuthEngine):

def _prepare(self, config):
# This is for standalone use.
self.ldap_uri = config.get('ldap_uri')
self.ldap_basedn = config.get('ldap_basedn')
self.ldap_filter = config.get('ldap_filter')

def _authenticate(self, user_name, password):
ldapHandle = None
try:
ldapHandle = ldap.initialize(self.ldap_uri)
result = ldapHandle.search_s(
self.ldap_basedn,
ldap.SCOPE_SUBTREE,
self.ldap_filter % utils.ldap_escape(user_name))
if len(result) != 1:
ldapHandle.unbind_s()
raise auth.AuthException("ldap search result count is not 1.",
ERR_LDAP)
dn = result[0][0]

# authenticate
ldapHandle.simple_bind_s(who=dn, cred=password)
ldapHandle.unbind_s()
except Exception, e:
if ldapHandle is not None:
try:
ldapHandle.unbind_s()
except:
pass
raise auth.AuthException(e,ERR_LDAP)
return True

cls = LdapAuthEngine

Tulip Marlowe

unread,
Oct 30, 2012, 5:22:22 AM10/30/12
to gheimd...@googlegroups.com
他所のシステムから借りてきたldapauth_rootbind.pyを、
/usr/lib/python2.6/site-packages/gheimdall2/auth/
に置いて、かつ python -m py_compileしてみましたが、エラーが消えません。
ldapauth_rootbindはサイト毎にカスタマイズする必要があるのでしょうか?

[root@gh ~]# cd /usr/lib/python2.6/site-packages/gheimdall2/auth
[root@gh auth]# cat ldapauth_rootbind.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# GHeimdall2 - A small web application for Google Apps SSO service.
# Copyright (C) 2008 SIOS Technology, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = 'tma...@sios.com (Takashi MATSUO)'

from gheimdall2 import auth, utils
import ldap

ERR_LDAP = 2

class LdapAuthRootBindEngine(auth.BaseAuthEngine):

def _prepare(self, config):
# This is for standalone use.
self.ldap_uri = config.get('ldap_uri')
self.ldap_basedn = config.get('ldap_basedn')
self.ldap_filter = config.get('ldap_filter')
self.ldap_rootdn = config.get('ldap_rootdn')
self.ldap_rootpw = config.get('ldap_rootpw')

def _authenticate(self, user_name, password):
ldapHandle = None
try:
ldapHandle = ldap.initialize(self.ldap_uri)
ldapHandle.simple_bind_s(who=self.ldap_rootdn, cred=self.ldap_rootpw)
result = ldapHandle.search_s(
self.ldap_basedn,
ldap.SCOPE_SUBTREE,
self.ldap_filter % utils.ldap_escape(user_name))
if len(result) != 1:
ldapHandle.unbind_s()
raise auth.AuthException("ldap search result count is not 1.",
ERR_LDAP)
dn = result[0][0]
ldapHandle.unbind_s()

ldapHandle = ldap.initialize(self.ldap_uri)

# authenticate
ldapHandle.simple_bind_s(who=dn, cred=password)
ldapHandle.unbind_s()
except Exception, e:
if ldapHandle is not None:
try:
ldapHandle.unbind_s()
except:
pass
raise auth.AuthException(e,ERR_LDAP)
return True

cls = LdapAuthRootBindEngine
[root@gh auth]#

Takashi Matsuo

unread,
Oct 30, 2012, 5:46:31 AM10/30/12
to gheimd...@googlegroups.com
2012/10/30 Tulip Marlowe <r1g1...@gmail.com>:

> 他所のシステムから借りてきたldapauth_rootbind.pyを、
> /usr/lib/python2.6/site-packages/gheimdall2/auth/
> に置いて、かつ python -m py_compileしてみましたが、エラーが消えません。

同じエラーですか?だとすればファイルのパーミッションはどうなっていますか?

--
Takashi Matsuo
matsuo....@gmail.com
Kay's daddy

> ldapauth_rootbindはサイト毎にカスタマイズする必要があるのでしょうか?

Tulip Marlowe

unread,
Oct 30, 2012, 6:02:28 AM10/30/12
to gheimd...@googlegroups.com
読み込みには特に支障ないようです。

[root@gh auth]# ls -la
合計 64
drwxr-xr-x 2 root root 4096 10月 30 18:58 2012 .
drwxr-xr-x 13 root root 4096 10月 24 13:40 2012 ..
-rw-r--r-- 1 root root 2509 3月 30 16:24 2010 __init__.py
-rw-r--r-- 2 root root 3472 3月 1 20:16 2011 __init__.pyc
-rw-r--r-- 2 root root 3472 3月 1 20:16 2011 __init__.pyo
-rw-r--r-- 1 root root 1968 3月 30 16:24 2010 ldapauth.py
-rw-r--r-- 2 root root 1662 3月 1 20:16 2011 ldapauth.pyc
-rw-r--r-- 2 root root 1662 3月 1 20:16 2011 ldapauth.pyo
-rw-r--r-- 1 root root 2237 3月 24 16:45 2011 ldapauth_rootbind.py
-rw-r--r-- 1 root root 1664 10月 30 18:15 2012 ldapauth_rootbind.pyc
-rw-r--r-- 1 root root 2120 3月 30 16:24 2010 pam.py
-rw-r--r-- 2 root root 2121 3月 1 20:16 2011 pam.pyc
-rw-r--r-- 2 root root 2121 3月 1 20:16 2011 pam.pyo
-rw-r--r-- 1 root root 1174 3月 30 16:24 2010 sample.py
-rw-r--r-- 2 root root 994 3月 1 20:16 2011 sample.pyc
-rw-r--r-- 2 root root 994 3月 1 20:16 2011 sample.pyo

Tulip Marlowe

unread,
Oct 30, 2012, 9:24:21 AM10/30/12
to gheimd...@googlegroups.com
ldapauth_rootbind.pyを追加したら、/var/log/gheimdall2/error.logが「ldapモジュ
ールが無い」といい始めました。
yum install mod_authz_ldap.i686 と導入してみましたが、これではなさそうですね。

2012-10-30 22:15:30,793:
/usr/lib/python2.6/site-packages/gheimdall2/middleware/handle_exception.py:
85: root: CRITICAL: Traceback (most recent cal l last):

File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py",
line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python2.6/site-packages/gheimdall2/idp/views.py",
line 173, in login_do
auth_engine = auth.createAuthEngine(config.get('auth_engine'), config)

File "/usr/lib/python2.6/site-packages/gheimdall2/auth/__init__.py",
line 77, in createAuthEngine
exec('from gheimdall2.auth import %s' % engine)

File "<string>", line 1, in <module>

File "/usr/lib/python2.6/site-packages/gheimdall2/auth/ldapauth_rootbind.py",
line 23, in <module>
import ldap

ImportError: No module named ldap



python-ldap.i686も入れてみたら、
2012-10-30 22:23:05,039:
/usr/lib/python2.6/site-packages/gheimdall2/idp/views.py: 181: root:
ERROR: Failed login attempt from 113.157.243.222. User: gakusei4.
Reason: {'desc': "Can't contact LDAP server"}

現在、客先のAXIOLEが電源切れているようで、明日続きをやって見ます。

Tulip Marlowe

unread,
Oct 30, 2012, 10:11:12 AM10/30/12
to gheimd...@googlegroups.com
何とかAXIOLEにつながったのですが、

/var/log/gheimdall2/error.logに

2012-10-30 23:05:49,128:
/usr/lib/python2.6/site-packages/gheimdall2/auth/__init__.py: 45:
root: INFO: Logged in as gakusei4 from 113.157.243.222
2012-10-30 23:05:49,139:
/usr/lib/python2.6/site-packages/gheimdall2/middleware/handle_exception.py:
85: root: CRITICAL: Traceback (most recent call last):

File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py",
line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python2.6/site-packages/gheimdall2/idp/views.py",
line 193, in login_do
user_name)

File "/usr/lib/python2.6/site-packages/gheimdall2/utils.py", line
249, in create_saml_response
signed_response = sign_message(saml_response)

File "/usr/lib/python2.6/site-packages/gheimdall2/utils.py", line
183, in sign_message
config.get('privkey_filename'))

File "/usr/lib/python2.6/site-packages/saml2/utils.py", line 142, in sign
ret = sign_xml(xml, key_file, cert_file)

File "/usr/lib/python2.6/site-packages/saml2/utils.py", line 172, in sign_xml
None, None, None)

File "/usr/lib/python2.6/site-packages/xmlsec.py", line 458, in
cryptoAppKeyLoad
if ret is None: raise Error('xmlSecCryptoAppKeyLoad() failed')

Error: 'xmlSecCryptoAppKeyLoad() failed'


と記録され、矢張りログイン画面の先でエラーになり、進めません。

Takashi Matsuo

unread,
Oct 30, 2012, 11:05:13 AM10/30/12
to gheimd...@googlegroups.com

private key のパーミッションはどうなってます?

Tulip Marlowe

unread,
Oct 30, 2012, 7:15:12 PM10/30/12
to gheimd...@googlegroups.com
[root@gh private]# ls -la
合計 16
drwx------. 2 apache apache 4096 10月 26 22:52 2012 .
drwxr-xr-x. 4 root root 4096 10月 26 22:50 2012 ..
-rw-------. 1 apache apache 1675 10月 26 22:52 2012 privkey-nopass.pem
-rw-------. 1 apache apache 1743 10月 26 22:51 2012 privkey.pem

と、少なくとも Apache は読める設定です。

Takashi Matsuo

unread,
Oct 30, 2012, 7:48:43 PM10/30/12
to gheimd...@googlegroups.com
SELinux?

--
Takashi Matsuo
matsuo....@gmail.com
Kay's daddy


2012年10月31日 8:15 Tulip Marlowe <r1g1...@gmail.com>:

Tulip Marlowe

unread,
Oct 30, 2012, 8:38:40 PM10/30/12
to gheimd...@googlegroups.com
[root@gh private] getenforce
Disabled

です。

Takashi Matsuo

unread,
Oct 30, 2012, 8:57:35 PM10/30/12
to gheimd...@googlegroups.com
うーん。難しいですね。
少しづつコード改変しながらデバッグできる人を雇ってみてはいかがでしょうか。

--
Takashi Matsuo
matsuo....@gmail.com
Kay's daddy


2012年10月31日 9:38 Tulip Marlowe <r1g1...@gmail.com>:


> [root@gh private] getenforce
> Disabled
>
> です。
>

Tulip Marlowe

unread,
Oct 30, 2012, 10:05:19 PM10/30/12
to gheimd...@googlegroups.com
色々と有難うございます。

GHeimdall2 のインストールの基本は、

1. http://code.google.com/p/gheimdall2/wiki/GHeimdall2OnDebianLenny
で公開された手順通りにパッケージを導入し(key pare作成、公開鍵登録を含む)、

2. /usr/lib/python2.6/site-packages/gheimdall2/settings.py
のSECRET_KEY を任意の文字列に書き換え、
その他、TIME_ZONE=Asia/Tokyo, LANGUAGE_CODE='ja' も書き換え?

3. /etc/gheimdall2/gheimdall2
のprivkey_filenameのパス、Google関連、ldap関連等サイト固有情報書き換え

4. その他追加ファイル登録
(1) /usr/lib/python2.6/site-packages/gheimdall2/auth/ldapauth_rootbind.py
(2) /usr/lib/python2.6/site-packages/uamobile-0.1.2-py2.6.egg/uamobile/cidr.py
(3) /usr/lib/python2.6/site-packages/uamobile-0.1.2-py2.6.egg/uamobile/cidrdata

5. 動作させて python-ldap など、/var/log/gheimdall2/error.log に記録される不足
パッケージを追加で組込む

と言う手順で間違いないでしょうか?


 また、何度かプラットフォームも変えながら再インストールしてみていますが、

① CentOS5.8 32bit
② CentOS6.3 32bit
③ Debian squeeze 32bit(lennyは更新が不安なので不採用)

の中で、どれが最もGHeimdall2と親和性が良いでしょうか?
そのOSで再度最初からインストールしてみたいと思います。

Tulip Marlowe

unread,
Nov 1, 2012, 7:14:15 AM11/1/12
to gheimd...@googlegroups.com
CentOS6.3 32bit、6.3 64bit、5.8 32bit、Squeeze 32bit、64bit
どれも /var/log/gheimdall2/error.log に寸分違わず次のログを残して止まってます。
再現性があるわけですが、何か手はないものでしようか



2012-11-01 20:06:09,972:
/usr/local/lib/python2.6/dist-packages/gheimdall2/auth/__init__.py:
45: root: INFO: Logged in as gakusei4 from 210.169.214.252
2012-11-01 20:06:10,094:
/usr/local/lib/python2.6/dist-packages/gheimdall2/middleware/handle_exception.py:
85: root: CRITICAL: Traceback (most recent call last):

File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/idp/views.py",
line 193, in login_do
user_name)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/utils.py",
line 249, in create_saml_response
signed_response = sign_message(saml_response)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/utils.py",
line 183, in sign_message
config.get('privkey_filename'))

File "/usr/local/lib/python2.6/dist-packages/saml2/utils.py", line
142, in sign
ret = sign_xml(xml, key_file, cert_file)

File "/usr/local/lib/python2.6/dist-packages/saml2/utils.py", line
172, in sign_xml
None, None, None)

File "/usr/local/lib/python2.6/dist-packages/xmlsec.py", line 458,
in cryptoAppKeyLoad
if ret is None: raise Error('xmlSecCryptoAppKeyLoad() failed')

Error: 'xmlSecCryptoAppKeyLoad() failed'


2012/10/31 Tulip Marlowe <r1g1...@gmail.com>:

Tulip Marlowe

unread,
Nov 1, 2012, 7:21:43 AM11/1/12
to gheimd...@googlegroups.com
CentOS6.3 32bit、6.3 64bit、5.8 32bit、Squeeze 32bit、64bit
どれも /var/log/gheimdall2/error.log に寸分違わず次のログを残して止まってます。
再現性があるわけですが、何か手はないものでしようか



2012-11-01 20:06:09,972:
/usr/local/lib/python2.6/dist-packages/gheimdall2/auth/__init__.py:
45: root: INFO: Logged in as gakusei4 from ***.***.***.***
2012-11-01 20:06:10,094:
/usr/local/lib/python2.6/dist-packages/gheimdall2/middleware/handle_exception.py:
85: root: CRITICAL: Traceback (most recent call last):

File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/idp/views.py",
line 193, in login_do
user_name)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/utils.py",
line 249, in create_saml_response
signed_response = sign_message(saml_response)

File "/usr/local/lib/python2.6/dist-packages/gheimdall2/utils.py",
line 183, in sign_message
config.get('privkey_filename'))

File "/usr/local/lib/python2.6/dist-packages/saml2/utils.py", line
142, in sign
ret = sign_xml(xml, key_file, cert_file)

File "/usr/local/lib/python2.6/dist-packages/saml2/utils.py", line
172, in sign_xml
None, None, None)

File "/usr/local/lib/python2.6/dist-packages/xmlsec.py", line 458,
in cryptoAppKeyLoad
if ret is None: raise Error('xmlSecCryptoAppKeyLoad() failed')

Error: 'xmlSecCryptoAppKeyLoad() failed'


2012/10/31 Tulip Marlowe <r1g1...@gmail.com>:
Message has been deleted

F500

unread,
Nov 5, 2012, 8:55:52 PM11/5/12
to GHeimdall-ja
key pairを再作成したところ、うまくログイン出来るようになりました。

松尾様、いろいろとありがとうございました。今後のご活躍をお祈りいたします。
Reply all
Reply to author
Forward
0 new messages