Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 198cc85

Browse files
author
the-djmaze
committed
O365 option to use Azure or Personal accounts #1645
1 parent 3931c11 commit 198cc85

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

plugins/login-o365/LoginOAuth2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
(rl => {
22
const client_id = rl.pluginSettingsGet('login-o365', 'client_id'),
3+
// https://learn.microsoft.com/en-us/entra/identity-platform/reply-url#query-parameter-support-in-redirect-uris
4+
query = rl.pluginSettingsGet('login-o365', 'personal') ? '' : '?',
35
tenant = rl.pluginSettingsGet('login-o365', 'tenant'),
46
login = () => {
57
document.location = 'https://login.microsoftonline.com/'+tenant+'/oauth2/v2.0/authorize?' + (new URLSearchParams({
68
response_type: 'code',
79
client_id: client_id,
8-
redirect_uri: document.location.href.replace(/\/$/, '') + '/LoginO365',
10+
redirect_uri: document.location.href.replace(/\/$/, '') + '/' + query + 'LoginO365',
911
scope: [
1012
// Associate personal info
1113
'openid',

plugins/login-o365/index.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
*
88
* https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps
99
*
10-
* redirect_uri=https://{DOMAIN}/?LoginO365
11-
* redirect_uri=https://{DOMAIN}/LoginO365
10+
* https://learn.microsoft.com/en-us/entra/identity-platform/reply-url#query-parameter-support-in-redirect-uris
11+
* Azure: redirect_uri=https://{DOMAIN}/?LoginO365
12+
* Personal: redirect_uri=https://{DOMAIN}/LoginO365
1213
*/
1314

1415
use RainLoop\Model\MainAccount;
@@ -18,8 +19,8 @@ class LoginO365Plugin extends \RainLoop\Plugins\AbstractPlugin
1819
{
1920
const
2021
NAME = 'Office365/Outlook OAuth2',
21-
VERSION = '0.2',
22-
RELEASE = '2024-08-13',
22+
VERSION = '0.3',
23+
RELEASE = '2024-09-29',
2324
REQUIRED = '2.36.1',
2425
CATEGORY = 'Login',
2526
DESCRIPTION = 'Office365/Outlook IMAP, Sieve & SMTP login using RFC 7628 OAuth2';
@@ -47,6 +48,7 @@ public function Init() : void
4748

4849
public function httpPaths(array &$aPaths) : void
4950
{
51+
// Personal accounts workaround
5052
if (!empty($_SERVER['PATH_INFO']) && \str_ends_with($_SERVER['PATH_INFO'], 'LoginO365')) {
5153
$aPaths = ['LoginO365'];
5254
}
@@ -113,7 +115,7 @@ public function ServiceLoginO365() : string
113115
$iExpires += $aResponse['expires_in'];
114116

115117
$oO365->setAccessToken($sAccessToken);
116-
$aUserInfo = $oO365->fetch('https://graph.microsoft.com/oidc/userinfo"');
118+
$aUserInfo = $oO365->fetch('https://graph.microsoft.com/oidc/userinfo');
117119
if (200 != $aUserInfo['code']) {
118120
throw new \RuntimeException("HTTP: {$aResponse['code']}");
119121
}
@@ -154,6 +156,12 @@ public function ServiceLoginO365() : string
154156
public function configMapping() : array
155157
{
156158
return [
159+
\RainLoop\Plugins\Property::NewInstance('personal')
160+
->SetLabel('Use with personal accounts')
161+
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
162+
->SetDefaultValue(true)
163+
->SetAllowedInJs()
164+
->SetDescription('Sign in users with personal Microsoft accounts such as Outlook.com (Hotmail)'),
157165
\RainLoop\Plugins\Property::NewInstance('client_id')
158166
->SetLabel('Client ID')
159167
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING)

0 commit comments

Comments
 (0)