Charset php simplesaml problem

瀏覽次數:593 次
跳到第一則未讀訊息

Nuno Gonçalves

未讀,
2009年9月16日 下午2:12:152009/9/16
收件者:simple...@googlegroups.com
Hi all,

I'am running a simpleSAMLphp version 1.3 as an IDP.
The problem is when authentication occurs and there are attributes with special chars like ç ã (portuguese chars :) )
this error appears in the browser:

Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE7 0xE3 0x6F 0x20 in Entity, line: 1 in /var/simplesamlphp/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php on line 78

When the attributes don't have special chars all goes OK.
It might be related with php software that might be tunned with some specific charset config.

Do you have any hint of what might it be,

I added at the saml20-idp-hosted.php file the following:
'attributeencodings' => array('objectGUID' => 'UTF-8'),
but nothing happens (I saw it as a hint for LDAP attributes)

NOTE: Mysql has a default collation latin1_swedish_ci and a charset cp1252 West European

thanks and best regards
Nuno
--

_______________________________________

Nuno Gonçalves

 

Utilizador RCTS

 

FCCN

Av. do Brasil, n.º 101 - Lisboa

Tel.: +351218440100 - Fax: +351218472167

 

http://www.fccn.pt

Olav Morken

未讀,
2009年9月17日 凌晨3:40:152009/9/17
收件者:simple...@googlegroups.com
On Wed, Sep 16, 2009 at 19:12:15 +0100, Nuno Gonçalves wrote:
> Hi all,
>
> I'am running a simpleSAMLphp version 1.3 as an IDP.
> The problem is when authentication occurs and there are attributes with
> special chars like ç ã (portuguese chars :) )
> this error appears in the browser:
>
> Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Input is
> not proper UTF-8, indicate encoding ! Bytes: 0xE7 0xE3 0x6F 0x20 in
> Entity, line: 1 in
> /var/simplesamlphp/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php on line 78
>
> When the attributes don't have special chars all goes OK.
> It might be related with php software that might be tunned with some
> specific charset config.
>
> Do you have any hint of what might it be,
>
> I added at the saml20-idp-hosted.php file the following:
> 'attributeencodings' => array('objectGUID' => 'UTF-8'),
> but nothing happens (I saw it as a hint for LDAP attributes)

That is a workaround for a specific problem, in that case the
objectGUID attribute containing binary data. It doesn't understand
character sets. I also don't think it exists inversion 1.3.

> NOTE: Mysql has a default collation latin1_swedish_ci and a charset
> cp1252 West European

Since you include this, I assume you are retrieving your attributes
from SQL?

Your problem is that simpleSAMLphp assumes that all attributes are
encoded in the UTF-8 charset. In your case that assumption does not
appear to be true. How do you access the mysql server?

--
Olav Morken

Nuno Gonçalves

未讀,
2009年9月17日 清晨5:44:182009/9/17
收件者:simple...@googlegroups.com
Hi Olav, thanks for your reply,

yep, I am accessing attributes from a mysql database with the default collation and charset
(
collation latin1_swedish_ci and a charset cp1252 West European)

The MySql is on a diferent server accessed by simpleSAMLphp on authsources.php
It has the following:

<?php

$config = array(

        'idp2-mysql' => array(
                'sqlauth:SQL',
                'dsn' => 'mysql:host=hostname;port=3306;dbname=database_name',
                'username' => 'database_user',
                'password' => 'database_user_password',
                'query' => 'SELECT uid,username, mail,givenname,surname,o FROM users WHERE username = :username AND password = :password',
        )


);

?>

Then the file saml20-idp-hosted.php has the following content related to attributes:

$metadata = array(

        // The SAML entity ID is the index of this config.
        'https://idp.simplesamlphp-teste.fccn.pt:444/simplesaml/saml2/idp/metadata.php' => array(

                // The hostname of the server (VHOST) that this SAML entity will use.
                'host'                          =>      'idp.hostname.pt',
               
                'auth'                          =>      'mysql',
                'attributes'             => array('username','mail','surname','givenname','o'),
                'AttributeNameFormat'   => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',
                'attributeencodings' => array('urn:oid:2.5.4.42' => 'utf-8'),
                'authproc' => array(
                                            50 => array(
                                        'class' => 'core:AttributeMap',
                                        'username' => 'urn:oid:2.5.4.3',
                                        'mail'=> 'urn:oid:0.9.2342.19200300.100.1.3',
                                        'surname' => 'urn:oid:2.5.4.4',
                                        'givenname'=> 'urn:oid:2.5.4.42',
                                        'o'=>'urn:oid:2.5.4.10'))

        )

The problem only appears if the attribute value has special characters :P

Browser error message:


Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE7 0xE3 0x6F 0x20 in Entity, line: 1 in /var/simplesamlphp/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php on line 78

Fatal error: Call to a member function setAttributeNS() on a non-object in /var/simplesamlphp/lib/xmlseclibs.php on line 945

Here I add the messages log file:
Sep 17 10:42:46 simplesamlphp-teste simpleSAMLphp[3385]: 5 STAT [bef485c59e] consent found

thanks again for your time and effort

Nuno



_______________________________________

Nuno Gonçalves

 

Utilizador RCTS

 

FCCN

Av. do Brasil, n.º 101 - Lisboa

Tel.: +351218440100 - Fax: +351218472167

 

http://www.fccn.pt



Olav Morken

未讀,
2009年9月17日 清晨7:00:502009/9/17
收件者:simple...@googlegroups.com
On Thu, Sep 17, 2009 at 10:44:18 +0100, Nuno Gonçalves wrote:
> Hi Olav, thanks for your reply,
>
> yep, I am accessing attributes from a mysql database with the default
> collation and charset
> (collation latin1_swedish_ci and a charset cp1252 West European)

This problem was caused by a bug/missing feature in the sqlauth module.
I have made a change to it in order to support other character sets in
the database than UTF-8.

The change is in r1759 [1], and the updated SQL.php-file can be
downloaded from [2].

[1] http://code.google.com/p/simplesamlphp/source/detail?r=1759
[2] http://simplesamlphp.googlecode.com/svn/trunk/modules/sqlauth/lib/Auth/Source/SQL.php

--
Olav Morken

回覆所有人
回覆作者
轉寄
0 則新訊息