xoauth stuff

This commit is contained in:
Synchro 2015-11-10 13:09:29 +01:00
parent 466264810a
commit 016e6330d4
13 changed files with 583 additions and 422 deletions

View File

@ -9,6 +9,8 @@ This is a major update that breaks backwards compatibility.
* Classes renamed to make use of the namespace
* `Extras` classes have been removed - use packages from packagist.org instead
* All elements previously marked as deprecated have been removed (e.g. `ReturnPath`)
* NTLM authentication removed - never worked anyway!
* SMTP::authenticate method signature changed
To avoid version confusion, this release is called **5.4**, **not 5.3**!

View File

@ -1,72 +0,0 @@
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.4.
*
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailerOAuthProvider class
* An abstract base class for service-provider-specific OAuth implementations.
* @author @hayageek
* @author Ravishanker Kusuma (hayageek@gmail.com)
*/
abstract class PHPMailerOAuthProvider
{
protected $oauthToken = null;
public function __construct(
$UserEmail = '',
$ClientSecret = '',
$ClientId = '',
$RefreshToken = ''
) {
$this->oauthClientId = $ClientId;
$this->oauthClientSecret = $ClientSecret;
$this->oauthRefreshToken = $RefreshToken;
$this->oauthUserEmail = $UserEmail;
}
abstract public function getProvider();
public function getOAUTHInstance()
{
return $this;
}
private function getGrant()
{
return new \League\OAuth2\Client\Grant\RefreshToken();
}
private function getToken()
{
$provider = $this->getProvider();
$grant = $this->getGrant();
return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]);
}
public function getOauth64()
{
// Get the new token only if it not available or expired
if ($this->oauthToken == null || ($this->oauthToken != null && $this->oauthToken->hasExpired()))
{
$this->oauthToken = $this->getToken();
}
return base64_encode('user='.$this->oauthUserEmail."\001auth=Bearer ".$this->oauthToken."\001\001");
}
}

View File

@ -20,17 +20,19 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=5.4.0",
"league/oauth2-google": "^1.0",
"hayageek/oauth2-yahoo": "^2.0",
"stevenmaguire/oauth2-microsoft": "^0.2.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "4.*"
},
"suggest": {
"league/oauth2-client": "Needed for Gmail's XOAUTH2 authentication system",
"league/oauth2-google": "^1.0",
"hayageek/oauth2-yahoo": "^2.0",
"stevenmaguire/oauth2-microsoft": "^0.2.0"
"league/oauth2-google": "Needed to use XOAUTH2 with Goole Gmail",
"hayageek/oauth2-yahoo": "Needed to use XOAUTH2 with Yahoo",
"stevenmaguire/oauth2-microsoft": "Needed to use XOAUTH2 with Microsoft services"
},
"autoload": {
"psr-4": {

451
composer.lock generated
View File

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "02e636165eb9fb167184cddb274e95c1",
"hash": "a3b58b03d342cf999d3795eca7e463b6",
"content-hash": "2d44974fc89cc800c9af9e89463f0ae2",
"packages": [
{
"name": "guzzlehttp/guzzle",
@ -121,16 +122,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "1.2.0",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e"
"reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/4ef919b0cf3b1989523138b60163bbcb7ba1ff7e",
"reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/4d0bdbe1206df7440219ce14c972aa57cc5e4982",
"reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982",
"shasum": ""
},
"require": {
@ -175,7 +176,57 @@
"stream",
"uri"
],
"time": "2015-08-15 19:32:36"
"time": "2015-11-03 01:34:55"
},
{
"name": "hayageek/oauth2-yahoo",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/hayageek/oauth2-yahoo.git",
"reference": "f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hayageek/oauth2-yahoo/zipball/f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245",
"reference": "f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245",
"shasum": ""
},
"require": {
"league/oauth2-client": "^1.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Hayageek\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ravishanker Kusuma",
"email": "hayageek@gmail.com",
"homepage": "http://hayageek.com"
}
],
"description": "Yahoo OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"Authentication",
"authorization",
"client",
"oauth",
"oauth2",
"yahoo"
],
"time": "2015-09-23 18:08:39"
},
{
"name": "ircmaxell/random-lib",
@ -433,6 +484,62 @@
"response"
],
"time": "2015-05-04 20:22:00"
},
{
"name": "stevenmaguire/oauth2-microsoft",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/stevenmaguire/oauth2-microsoft.git",
"reference": "1141315e8e878cf2c9847193a675fcde0a157a8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stevenmaguire/oauth2-microsoft/zipball/1141315e8e878cf2c9847193a675fcde0a157a8c",
"reference": "1141315e8e878cf2c9847193a675fcde0a157a8c",
"shasum": ""
},
"require": {
"league/oauth2-client": "~1.0",
"php": ">=5.5.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Stevenmaguire\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Steven Maguire",
"email": "stevenmaguire@gmail.com",
"homepage": "https://github.com/stevenmaguire"
}
],
"description": "Microsoft OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"authorisation",
"authorization",
"client",
"microsoft",
"oauth",
"oauth2"
],
"time": "2015-08-20 14:08:56"
}
],
"packages-dev": [
@ -759,16 +866,16 @@
},
{
"name": "erusev/parsedown",
"version": "1.5.4",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "0e89e3714bda18973184d30646306bb0a482bd96"
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/0e89e3714bda18973184d30646306bb0a482bd96",
"reference": "0e89e3714bda18973184d30646306bb0a482bd96",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"shasum": ""
},
"type": "library",
@ -794,7 +901,7 @@
"markdown",
"parser"
],
"time": "2015-08-03 09:24:05"
"time": "2015-10-04 16:44:32"
},
{
"name": "herrera-io/json",
@ -1074,16 +1181,16 @@
},
{
"name": "justinrainbow/json-schema",
"version": "1.4.4",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/justinrainbow/json-schema.git",
"reference": "8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce"
"reference": "a4bee9f4b344b66e0a0d96c7afae1e92edf385fe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce",
"reference": "8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/a4bee9f4b344b66e0a0d96c7afae1e92edf385fe",
"reference": "a4bee9f4b344b66e0a0d96c7afae1e92edf385fe",
"shasum": ""
},
"require": {
@ -1104,8 +1211,8 @@
}
},
"autoload": {
"psr-0": {
"JsonSchema": "src/"
"psr-4": {
"JsonSchema\\": "src/JsonSchema/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -1136,7 +1243,7 @@
"json",
"schema"
],
"time": "2015-07-14 16:29:50"
"time": "2015-09-08 22:28:04"
},
{
"name": "kherge/version",
@ -1183,16 +1290,16 @@
},
{
"name": "monolog/monolog",
"version": "1.17.1",
"version": "1.17.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422"
"reference": "bee7f0dc9c3e0b69a6039697533dca1e845c8c24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/0524c87587ab85bc4c2d6f5b41253ccb930a5422",
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bee7f0dc9c3e0b69a6039697533dca1e845c8c24",
"reference": "bee7f0dc9c3e0b69a6039697533dca1e845c8c24",
"shasum": ""
},
"require": {
@ -1206,10 +1313,11 @@
"aws/aws-sdk-php": "^2.4.9",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"raven/raven": "~0.11",
"raven/raven": "^0.13",
"ruflin/elastica": ">=0.90 <3.0",
"swiftmailer/swiftmailer": "~5.3",
"videlalvaro/php-amqplib": "~2.4"
@ -1255,7 +1363,7 @@
"logging",
"psr-3"
],
"time": "2015-08-31 09:17:37"
"time": "2015-10-14 12:51:02"
},
{
"name": "nikic/php-parser",
@ -1740,16 +1848,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "2.2.2",
"version": "2.2.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c"
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"shasum": ""
},
"require": {
@ -1798,7 +1906,7 @@
"testing",
"xunit"
],
"time": "2015-08-04 03:42:39"
"time": "2015-10-06 15:47:00"
},
{
"name": "phpunit/php-file-iterator",
@ -1931,16 +2039,16 @@
},
{
"name": "phpunit/php-token-stream",
"version": "1.4.6",
"version": "1.4.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b"
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": ""
},
"require": {
@ -1976,20 +2084,20 @@
"keywords": [
"tokenizer"
],
"time": "2015-08-16 08:51:00"
"time": "2015-09-15 10:49:45"
},
{
"name": "phpunit/phpunit",
"version": "4.7.7",
"version": "4.8.16",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "9b97f9d807b862c2de2a36e86690000801c85724"
"reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724",
"reference": "9b97f9d807b862c2de2a36e86690000801c85724",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/625f8c345606ed0f3a141dfb88f4116f0e22978e",
"reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e",
"shasum": ""
},
"require": {
@ -1999,7 +2107,7 @@
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "~1.3,>=1.3.1",
"phpspec/prophecy": "^1.3.1",
"phpunit/php-code-coverage": "~2.1",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
@ -2007,7 +2115,7 @@
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
"sebastian/environment": "~1.2",
"sebastian/environment": "~1.3",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
"sebastian/version": "~1.0",
@ -2022,7 +2130,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.7.x-dev"
"dev-master": "4.8.x-dev"
}
},
"autoload": {
@ -2048,20 +2156,20 @@
"testing",
"xunit"
],
"time": "2015-07-13 11:28:34"
"time": "2015-10-23 06:48:33"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.3.7",
"version": "2.3.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "5e2645ad49d196e020b85598d7c97e482725786a"
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
"reference": "5e2645ad49d196e020b85598d7c97e482725786a",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"shasum": ""
},
"require": {
@ -2104,7 +2212,7 @@
"mock",
"xunit"
],
"time": "2015-08-19 09:14:08"
"time": "2015-10-02 06:51:40"
},
{
"name": "pimple/pimple",
@ -2426,16 +2534,16 @@
},
{
"name": "sebastian/global-state",
"version": "1.0.0",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
"reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4",
"reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
"shasum": ""
},
"require": {
@ -2473,7 +2581,7 @@
"keywords": [
"global state"
],
"time": "2014-10-06 09:23:50"
"time": "2015-10-12 03:26:01"
},
{
"name": "sebastian/recursion-context",
@ -2611,25 +2719,22 @@
},
{
"name": "symfony/config",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9"
"reference": "831f88908b51b9ce945f5e6f402931d1ac544423"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/6c905bbed1e728226de656e4c07d620dfe9e80d9",
"reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9",
"url": "https://api.github.com/repos/symfony/config/zipball/831f88908b51b9ce945f5e6f402931d1ac544423",
"reference": "831f88908b51b9ce945f5e6f402931d1ac544423",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/filesystem": "~2.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2657,20 +2762,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-10-11 09:39:48"
},
{
"name": "symfony/console",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e"
"reference": "5efd632294c8320ea52492db22292ff853a43766"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/d6cf02fe73634c96677e428f840704bfbcaec29e",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e",
"url": "https://api.github.com/repos/symfony/console/zipball/5efd632294c8320ea52492db22292ff853a43766",
"reference": "5efd632294c8320ea52492db22292ff853a43766",
"shasum": ""
},
"require": {
@ -2679,7 +2784,6 @@
"require-dev": {
"psr/log": "~1.0",
"symfony/event-dispatcher": "~2.1",
"symfony/phpunit-bridge": "~2.7",
"symfony/process": "~2.1"
},
"suggest": {
@ -2714,20 +2818,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 15:18:12"
"time": "2015-10-20 14:38:46"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3"
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"shasum": ""
},
"require": {
@ -2738,7 +2842,6 @@
"symfony/config": "~2.0,>=2.0.5",
"symfony/dependency-injection": "~2.6",
"symfony/expression-language": "~2.6",
"symfony/phpunit-bridge": "~2.7",
"symfony/stopwatch": "~2.3"
},
"suggest": {
@ -2772,28 +2875,25 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2015-06-18 19:21:56"
"time": "2015-10-11 09:39:48"
},
{
"name": "symfony/filesystem",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8"
"reference": "56fd6df73be859323ff97418d97edc1d756df6df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/2d7b2ddaf3f548f4292df49a99d19c853d43f0b8",
"reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/56fd6df73be859323ff97418d97edc1d756df6df",
"reference": "56fd6df73be859323ff97418d97edc1d756df6df",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2821,28 +2921,25 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-10-18 20:23:18"
},
{
"name": "symfony/finder",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "ae0f363277485094edc04c9f3cbe595b183b78e4"
"url": "https://github.com/symfony/finder.git",
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/ae0f363277485094edc04c9f3cbe595b183b78e4",
"reference": "ae0f363277485094edc04c9f3cbe595b183b78e4",
"url": "https://api.github.com/repos/symfony/finder/zipball/2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2870,28 +2967,25 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-10-11 09:39:48"
},
{
"name": "symfony/process",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3"
"url": "https://github.com/symfony/process.git",
"reference": "4a959dd4e19c2c5d7512689413921e0a74386ec7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/48aeb0e48600321c272955132d7606ab0a49adb3",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3",
"url": "https://api.github.com/repos/symfony/process/zipball/4a959dd4e19c2c5d7512689413921e0a74386ec7",
"reference": "4a959dd4e19c2c5d7512689413921e0a74386ec7",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2919,28 +3013,25 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2015-07-01 11:25:50"
"time": "2015-10-23 14:47:27"
},
{
"name": "symfony/stopwatch",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Stopwatch.git",
"reference": "b07a866719bbac5294c67773340f97b871733310"
"url": "https://github.com/symfony/stopwatch.git",
"reference": "f8ab957c17e4b85a73c4df03bdf94ee597f2bd55"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310",
"reference": "b07a866719bbac5294c67773340f97b871733310",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/f8ab957c17e4b85a73c4df03bdf94ee597f2bd55",
"reference": "f8ab957c17e4b85a73c4df03bdf94ee597f2bd55",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2968,20 +3059,20 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2015-07-01 18:23:16"
"time": "2015-10-12 12:42:24"
},
{
"name": "symfony/translation",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"reference": "c8dc34cc936152c609cdd722af317e4239d10dd6"
"url": "https://github.com/symfony/translation.git",
"reference": "6ccd9289ec1c71d01a49d83480de3b5293ce30c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/c8dc34cc936152c609cdd722af317e4239d10dd6",
"reference": "c8dc34cc936152c609cdd722af317e4239d10dd6",
"url": "https://api.github.com/repos/symfony/translation/zipball/6ccd9289ec1c71d01a49d83480de3b5293ce30c8",
"reference": "6ccd9289ec1c71d01a49d83480de3b5293ce30c8",
"shasum": ""
},
"require": {
@ -2993,8 +3084,7 @@
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.7",
"symfony/intl": "~2.3",
"symfony/phpunit-bridge": "~2.7",
"symfony/intl": "~2.4",
"symfony/yaml": "~2.2"
},
"suggest": {
@ -3029,20 +3119,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-10-27 15:38:06"
},
{
"name": "symfony/validator",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
"reference": "646df03e635a8a232804274401449ccdf5f03cad"
"url": "https://github.com/symfony/validator.git",
"reference": "df9021e689aa3d08367881e7f8917219fabe5e64"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Validator/zipball/646df03e635a8a232804274401449ccdf5f03cad",
"reference": "646df03e635a8a232804274401449ccdf5f03cad",
"url": "https://api.github.com/repos/symfony/validator/zipball/df9021e689aa3d08367881e7f8917219fabe5e64",
"reference": "df9021e689aa3d08367881e7f8917219fabe5e64",
"shasum": ""
},
"require": {
@ -3052,12 +3142,12 @@
"require-dev": {
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.0",
"doctrine/common": "~2.3",
"egulias/email-validator": "~1.2,>=1.2.1",
"symfony/config": "~2.2",
"symfony/expression-language": "~2.4",
"symfony/http-foundation": "~2.1",
"symfony/intl": "~2.3",
"symfony/phpunit-bridge": "~2.7",
"symfony/intl": "~2.4",
"symfony/property-access": "~2.3",
"symfony/yaml": "~2.0,>=2.0.5"
},
@ -3099,28 +3189,25 @@
],
"description": "Symfony Validator Component",
"homepage": "https://symfony.com",
"time": "2015-07-31 06:49:15"
"time": "2015-10-18 20:23:18"
},
{
"name": "symfony/yaml",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff"
"url": "https://github.com/symfony/yaml.git",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/71340e996171474a53f3d29111d046be4ad8a0ff",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff",
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@ -3148,20 +3235,20 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 14:07:07"
"time": "2015-10-11 09:39:48"
},
{
"name": "twig/twig",
"version": "v1.21.1",
"version": "v1.23.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23"
"reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
"reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
"reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
"shasum": ""
},
"require": {
@ -3174,7 +3261,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.21-dev"
"dev-master": "1.23-dev"
}
},
"autoload": {
@ -3209,32 +3296,32 @@
"keywords": [
"templating"
],
"time": "2015-08-26 08:58:31"
"time": "2015-11-05 12:49:06"
},
{
"name": "zendframework/zend-cache",
"version": "2.5.2",
"version": "2.5.3",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-cache.git",
"reference": "325afc68d4381cf8b95288ebb9b1d38dc32ed579"
"reference": "7ff9d6b922ae29dbdc53f6a62b471fb6e58565df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-cache/zipball/325afc68d4381cf8b95288ebb9b1d38dc32ed579",
"reference": "325afc68d4381cf8b95288ebb9b1d38dc32ed579",
"url": "https://api.github.com/repos/zendframework/zend-cache/zipball/7ff9d6b922ae29dbdc53f6a62b471fb6e58565df",
"reference": "7ff9d6b922ae29dbdc53f6a62b471fb6e58565df",
"shasum": ""
},
"require": {
"php": ">=5.5",
"zendframework/zend-eventmanager": "~2.5",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-servicemanager": "~2.5",
"zendframework/zend-stdlib": "~2.5"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-session": "~2.5"
},
"suggest": {
@ -3272,7 +3359,7 @@
"cache",
"zf2"
],
"time": "2015-07-16 18:44:41"
"time": "2015-09-15 16:09:09"
},
{
"name": "zendframework/zend-config",
@ -3434,6 +3521,62 @@
],
"time": "2015-06-03 15:32:01"
},
{
"name": "zendframework/zend-hydrator",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-hydrator.git",
"reference": "f3ed8b833355140350bbed98d8a7b8b66875903f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-hydrator/zipball/f3ed8b833355140350bbed98d8a7b8b66875903f",
"reference": "f3ed8b833355140350bbed98d8a7b8b66875903f",
"shasum": ""
},
"require": {
"php": ">=5.5",
"zendframework/zend-stdlib": "^2.5.1"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "^2.0@dev",
"zendframework/zend-eventmanager": "^2.5.1",
"zendframework/zend-filter": "^2.5.1",
"zendframework/zend-inputfilter": "^2.5.1",
"zendframework/zend-serializer": "^2.5.1",
"zendframework/zend-servicemanager": "^2.5.1"
},
"suggest": {
"zendframework/zend-eventmanager": "^2.5.1, to support aggregate hydrator usage",
"zendframework/zend-filter": "^2.5.1, to support naming strategy hydrator usage",
"zendframework/zend-serializer": "^2.5.1, to use the SerializableStrategy",
"zendframework/zend-servicemanager": "^2.5.1, to support hydrator plugin manager usage"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Hydrator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zend-hydrator",
"keywords": [
"hydrator",
"zf2"
],
"time": "2015-09-17 14:06:43"
},
{
"name": "zendframework/zend-i18n",
"version": "2.5.1",
@ -3708,22 +3851,24 @@
},
{
"name": "zendframework/zend-stdlib",
"version": "2.6.0",
"version": "2.7.4",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-stdlib.git",
"reference": "a35758803fc9051ec1aff43989e679b6b451b1b4"
"reference": "cae029346a33663b998507f94962eb27de060683"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a35758803fc9051ec1aff43989e679b6b451b1b4",
"reference": "a35758803fc9051ec1aff43989e679b6b451b1b4",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cae029346a33663b998507f94962eb27de060683",
"reference": "cae029346a33663b998507f94962eb27de060683",
"shasum": ""
},
"require": {
"php": ">=5.5"
"php": ">=5.5",
"zendframework/zend-hydrator": "~1.0"
},
"require-dev": {
"athletic/athletic": "~0.1",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0",
"zendframework/zend-config": "~2.5",
@ -3742,8 +3887,8 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev",
"dev-develop": "2.7-dev"
"dev-master": "2.7-dev",
"dev-develop": "2.8-dev"
}
},
"autoload": {
@ -3760,7 +3905,7 @@
"stdlib",
"zf2"
],
"time": "2015-07-21 17:08:05"
"time": "2015-10-15 15:57:32"
},
{
"name": "zetacomponents/base",
@ -3883,7 +4028,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.0.0"
"php": ">=5.4.0"
},
"platform-dev": []
}

View File

@ -1,78 +1,75 @@
<?php
/**
* Get an OAuth2 token from Google.
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.4
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Get an OAuth2 token from an OAuth2 provider.
* * Install this script on your server so that it's accessible
* as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
* e.g.: http://localhost/phpmail/get_oauth_token.php
* e.g.: http://localhost/phpmailer/get_oauth_token.php
* * Ensure dependencies are installed with 'composer install'
* * Set up an app in your Google/Yahoo/Microsoft account
* * Set the script address as the app's redirect URL
* If no refresh token is obtained when running this file, revoke access to your app
* using link: https://accounts.google.com/b/0/IssuedAuthSubTokens and run the script again.
* This script requires PHP 5.4 or later
* If no refresh token is obtained when running this file,
* revoke access to your app and run the script again.
* PHP Version 5.4
*/
if (!isset($_GET['code']) && !isset($_GET['provider'])) {
?>
<html>
<body>Select Provider:<br/>
<a href='?provider=Google'>Google</a><br/>
<a href='?provider=Yahoo'>Yahoo</a><br/>
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
</body>
<?php
exit;
}
require 'vendor/autoload.php';
session_start();
if (!isset($_GET['code']) && !isset($_GET['provider_name'])) {
echo '<html><body><b>Select Provider</b>:<br/>';
echo "<a href='?provider_name=google'>Google</a><br/>";
echo "<a href='?provider_name=yahoo'>Yahoo</a><br/>";
echo "<a href='?provider_name=microsoft'>Microsoft/Outlook/Live</a><br/>";
echo '</body>';
exit;
$providerName = '';
if (array_key_exists('provider', $_GET)) {
$providerName = $_GET['provider'];
$_SESSION['provider'] = $providerName;
} elseif (array_key_exists('provider', $_SESSION)) {
$providerName = $_SESSION['provider'];
}
if (!preg_match('/^(Google|Microsoft|Yahoo)$/', $providerName)) {
exit("Only Google, Microsoft and Yahoo OAuth2 providers are currently supported.");
}
$provider_name = '';
$options = array();
//Alter this to point at the URL of this script on your own server
//Should be an HTTPS URL
$redirectUri = 'https://example.com/PHPMailer/get_oauth_token.php';
if (isset($_GET['provider_name'])) {
$provider_name = $_GET['provider_name'];
$_SESSION['provider_name'] = $provider_name;
} elseif (isset($_SESSION['provider_name'])) {
$provider_name = $_SESSION['provider_name'];
}
//save in session for subsequent requests.
$redirectUri = 'https://kusuma.com/phpmail/PHPMailer/get_oauth_token.php';
$providerClass = '\\PHPMailer\\PHPMailer\\OAuthProvider\\'.$providerName;
if ($provider_name == 'google') {
$provider = new League\OAuth2\Client\Provider\Google(array(
'clientId' => '{GOOGLE_APP_ID}',
'clientSecret' => '{GOOGLE_APP_SECRET}',
'redirectUri' => $redirectUri,
'accessType' => 'offline'
));
//scope for mail
$options['scope'] = array(
'https://mail.google.com/'
);
//To get the refresh token everytime
$options['approval_prompt'] = 'force';
} elseif ($provider_name == 'yahoo') {
$provider = new Hayageek\OAuth2\Client\Provider\Yahoo(array(
'clientId' => '{YAHOO_APP_ID}',
'clientSecret' => '{YAHOO_APP_SECRET}',
'redirectUri' => $redirectUri //for yahoo redirect URL should be https
));
} elseif ($provider_name == 'microsoft') {
$provider = new Stevenmaguire\OAuth2\Client\Provider\Microsoft(array(
'clientId' => '{MICROSOFT_APP_ID}',
'clientSecret' => '{MICROSOFT_APP_SECRET}',
'redirectUri' => $redirectUri
));
//scopes
$options['scope'] = array(
'wl.imap',
'wl.offline_access'
);
} else {
echo 'Not supported for now';
exit;
}
$provider = new $providerClass(
'{YOUR_APP_ID}',
'{YOUR_APP_SECRET}',
$redirectUri,
'offline'
);
if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
@ -86,10 +83,10 @@ if (!isset($_GET['code'])) {
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
unset($_SESSION['provider_name']);
unset($_SESSION['provider']);
exit('Invalid state');
} else {
unset($_SESSION['provider_name']);
unset($_SESSION['provider']);
// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken('authorization_code', array(
@ -104,4 +101,4 @@ if (!isset($_GET['code'])) {
// Number of seconds until the access token will expire, and need refreshing
echo 'Expires:' . $token->getExpires() . '<br>';
}
}

129
src/OAuthProvider/Base.php Normal file
View File

@ -0,0 +1,129 @@
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.4
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace PHPMailer\PHPMailer\OAuthProvider;
/**
* PHPMailer OAuthProvider Base class.
* An abstract base class for service-provider-specific OAuth implementations.
* @author @hayageek
* @author Ravishanker Kusuma (hayageek@gmail.com)
*/
abstract class Base
{
/**
* @var League\OAuth2\Client\Provider\AbstractProvider
*/
protected $provider = null;
/**
* @var League\OAuth2\Client\Token\AccessToken
*/
protected $oauthToken = null;
/**
* @var string
*/
protected $oauthUserEmail = '';
/**
* @var string
*/
protected $oauthClientSecret = '';
/**
* @var string
*/
protected $oauthClientId = '';
/**
* @var string
*/
protected $refreshToken = '';
public function __construct(
$userEmail = '',
$clientSecret = '',
$clientId = '',
$refreshToken = ''
) {
$this->oauthUserEmail = $userEmail;
$this->oauthClientSecret = $clientSecret;
$this->oauthClientId = $clientId;
$this->oauthRefreshToken = $refreshToken;
}
/**
* @return League\OAuth2\Client\Provider\AbstractProvider
*/
abstract public function getProvider();
/**
* Array of default options.
* @return array
*/
protected function getOptions()
{
return [];
}
/**
* @return \League\OAuth2\Client\Grant\RefreshToken
*/
protected function getGrant()
{
return new \League\OAuth2\Client\Grant\RefreshToken();
}
/**
* @return League\OAuth2\Client\Token\AccessToken
*/
protected function getToken()
{
$provider = $this->getProvider();
$grant = $this->getGrant();
return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]);
}
/**
* Generate a base64-encoded OAuth token.
* @return string
*/
public function getOauth64()
{
// Get a new token if it's not available or has expired
if (is_null($this->oauthToken) or $this->oauthToken->hasExpired()) {
$this->oauthToken = $this->getToken();
}
return base64_encode('user='.$this->oauthUserEmail."\001auth=Bearer ".$this->oauthToken."\001\001");
}
/**
* @param array $options
* @return string
*/
public function getAuthorizationUrl($options = [])
{
//If no options provided, use defaults
if (empty($options)) {
$options = $this->getOptions();
}
return $this->getProvider()->getAuthorizationUrl($options);
}
}

View File

@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -19,20 +19,34 @@
namespace PHPMailer\PHPMailer\OAuthProvider;
use League\OAuth2\Client\Provider\Google as LeagueGoogle;
/**
* PHPMailer Google OAuth class- Wrapper for League OAuth2 Google provider.
* Wrapper for League Google OAuth2 provider.
* @package PHPMailer
* @author @sherryl4george
* @author Marcus Bointon (@Synchro) <phpmailer@synchromedia.co.uk>
* @link https://github.com/thephpleague/oauth2-client
*/
class PHPMailerOAuthGoogle extends PHPMailerOAuthProvider
class Google
class Google extends Base
{
public function getProvider() {
return new League\OAuth2\Client\Provider\Google([
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]);
public function getProvider()
{
if (is_null($this->provider)) {
$this->provider = new LeagueGoogle([
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]);
}
return $this->provider;
}
public function getOptions()
{
return [
'scope' => ['https://mail.google.com/'],
'approval_prompt' => 'force'
];
}
}

View File

@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -17,20 +17,38 @@
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace PHPMailer\PHPMailer\OAuthProvider;
use Stevenmaguire\OAuth2\Client\Provider\Microsoft as StevenmaguireMicrosoft;
/**
* PHPMailerOAuthProvider - Wrapper for League OAuth2 Microsoft provider.
* Wrapper for League Microsoft OAuth2 provider.
* @package PHPMailer
* @author @hayageek
* @author Ravishanker Kusuma (hayageek@gmail.com)
* @link https://github.com/hayageek
*/
class PHPMailerOAuthMicrosoft extends PHPMailerOAuthProvider
class Microsoft extends Base
{
public function getProvider() {
return new Stevenmaguire\OAuth2\Client\Provider\Microsoft([
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]);
public function getProvider()
{
if (is_null($this->provider)) {
$this->provider = new StevenmaguireMicrosoft([
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]);
}
return $this->provider;
}
public function getOptions()
{
return [
'scope' => [
'wl.imap',
'wl.offline_access'
]
];
}
}

View File

@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -17,21 +17,30 @@
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace PHPMailer\PHPMailer\OAuthProvider;
use Hayageek\OAuth2\Client\Provider\Yahoo as HayageekYahoo;
/**
* PHPMailerOAuthProvider - Wrapper for League OAuth2 provider.
* Wrapper for League Yahoo OAuth2 provider.
* @package PHPMailer
* @author @hayageek
* @author Ravishanker Kusuma (hayageek@gmail.com)
* @link https://github.com/hayageek
*/
class PHPMailerOAuthYahoo extends PHPMailerOAuthProvider
class Yahoo extends Base
{
public function getProvider() {
return new Hayageek\OAuth2\Client\Provider\Yahoo([
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]);
public function getProvider()
{
if (is_null($this->provider)) {
$this->provider = new HayageekYahoo(
[
'clientId' => $this->oauthClientId,
'clientSecret' => $this->oauthClientSecret
]
);
}
return $this->provider;
}
}

View File

@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License

View File

@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -28,53 +28,26 @@ namespace PHPMailer\PHPMailer;
class PHPMailerOAuth extends PHPMailer
{
/**
* The OAuth user's email address
* @var string
*/
public $oauthUserEmail = '';
/**
* The OAuth refresh token
* @var string
*/
public $oauthRefreshToken = '';
/**
* The OAuth client ID
* @var string
*/
public $oauthClientId = '';
/**
* The OAuth client secret
* @var string
*/
public $oauthClientSecret = '';
/**
* An instance of the OAuthProvider\Google class.
* @var OAuthProvider\Google
* An instance of an OAuthProvider\Base derivative class.
* @var OAuthProvider\Base
* @access protected
*/
protected $oauth = null;
/**
* Get an OAuthProvider\Google instance to use.
* @return OAuthProvider\Google
* Get an OAuthProvider instance to use.
* @return OAuthProvider\Base
*/
public function getOAUTHInstance()
public function getOAuth()
{
if (!is_object($this->oauth)) {
$this->oauth = new OAuthProvider\Google(
$this->oauthUserEmail,
$this->oauthClientSecret,
$this->oauthClientId,
$this->oauthRefreshToken
);
}
return $this->oauth;
}
public function setOAuth(OAuthProvider\Base $oauth)
{
$this->oauth = $oauth;
}
/**
* Initiate a connection to an SMTP server.
* Overrides the original smtpConnect method to add support for OAuth.
@ -92,7 +65,7 @@ class PHPMailerOAuth extends PHPMailer
}
if (is_null($this->oauth)) {
$this->oauth = $this->getOAUTHInstance();
$this->oauth = $this->getOAuth();
}
// Already connected?
@ -157,7 +130,7 @@ class PHPMailerOAuth extends PHPMailer
// * we have openssl extension
// * we are not already using SSL
// * the server offers STARTTLS
if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) {
if ($this->SMTPAutoTLS and $sslext and 'ssl' != $secure and $this->smtp->getServerExt('STARTTLS')) {
$tls = true;
}
if ($tls) {
@ -172,8 +145,6 @@ class PHPMailerOAuth extends PHPMailer
$this->Username,
$this->Password,
$this->AuthType,
$this->Realm,
$this->Workstation,
$this->oauth
)
) {

View File

@ -1,14 +1,14 @@
<?php
/**
* PHPMailer POP-Before-SMTP Authentication Class.
* PHP Version 5
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.4
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License

View File

@ -1,14 +1,14 @@
<?php
/**
* PHPMailer RFC821 SMTP email transport class.
* PHP Version 5
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.4
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2014 Marcus Bointon
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -348,17 +348,13 @@ class SMTP
* @param string $username The user name
* @param string $password The password
* @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
* @param string $realm The auth realm for NTLM
* @param string $workstation The auth workstation for NTLM
* @param null|PHPMailerOAuthProvider $OAuth An optional PHPMailerOAuthProvider instance (@see PHPMailerOAuth)
* @param OAuthProvider\Base $OAuth An optional OAuth provider instance (@see PHPMailerOAuth)
* @return bool True if successfully authenticated.* @access public
*/
public function authenticate(
$username,
$password,
$authtype = null,
$realm = '',
$workstation = '',
$OAuth = null
) {
if (!$this->server_caps) {
@ -444,56 +440,6 @@ class SMTP
return false;
}
break;
case 'NTLM':
/*
* ntlm_sasl_client.php
* Bundled with Permission
*
* How to telnet in windows:
* http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
* PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
*/
require_once 'extras/ntlm_sasl_client.php';
$temp = new stdClass;
$ntlm_client = new ntlm_sasl_client_class;
//Check that functions are available
if (!$ntlm_client->Initialize($temp)) {
$this->setError($temp->error);
$this->edebug(
'You need to enable some modules in your php.ini file: '
. $this->error['error'],
self::DEBUG_CLIENT
);
return false;
}
//msg1
$msg1 = $ntlm_client->TypeMsg1($realm, $workstation); //msg1
if (!$this->sendCommand(
'AUTH NTLM',
'AUTH NTLM ' . base64_encode($msg1),
334
)
) {
return false;
}
//Though 0 based, there is a white space after the 3 digit number
//msg2
$challenge = substr($this->last_reply, 3);
$challenge = base64_decode($challenge);
$ntlm_res = $ntlm_client->NTLMResponse(
substr($challenge, 24, 8),
$password
);
//msg3
$msg3 = $ntlm_client->TypeMsg3(
$ntlm_res,
$username,
$realm,
$workstation
);
// send encoded username
return $this->sendCommand('Username', base64_encode($msg3), 235);
case 'CRAM-MD5':
// Start authentication
if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {