-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from arodu/feature/microsoft-login
Feature/microsoft login
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
|
||
namespace CakeDC\Auth\Social\Mapper; | ||
|
||
class Azure extends AbstractMapper | ||
{ | ||
/** | ||
* Map for provider fields | ||
* | ||
* @var array | ||
*/ | ||
protected $_mapFields = [ | ||
'id' => 'sub', | ||
'full_name' => 'name', | ||
'username' => 'unique_name', | ||
'email' => 'upn', | ||
]; | ||
|
||
/** | ||
* Get link property value | ||
* | ||
* @param mixed $rawData raw data | ||
* @return string | ||
*/ | ||
protected function _link($rawData) | ||
{ | ||
return '#'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
|
||
namespace CakeDC\Auth\Test\TestCase\Social\Mapper; | ||
|
||
use Cake\TestSuite\TestCase; | ||
use CakeDC\Auth\Social\Mapper\Azure; | ||
|
||
class AzureTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
public function testMap() | ||
{ | ||
$token = new \League\OAuth2\Client\Token\AccessToken([ | ||
'access_token' => 'test-token', | ||
'expires' => 1490988496, | ||
]); | ||
$rawData = [ | ||
'token' => $token, | ||
'aud' => 'ef044865-c304-4707-bce2-2c8cb469f093', | ||
'iss' => 'https://sts.windows.net/b5a44686-40bd-47e2-8e01-e52f214f2c8f/', | ||
'iat' => 1660940688, | ||
'nbf' => 1660940688, | ||
'exp' => 1660944588, | ||
'amr' => [ ], | ||
'ipaddr' => '127.0.0.1', | ||
'name' => 'Test', | ||
'oid' => '8a27cdf6-50c6-455b-af9d-ec60381ee8b9', | ||
'rh' => '0.AQUAhkaktb1A4keOAeUvIU8sj2VIBO8EwwdHvOIsjLRp8JMFAJM.', | ||
'sub' => 'wsAdh5DgzKg_-dz9xap8P0Sqnar2-CKifp0noideBv4', | ||
'tid' => 'b5a44686-40bd-47e2-8e01-e52f214f2c8f', | ||
'unique_name' => '[email protected]', | ||
'upn' => '[email protected]', | ||
'ver' => '1.0', | ||
]; | ||
$providerMapper = new Azure(); | ||
$user = $providerMapper($rawData); | ||
$this->assertEquals([ | ||
'id' => 'wsAdh5DgzKg_-dz9xap8P0Sqnar2-CKifp0noideBv4', | ||
'username' => '[email protected]', | ||
'full_name' => 'Test', | ||
'first_name' => null, | ||
'last_name' => null, | ||
'email' => '[email protected]', | ||
'avatar' => null, | ||
'gender' => null, | ||
'link' => '#', | ||
'bio' => null, | ||
'locale' => null, | ||
'validated' => true, | ||
'credentials' => [ | ||
'token' => 'test-token', | ||
'secret' => null, | ||
'expires' => 1490988496, | ||
], | ||
'raw' => $rawData, | ||
], $user); | ||
} | ||
} |