External authentification and config

51 views
Skip to first unread message

Knut

unread,
Nov 17, 2011, 4:42:06 AM11/17/11
to simpleSAMLphp
Hello to all,

very new with SimpleSAMLphp I'm currently trying to implement local
login with a copy of the external module.
This works fine as long I hardcode some values like 'hostname' (for
instance). The better way - I think - is to use entries in
authsources.php like:
[code]
'myauth' => array(
'myauth:External',
'hostname' => 'myhost.mynet.de',
[/code]
Now I have to retrieve those informations in External.php and tried
that with:
[code]
private $config;
/**
* Constructor for this authentication source.
*
* @param array $info Information about this authentication source.
* @param array $config Configuration.
*/
public function __construct($info, $config) {
assert('is_array($info)');
assert('is_array($config)');

/* Call the parent constructor first, as required by the interface.
*/
parent::__construct($info, $config);

/* Do any other configuration we need here. */
/* knulo 2011-11-17 */
$this->config = SimpleSAML_Configuration::loadFromArray($config,
'Authentication source ' . var_export($this->authId, TRUE));
[/code]
Unfortunately $this->config is empty.

What do I wrong?

Thanks in advance!

--
Regards Knut

Olav Morken

unread,
Nov 17, 2011, 6:27:11 AM11/17/11
to simple...@googlegroups.com

Difficult to tell. I don't see anything obvious incorrect in the part
that you included in your message.

I suggest adding some debug logging in various places in your code, and
using that to verify the contents of both $config when passed to the
constructor, and $this->config after you have called loadFromArray().

Regards,
Olav Morken
UNINETT / Feide

Knut Lohse

unread,
Nov 17, 2011, 6:50:18 AM11/17/11
to simple...@googlegroups.com
> > [code]

> > /* Do any other configuration we need here. */
> > /* knulo 2011-11-17 */
> > $this->config = SimpleSAML_Configuration::loadFromArray($config,
> > 'Authentication source ' . var_export($this->authId, TRUE));
> > [/code]
> > Unfortunately $this->config is empty.
> I suggest adding some debug logging in various places in your code, and
> using that to verify the contents of both $config when passed to the
> constructor, and $this->config after you have called loadFromArray().

Thank you, Olav,
I tried to use $config instead of the return value of 'loadFromArray' and this
works well. Now my code looks like that:
[code]


/* Do any other configuration we need here. */
/* knulo 2011-11-17 */

SimpleSAML_Configuration::loadFromArray($config,
'Authentication source ' . var_export($this->authId, TRUE));

$this->config = $config; // save for further use
[/code]

Maybe this helps others...

--
Regards, Knut

Olav Morken

unread,
Nov 17, 2011, 7:18:45 AM11/17/11
to simple...@googlegroups.com

Did you by any chance try to access $this->config['<something>'] after
using loadFromArray()? If you did that, it would explain your problem,
since SimpleSAML_Configuration::loadFromArray creates a
SimpleSAML_Configuration object. To retrieve data from that object you
must use various functions. E.g.:

$something = $this->config->getString('something');

This will also give you an error when "something" isn't available in
the array, or if it isn't a string. You can also give a default value:

$something = $this->config->getString('something', 'default-string');

Knut

unread,
Nov 17, 2011, 8:09:33 AM11/17/11
to simpleSAMLphp
> Did you by any chance try to access $this->config['<something>'] after
> using loadFromArray()? If you did that, it would explain your problem,
> since SimpleSAML_Configuration::loadFromArray creates a
> SimpleSAML_Configuration object. To retrieve data from that object you
> must use various functions. E.g.:
>
>     $something = $this->config->getString('something');

I really tried something like the statement above, but that throws an
error (now I know: something else was wrong), so I used (since now)

SimpleSAML_Configuration::loadFromArray($config, <key>);
$this->config = $config;
...
$something = $this->config['something'];

with success.
Now I changed my code for better readability and ruggedness:

$this->config = SimpleSAML_Configuration::loadFromArray($config,
<key>);
...
$something = $this->config->getString('something');

I think, now we can see the problem as REALLY SOLVED. :)
Thanks once more for your support.

--
Regards, Knut
Reply all
Reply to author
Forward
0 new messages