Regarding "How to contribute a sub module for oauth?" I answer in a new thread, because google keeps deleting every singler answer I post.
Here is the answer:
Thanks Steve. We do have a functionable module.
Maybe someone can use this:
MODULE oauth_azure.php
<?php
class modules_oauth_azure {
public function __construct() {
$app = Dataface_Application::getInstance();
$app->registerEventListener('oauth_fetch_user_data', array($this, 'oauth_fetch_user_data'), false);
$app->registerEventListener('oauth_extract_user_properties_from_user_data', array($this, 'oauth_extract_user_properties_from_user_data'), false);
}
public function oauth_fetch_user_data($evt) {
if ($evt->service !== 'azure') {
return;
}
$mod = Dataface_ModuleTool::getInstance()->loadModule('modules_oauth');
$enc_data = $mod->getOauthToken('azure');
list($header, $payload, $signature) = explode(".", $enc_data);
$plainHeader = base64_decode($header);
$plainPayload = base64_decode($payload);
$data = json_decode($plainPayload, true);
$upn = $data['upn'];
$oid = $data['oid'];
$name = $data['name'];
$email = strtolower($data['upn']);
$evt->out = array("upn" => $upn, "id" => $email, "name" => $name, "email" => $email);
return;
}
public function oauth_extract_user_properties_from_user_data($evt) {
if ($evt->service !== 'azure') {
return;
}
$evt->out = array(
'id' => $evt->userData['id'],
'name' => $evt->userData['name'],
'upn' => $evt->userData['upn'],
'email' => $evt->userData['email']
);
}
}
This is conf.ini:
[_modules]
modules_oauth="modules/Auth/oauth/oauth.php"
modules_oauth_azure="modules/Auth/oauth/oauth_azure.php"
[oauth_azure]
client_id="clientid"
client_secret="secret"
scope = openid email profile
autocreate=1
This is actions.ini:
[oauth_azure]
oauth.url="
https://login.microsoftonline.com/enter_your_id/oauth2/v2.0/authorize"
oauth.request_token_url="
https://login.microsoftonline.com/enter_your_id/oauth2/v2.0/token"
oauth.url_logout = "
https://login.microsoftonline.com/enter_your_id/oauth2/v2.0/logout"
label="OAUTH-Login"
category="login_actions"
Best regards
Richard