Skip to content

Commit

Permalink
Oauth IMAP mail receivers for G Suite and Azure AD
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Oct 9, 2020
1 parent 82aaa55 commit faafa8e
Show file tree
Hide file tree
Showing 36 changed files with 6,036 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
vendor/
.gh_token
*.min.*
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: php
php:
- 7.2
- 7.4

before_script:
- composer self-update
- composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest

script:
- vendor/bin/robo --no-interaction code:cs --strict

cache:
directories:
- $HOME/.composer/cache
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Oauth IMAP client for GLPI

This plugins provides IMAP SASL XOAUTH2 authentication mechanism for mail receivers.

Currently implemented for:

* [Google (Gmail)](https://developers.google.com/gmail/imap/xoauth2-protocol)
* [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)

![Configuration page](docs/screenshots/config.png)
![mail receiver setup](docs/screenshots/config_oauth_mailcollector.png)

## Documentation

We maintain a detailed documentation here -> [Documentation](https://glpi-plugins.readthedocs.io/en/latest/oauthimap/index.html)

## Contact

For notices about major changes and general discussion of oauthimap, subscribe to the [/r/glpi](https://www.reddit.com/r/glpi/) subreddit.
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).

## Professional Services

![GLPI Network](docs/glpi_network.png "GLPI network")

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.

Obtain a personalized service experience, associated with benefits and opportunities.

## Contributing

* Open a ticket for each bug/feature so it can be discussed
* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins/index.html)
* Refer to [GitFlow](http://git-flow.readthedocs.io/) process for branching
* Work on a new branch on your own fork
* Open a PR that will be reviewed by a developer

## Copying

* **Code**: you can redistribute it and/or modify
it under the terms of the GNU General Public License ([GPL-2.0](https://www.gnu.org/licenses/gpl-2.0.en.html)).
32 changes: 32 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
-------------------------------------------------------------------------
oauthimap plugin for GLPI
Copyright (C) 2018-2020 by the oauthimap Development Team.
-------------------------------------------------------------------------
LICENSE
This file is part of oauthimap.
oauthimap is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
oauthimap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with oauthimap. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/

require_once 'vendor/autoload.php';

class RoboFile extends Glpi\Tools\RoboFile
{
//Own plugin's robo stuff
}
61 changes: 61 additions & 0 deletions ajax/dropdownAuthorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
-------------------------------------------------------------------------
oauthimap plugin for GLPI
Copyright (C) 2018-2020 by the oauthimap Development Team.
-------------------------------------------------------------------------
LICENSE
This file is part of oauthimap.
oauthimap is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
oauthimap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with oauthimap. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/

include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Session::checkLoginUser();

global $DB;

$iterator = $DB->request(
[
'FROM' => PluginOauthimapAuthorization::getTable(),
'WHERE' => [
PluginOauthimapApplication::getForeignKeyField() => $_POST['application_id'] ?? null,
],
]
);
$authorizations = [
'-1' => __('Create authorization for another user', 'oauthimap')
];
$value = -1;
foreach ($iterator as $row) {
$authorizations[$row['id']] = $row['email'];
if (array_key_exists('selected', $_POST) && $row['email'] == $_POST['selected']) {
$value = $row['id'];
}
}

Dropdown::showFromArray(
PluginOauthimapAuthorization::getForeignKeyField(),
$authorizations,
[
'display_emptychoice' => false,
'value' => $value,
]
);
17 changes: 17 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"require": {
"php": "^7.2",
"league/oauth2-google": "^3.0",
"thenetworg/oauth2-azure": "^1.4"
},
"require-dev": {
"glpi-project/tools": "^0.1"
},
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.2.0"
},
"sort-packages": true
}
}
Loading

0 comments on commit faafa8e

Please sign in to comment.