Skip to content

Commit 0d1fb8b

Browse files
committed
..
1 parent e7b2536 commit 0d1fb8b

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

lib/Auth/Process/AttributeFromRestApi.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* '60' => array(
1313
* 'class' => 'attributefromrestapi:AttributeFromRestApi',
1414
* 'nameId_attribute_name' => 'subject_nameid', // look at the aa authsource config
15-
* 'api_url' => 'https://www.example.com/app.php/api',
15+
* 'api_url' => 'https://www.example.com/resource',
1616
* ),
1717
*
1818
* @author Gyula Szabó <gyufi@niif.hu>
@@ -39,7 +39,13 @@ public function process(&$state)
3939
assert('is_array($state)');
4040
$nameId = $state['Attributes'][$this->as_config['nameId_attribute_name']][0];
4141
$this->config = SimpleSAML_Configuration::getInstance();
42-
array_push($state['Attributes'], $this->getAttributes($nameId));
42+
$new_attributes = $this->getAttributes($nameId);
43+
$state['Attributes'][key($new_attributes)][0] = $new_attributes[key($new_attributes)];
44+
45+
// array_push($state['Attributes'], $this->getAttributes($nameId));
46+
47+
// var_dump($this->getAttributes($nameId)); exit;
48+
// var_dump($state['Attributes']); exit;
4349
}
4450

4551
public function getAttributes($nameId, $attributes = array())
@@ -54,13 +60,14 @@ public function getAttributes($nameId, $attributes = array())
5460
// Setup cURL
5561
$url = $this->as_config['api_url'].'/'.$nameId;
5662
$ch = curl_init($url);
57-
curl_setopt_array($ch,
63+
curl_setopt_array(
64+
$ch,
5865
array(
5966
CURLOPT_CUSTOMREQUEST => 'GET',
6067
CURLOPT_RETURNTRANSFER => true,
6168
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
62-
)
63-
);
69+
)
70+
);
6471

6572
// Send the request
6673
$response = curl_exec($ch);
@@ -71,8 +78,7 @@ public function getAttributes($nameId, $attributes = array())
7178
SimpleSAML_Logger::error('[afra] API query failed: HTTP response code: '.$http_response.', curl error: "'.curl_error($ch)).'"';
7279
SimpleSAML_Logger::debug('[afra] API query failed: curl info: '.var_export(curl_getinfo($ch), 1));
7380
SimpleSAML_Logger::debug('[afra] API query failed: HTTP response: '.var_export($response, 1));
74-
$data = array();
75-
var_dump($http_response, $response);exit;
81+
throw new \Exception("Hiba, ". $response, 1);
7682
} elseif (false) {
7783
# egyéb hibaüzenetek
7884
} else {

0 commit comments

Comments
 (0)