|
const | STAGE_INIT = 'authwindowslive:init' |
| The string used to identify our states. More...
|
|
const | AUTHID = 'authwindowslive:AuthId' |
| The key of the AuthId field in the state. More...
|
|
Definition at line 10 of file LiveID.php.
◆ __construct()
sspmod_authwindowslive_Auth_Source_LiveID::__construct |
( |
|
$info, |
|
|
|
$config |
|
) |
| |
Constructor for this authentication source.
- Parameters
-
array | $info | Information about this authentication source. |
array | $config | Configuration. |
- Exceptions
-
Exception | In case of misconfiguration. |
Definition at line 35 of file LiveID.php.
36 {
37 assert('is_array($info)');
38 assert('is_array($config)');
39
40
42
43 if (!array_key_exists(
'key',
$config)) {
44 throw new Exception('LiveID authentication source is not properly configured: missing [key]');
45 }
46
48
49 if (!array_key_exists(
'secret',
$config)) {
50 throw new Exception('LiveID authentication source is not properly configured: missing [secret]');
51 }
52
53 $this->secret =
$config[
'secret'];
54 }
References $config, and $info.
◆ authenticate()
sspmod_authwindowslive_Auth_Source_LiveID::authenticate |
( |
& |
$state | ) |
|
Log-in using LiveID platform.
- Parameters
-
array | &$state | Information about the current authentication. |
Reimplemented from SimpleSAML_Auth_Source.
Definition at line 62 of file LiveID.php.
63 {
64 assert('is_array($state)');
65
66
68
70
72
73
74
75
76 $authorizeURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
77 . '?client_id=' . $this->key
78 . '&response_type=code'
79 . '&response_mode=query'
80 .
'&redirect_uri=' . urlencode(
SimpleSAML\Module::getModuleUrl(
'authwindowslive') .
'/linkback.php')
81 . '&state=' . urlencode($stateID)
82 . '&scope=' . urlencode('openid https://graph.microsoft.com/user.read')
83 ;
84
86 }
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static saveState(&$state, $stage, $rawId=false)
Save the state.
const AUTHID
The key of the AuthId field in the state.
Attribute-related utility methods.
References SimpleSAML_Auth_Source\$authId, $state, AUTHID, SimpleSAML\Logger\debug(), SimpleSAML\Utils\HTTP\redirectTrustedURL(), and SimpleSAML_Auth_State\saveState().
◆ finalStep()
sspmod_authwindowslive_Auth_Source_LiveID::finalStep |
( |
& |
$state | ) |
|
- Parameters
-
- Exceptions
-
Definition at line 94 of file LiveID.php.
95 {
97 "authwindowslive oauth: Using this verification code [".
$state[
'authwindowslive:verification_code'].
"]"
98 );
99
100
101
102
103 $postData =
'client_id=' . urlencode($this->key)
104 . '&client_secret=' . urlencode($this->secret)
105 . '&scope=' . urlencode('https://graph.microsoft.com/user.read')
106 . '&grant_type=authorization_code'
107 .
'&redirect_uri=' . urlencode(
SimpleSAML\Module::getModuleUrl(
'authwindowslive') .
'/linkback.php')
108 .
'&code=' . urlencode(
$state[
'authwindowslive:verification_code']);
109
110 $context = array(
111 'http' => array(
112 'method' => 'POST',
113 'header' => 'Content-type: application/x-www-form-urlencoded',
115 ),
116 );
117
119
121
122
123 if (!array_key_exists(
'access_token',
$response)) {
124 throw new Exception(
126 "\r\nNo access_token returned - cannot proceed\r\n" . implode(
', ',
$response[
'error_codes'])
127 );
128 }
129
131 "authwindowslive: Got an access token from the OAuth service provider [".
$response[
'access_token'].
"]"
132 );
133
134
135 $opts = array('http' => array('header' => "Accept: application/json\r\nAuthorization: Bearer ".
139
140
141 if (!array_key_exists(
'@odata.context',
$userdata) || array_key_exists(
'error',
$userdata)) {
142 throw new Exception(
143 'Unable to retrieve userdata from Microsoft Graph ['.
$userdata[
'error'][
'code'].
'] '.
145 );
146 }
149 'https://graph.microsoft.com!'.(!empty(
$userdata[
'id']) ?
$userdata[
'id'] :
'unknown')
150 );
152 if (is_string($value)) {
154 }
155 }
156
157
159
161 }
static fetch($url, $context=array(), $getHeaders=false)
Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorizati...
if($session===NULL) $postData
References $attributes, $data, $key, $postData, $response, $result, $state, $userdata, SimpleSAML\Logger\debug(), and SimpleSAML\Utils\HTTP\fetch().
◆ $key
sspmod_authwindowslive_Auth_Source_LiveID::$key |
|
private |
◆ $secret
sspmod_authwindowslive_Auth_Source_LiveID::$secret |
|
private |
◆ AUTHID
const sspmod_authwindowslive_Auth_Source_LiveID::AUTHID = 'authwindowslive:AuthId' |
◆ STAGE_INIT
const sspmod_authwindowslive_Auth_Source_LiveID::STAGE_INIT = 'authwindowslive:init' |
The string used to identify our states.
Definition at line 16 of file LiveID.php.
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/modules/authwindowslive/lib/Auth/Source/LiveID.php