Product:
Search Type:

Is there are any API for password checking (how to check passwords stored in sm_authpass)?

Article ID: 690 
Last Review: Jul,19 2007
APPLIES TO:
  • HSPcomplete 3.2.x

RESOLUTION

This is a piece of code for checking passwords using HSPC API:

#!/usr/bin/perl
## initialize environment in console script
use HSPC::Console;

## get authentication module
my $auth_module = $ENV{security_obj}->{_auth_obj};

## check password
my $err = $auth_module->check_pwd(email=>'john@smith.com',pwd=>'123');

## reset password if check failed
if($err) {
print "Got error - $err, reseting password\n";
$auth_module->change_pwd(email=>'john@smith.com',pwd=>'123');
}

Please, note that check_pwd method returns undef if email/password pair is valid.

If you need to create a new person, please, check HSPC integration guide.


The code snipped that does a 'real work':

sub _digest{
my $hmac = Digest::HMAC_SHA1->new($CONFIG);
$hmac->add($_[0]);
my $res = $hmac->b64digest;
$res =~ s/\+/_/g;
print "Hashing $_[0] -> $res" if $_[1];
return $res;
}

$CONFIG
is taken from
/etc/hspc/hspc.conf

perhaps it is more suitable for you - you can write something similar in different language or for example can encrypt passwords somewhere else and authenticate against a remote mysql database (HSPC) - but it is not recommended, there's no guarantee that encryption format won't be changed (I myself hope it will and 'regular' crypt() will be used with md5 or blowfish hash).


Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
*Please type the code you can see.
* - required fields