Skip to content

Commit faafa8e

Browse files
committed
Oauth IMAP mail receivers for G Suite and Azure AD
1 parent 82aaa55 commit faafa8e

36 files changed

+6036
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
vendor/
3+
.gh_token
4+
*.min.*

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: php
2+
php:
3+
- 7.2
4+
- 7.4
5+
6+
before_script:
7+
- composer self-update
8+
- composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest
9+
10+
script:
11+
- vendor/bin/robo --no-interaction code:cs --strict
12+
13+
cache:
14+
directories:
15+
- $HOME/.composer/cache

LICENSE

+339
Large diffs are not rendered by default.

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Oauth IMAP client for GLPI
2+
3+
This plugins provides IMAP SASL XOAUTH2 authentication mechanism for mail receivers.
4+
5+
Currently implemented for:
6+
7+
* [Google (Gmail)](https://developers.google.com/gmail/imap/xoauth2-protocol)
8+
* [Microsoft Azure (Microsoft 365)](https://docs.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth)
9+
10+
![Configuration page](docs/screenshots/config.png)
11+
![mail receiver setup](docs/screenshots/config_oauth_mailcollector.png)
12+
13+
## Documentation
14+
15+
We maintain a detailed documentation here -> [Documentation](https://glpi-plugins.readthedocs.io/en/latest/oauthimap/index.html)
16+
17+
## Contact
18+
19+
For notices about major changes and general discussion of oauthimap, subscribe to the [/r/glpi](https://www.reddit.com/r/glpi/) subreddit.
20+
You can also chat with us via IRC in [#glpi on freenode](http://webchat.freenode.net/?channels=glpi) or [@glpi on Telegram](https://t.me/glpien).
21+
22+
## Professional Services
23+
24+
![GLPI Network](docs/glpi_network.png "GLPI network")
25+
26+
The GLPI Network services are available through our [Partner's Network](http://www.teclib-edition.com/en/partners/). We provide special training, bug fixes with editor subscription, contributions for new features, and more.
27+
28+
Obtain a personalized service experience, associated with benefits and opportunities.
29+
30+
## Contributing
31+
32+
* Open a ticket for each bug/feature so it can be discussed
33+
* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins/index.html)
34+
* Refer to [GitFlow](http://git-flow.readthedocs.io/) process for branching
35+
* Work on a new branch on your own fork
36+
* Open a PR that will be reviewed by a developer
37+
38+
## Copying
39+
40+
* **Code**: you can redistribute it and/or modify
41+
it under the terms of the GNU General Public License ([GPL-2.0](https://www.gnu.org/licenses/gpl-2.0.en.html)).

RoboFile.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
-------------------------------------------------------------------------
4+
oauthimap plugin for GLPI
5+
Copyright (C) 2018-2020 by the oauthimap Development Team.
6+
-------------------------------------------------------------------------
7+
8+
LICENSE
9+
10+
This file is part of oauthimap.
11+
12+
oauthimap is free software; you can redistribute it and/or modify
13+
it under the terms of the GNU General Public License as published by
14+
the Free Software Foundation; either version 2 of the License, or
15+
(at your option) any later version.
16+
17+
oauthimap is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with oauthimap. If not, see <http://www.gnu.org/licenses/>.
24+
--------------------------------------------------------------------------
25+
*/
26+
27+
require_once 'vendor/autoload.php';
28+
29+
class RoboFile extends Glpi\Tools\RoboFile
30+
{
31+
//Own plugin's robo stuff
32+
}

ajax/dropdownAuthorization.php

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
-------------------------------------------------------------------------
4+
oauthimap plugin for GLPI
5+
Copyright (C) 2018-2020 by the oauthimap Development Team.
6+
-------------------------------------------------------------------------
7+
8+
LICENSE
9+
10+
This file is part of oauthimap.
11+
12+
oauthimap is free software; you can redistribute it and/or modify
13+
it under the terms of the GNU General Public License as published by
14+
the Free Software Foundation; either version 2 of the License, or
15+
(at your option) any later version.
16+
17+
oauthimap is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with oauthimap. If not, see <http://www.gnu.org/licenses/>.
24+
--------------------------------------------------------------------------
25+
*/
26+
27+
include ("../../../inc/includes.php");
28+
header("Content-Type: text/html; charset=UTF-8");
29+
Html::header_nocache();
30+
31+
Session::checkLoginUser();
32+
33+
global $DB;
34+
35+
$iterator = $DB->request(
36+
[
37+
'FROM' => PluginOauthimapAuthorization::getTable(),
38+
'WHERE' => [
39+
PluginOauthimapApplication::getForeignKeyField() => $_POST['application_id'] ?? null,
40+
],
41+
]
42+
);
43+
$authorizations = [
44+
'-1' => __('Create authorization for another user', 'oauthimap')
45+
];
46+
$value = -1;
47+
foreach ($iterator as $row) {
48+
$authorizations[$row['id']] = $row['email'];
49+
if (array_key_exists('selected', $_POST) && $row['email'] == $_POST['selected']) {
50+
$value = $row['id'];
51+
}
52+
}
53+
54+
Dropdown::showFromArray(
55+
PluginOauthimapAuthorization::getForeignKeyField(),
56+
$authorizations,
57+
[
58+
'display_emptychoice' => false,
59+
'value' => $value,
60+
]
61+
);

composer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"require": {
3+
"php": "^7.2",
4+
"league/oauth2-google": "^3.0",
5+
"thenetworg/oauth2-azure": "^1.4"
6+
},
7+
"require-dev": {
8+
"glpi-project/tools": "^0.1"
9+
},
10+
"config": {
11+
"optimize-autoloader": true,
12+
"platform": {
13+
"php": "7.2.0"
14+
},
15+
"sort-packages": true
16+
}
17+
}

0 commit comments

Comments
 (0)