Commit b03c9c9a authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Changes for /check_token endpoint

parent 0ff1e83d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -108,6 +108,10 @@ Before using social API it is necessary to register an application on each socia


Copy the `config-example.php` into `config.php` and edit it for matching your needs.
Copy the `config-example.php` into `config.php` and edit it for matching your needs.


### Generate keypair

    php exec/generate-keypair.php

### Logs directory
### Logs directory


Create the logs directory and assign ownership to the Apache user (usually www-data or apache)
Create the logs directory and assign ownership to the Apache user (usually www-data or apache)
+13 −2
Original line number Original line Diff line number Diff line
@@ -127,10 +127,21 @@ Flight::route('POST /auth/oauth2/check_token', function() {


    global $locator;
    global $locator;


    $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING);
    $headers = apache_request_headers();

    if (!isset($headers['Authorization'])) {
        throw new BadRequestException("Missing Authorization header");
    }

    $authorizationHeader = explode(" ", $headers['Authorization']);
    if ($authorizationHeader[0] === "Bearer") {
        $token = $authorizationHeader[1];
    } else {
        throw new BadRequestException("Invalid token type");
    }


    if ($token === null) {
    if ($token === null) {
        throw new BadRequestException("Access token id is required");
        throw new BadRequestException("Access token is required");
    }
    }


    $requestHandler = new \RAP\OAuth2RequestHandler($locator);
    $requestHandler = new \RAP\OAuth2RequestHandler($locator);