2017-08-08 03:01:11 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Adapted from Oauth2-server-php cookbook
|
|
|
|
* @see http://bshaffer.github.io/oauth2-server-php-docs/cookbook/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// include our OAuth2 Server object
|
|
|
|
require_once __DIR__.'/server.php';
|
2020-05-02 00:21:26 +08:00
|
|
|
require_once __DIR__.'/config.php';
|
|
|
|
|
2017-08-08 03:01:11 +08:00
|
|
|
|
2020-05-02 00:21:26 +08:00
|
|
|
/*
|
|
|
|
|
2020-05-02 01:28:42 +08:00
|
|
|
The Mattermost server seems to be returning bare http urls, even if
|
|
|
|
there is no http url in the config.json. If we are using https we
|
|
|
|
need to modify them.
|
2020-04-28 05:00:45 +08:00
|
|
|
|
2020-05-02 00:21:26 +08:00
|
|
|
*/
|
|
|
|
$redirect_url_scheme = substr($_POST["redirect_uri"], 0, 5);
|
|
|
|
|
|
|
|
if ($url_scheme == "https" && $redirect_url_scheme == "http:") {
|
|
|
|
$_POST["redirect_uri"] = "https" . substr($_POST["redirect_uri"], 4);
|
2020-04-25 04:50:30 +08:00
|
|
|
}
|
|
|
|
|
2020-05-02 01:24:17 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
Handle a request for an OAuth2.0 Access Token and send the response
|
|
|
|
to the client
|
|
|
|
|
|
|
|
*/
|
2017-08-08 03:01:11 +08:00
|
|
|
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
|
2020-04-25 04:50:30 +08:00
|
|
|
?>
|