Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
502d71fa
Unverified
Commit
502d71fa
authored
7 years ago
by
Tim van Dijen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PSR-2
+ code quality
parent
e9320204
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/authYubiKey/libextinc/Yubico.php
+11
-10
11 additions, 10 deletions
modules/authYubiKey/libextinc/Yubico.php
with
11 additions
and
10 deletions
modules/authYubiKey/libextinc/Yubico.php
+
11
−
10
View file @
502d71fa
...
...
@@ -66,19 +66,19 @@ class Auth_Yubico
* Yubico client ID
* @var string
*/
var
$_id
;
private
var
$_id
;
/**
* Yubico client key
* @var string
*/
var
$_key
;
private
var
$_key
;
/**
* Response from server
* @var string
*/
var
$_response
;
private
var
$_response
;
/**
* Constructor
...
...
@@ -100,7 +100,7 @@ class Auth_Yubico
* @return string Output from server.
* @access public
*/
function
getLastResponse
()
public
function
getLastResponse
()
{
return
$this
->
_response
;
}
...
...
@@ -114,11 +114,11 @@ class Auth_Yubico
* @return mixed PEAR error on error, true otherwise
* @access public
*/
function
verify
(
$token
)
public
function
verify
(
$token
)
{
$parameters
=
"id="
.
$this
->
_id
.
"&otp="
.
$token
;
// Generate signature
if
(
$this
->
_key
<>
""
)
{
if
(
$this
->
_key
<>
""
)
{
$signature
=
base64_encode
(
hash_hmac
(
'sha1'
,
$parameters
,
$this
->
_key
,
true
));
$parameters
.
=
'&h='
.
$signature
;
}
...
...
@@ -127,16 +127,17 @@ class Auth_Yubico
$responseMsg
=
\SimpleSAML\Utils\HTTP
::
fetch
(
$url
);
if
(
!
preg_match
(
"/status=([a-zA-Z0-9_]+)/"
,
$responseMsg
,
$out
))
{
if
(
!
preg_match
(
"/status=([a-zA-Z0-9_]+)/"
,
$responseMsg
,
$out
))
{
throw
new
Exception
(
'Could not parse response'
);
}
$status
=
$out
[
1
];
/* Verify signature. */
if
(
$this
->
_key
<>
""
)
{
if
(
$this
->
_key
<>
""
)
{
$rows
=
explode
(
"
\r\n
"
,
$responseMsg
);
while
(
list
(
$key
,
$val
)
=
each
(
$rows
))
{
response
=
array
();
while
(
list
(,
$val
)
=
each
(
$rows
))
{
// = is also used in BASE64 encoding so we only replace the first = by # which is not used in BASE64
$val
=
preg_replace
(
'/=/'
,
'#'
,
$val
,
1
);
$row
=
explode
(
"#"
,
$val
);
...
...
@@ -146,7 +147,7 @@ class Auth_Yubico
$check
=
'status='
.
$response
[
'status'
]
.
'&t='
.
$response
[
't'
];
$checksignature
=
base64_encode
(
hash_hmac
(
'sha1'
,
$check
,
$this
->
_key
,
true
));
if
(
$response
[
'h'
]
!=
$checksignature
)
{
if
(
$response
[
'h'
]
!=
$checksignature
)
{
throw
new
Exception
(
'Checked Signature failed'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment