@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - /* |
|
| 4 | + /* |
|
| 5 | 5 | |-------------------------------------------------------------------------- |
| 6 | 6 | | API Access |
| 7 | 7 | |-------------------------------------------------------------------------- |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | | If this applies to your Business, set 'expire_api_access' to true. |
| 12 | 12 | | |
| 13 | 13 | */ |
| 14 | - 'expire_api_access' => true, |
|
| 14 | + 'expire_api_access' => true, |
|
| 15 | 15 | |
| 16 | - /* |
|
| 16 | + /* |
|
| 17 | 17 | |-------------------------------------------------------------------------- |
| 18 | 18 | | Environment |
| 19 | 19 | |-------------------------------------------------------------------------- |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | | Default is true. |
| 23 | 23 | | |
| 24 | 24 | */ |
| 25 | - 'sandbox' => env('REVOLUT_SANDBOX', true), |
|
| 25 | + 'sandbox' => env('REVOLUT_SANDBOX', true), |
|
| 26 | 26 | |
| 27 | - /* |
|
| 27 | + /* |
|
| 28 | 28 | |-------------------------------------------------------------------------- |
| 29 | 29 | | Private Key Path |
| 30 | 30 | |-------------------------------------------------------------------------- |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | | authorization process. |
| 35 | 35 | | |
| 36 | 36 | */ |
| 37 | - 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
| 37 | + 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
| 38 | 38 | |
| 39 | - /* |
|
| 39 | + /* |
|
| 40 | 40 | |-------------------------------------------------------------------------- |
| 41 | 41 | | Client ID |
| 42 | 42 | |-------------------------------------------------------------------------- |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | | selecting the relevant API certificate. |
| 47 | 47 | | |
| 48 | 48 | */ |
| 49 | - 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
| 49 | + 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
| 50 | 50 | |
| 51 | - /* |
|
| 51 | + /* |
|
| 52 | 52 | |-------------------------------------------------------------------------- |
| 53 | 53 | | Oauth Redirect URI |
| 54 | 54 | |-------------------------------------------------------------------------- |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | | necessary route and controllers. |
| 61 | 61 | | |
| 62 | 62 | */ |
| 63 | - 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
| 63 | + 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
| 64 | 64 | |
| 65 | - /* |
|
| 65 | + /* |
|
| 66 | 66 | |-------------------------------------------------------------------------- |
| 67 | 67 | | Tokens |
| 68 | 68 | |-------------------------------------------------------------------------- |
@@ -79,22 +79,22 @@ discard block |
||
| 79 | 79 | | Supported stores: 'database', 'cache' |
| 80 | 80 | | |
| 81 | 81 | */ |
| 82 | - 'tokens' => [ |
|
| 82 | + 'tokens' => [ |
|
| 83 | 83 | |
| 84 | - 'encrypt' => true, |
|
| 84 | + 'encrypt' => true, |
|
| 85 | 85 | |
| 86 | - 'store' => 'database', |
|
| 86 | + 'store' => 'database', |
|
| 87 | 87 | |
| 88 | - 'database' => [ |
|
| 89 | - 'table_name' => 'revolut_tokens' |
|
| 90 | - ], |
|
| 88 | + 'database' => [ |
|
| 89 | + 'table_name' => 'revolut_tokens' |
|
| 90 | + ], |
|
| 91 | 91 | |
| 92 | - 'cache' => [ |
|
| 93 | - 'driver' => null, |
|
| 94 | - ], |
|
| 95 | - ], |
|
| 92 | + 'cache' => [ |
|
| 93 | + 'driver' => null, |
|
| 94 | + ], |
|
| 95 | + ], |
|
| 96 | 96 | |
| 97 | - /* |
|
| 97 | + /* |
|
| 98 | 98 | |-------------------------------------------------------------------------- |
| 99 | 99 | | Authorization Route |
| 100 | 100 | |-------------------------------------------------------------------------- |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | | therefore applied automatically and does not need to be specified |
| 106 | 106 | | |
| 107 | 107 | */ |
| 108 | - 'auth_route' => [ |
|
| 108 | + 'auth_route' => [ |
|
| 109 | 109 | |
| 110 | - 'name' => 'revolut-authorization', |
|
| 110 | + 'name' => 'revolut-authorization', |
|
| 111 | 111 | |
| 112 | - 'middleware' => [ |
|
| 113 | - // 'auth' |
|
| 114 | - ] |
|
| 115 | - ], |
|
| 112 | + 'middleware' => [ |
|
| 113 | + // 'auth' |
|
| 114 | + ] |
|
| 115 | + ], |
|
| 116 | 116 | ]; |
@@ -8,27 +8,27 @@ |
||
| 8 | 8 | |
| 9 | 9 | class DatabaseTokenRepository implements TokenRepository |
| 10 | 10 | { |
| 11 | - public function getAccessToken() |
|
| 12 | - { |
|
| 13 | - return AccessToken::active()->orderBy('id', 'desc')->first(); |
|
| 14 | - } |
|
| 11 | + public function getAccessToken() |
|
| 12 | + { |
|
| 13 | + return AccessToken::active()->orderBy('id', 'desc')->first(); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function getRefreshToken() |
|
| 17 | - { |
|
| 18 | - return RefreshToken::active()->orderBy('id', 'desc')->first(); |
|
| 19 | - } |
|
| 16 | + public function getRefreshToken() |
|
| 17 | + { |
|
| 18 | + return RefreshToken::active()->orderBy('id', 'desc')->first(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function createAccessToken(string $value) |
|
| 22 | - { |
|
| 23 | - return AccessToken::create([ |
|
| 24 | - 'value' => $value |
|
| 25 | - ]); |
|
| 26 | - } |
|
| 21 | + public function createAccessToken(string $value) |
|
| 22 | + { |
|
| 23 | + return AccessToken::create([ |
|
| 24 | + 'value' => $value |
|
| 25 | + ]); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function createRefreshToken(string $value) |
|
| 29 | - { |
|
| 30 | - return RefreshToken::create([ |
|
| 31 | - 'value' => $value |
|
| 32 | - ]); |
|
| 33 | - } |
|
| 28 | + public function createRefreshToken(string $value) |
|
| 29 | + { |
|
| 30 | + return RefreshToken::create([ |
|
| 31 | + 'value' => $value |
|
| 32 | + ]); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -8,69 +8,69 @@ |
||
| 8 | 8 | |
| 9 | 9 | class RefreshToken extends Token implements GrantsAccessTokens, PersistableToken |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The type of the token |
|
| 13 | - * |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - const TYPE = 'refresh_token'; |
|
| 11 | + /** |
|
| 12 | + * The type of the token |
|
| 13 | + * |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + const TYPE = 'refresh_token'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * The grant type of the token |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - const GRANT_TYPE = 'refresh_token'; |
|
| 18 | + /** |
|
| 19 | + * The grant type of the token |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + const GRANT_TYPE = 'refresh_token'; |
|
| 24 | 24 | |
| 25 | - public function getValue() |
|
| 26 | - { |
|
| 27 | - return $this->value; |
|
| 28 | - } |
|
| 25 | + public function getValue() |
|
| 26 | + { |
|
| 27 | + return $this->value; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public static function getType() |
|
| 31 | - { |
|
| 32 | - return self::TYPE; |
|
| 33 | - } |
|
| 30 | + public static function getType() |
|
| 31 | + { |
|
| 32 | + return self::TYPE; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public static function getGrantType() |
|
| 36 | - { |
|
| 37 | - return self::GRANT_TYPE; |
|
| 38 | - } |
|
| 35 | + public static function getGrantType() |
|
| 36 | + { |
|
| 37 | + return self::GRANT_TYPE; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function getExpiration() |
|
| 41 | - { |
|
| 42 | - return config('revolut.expire_api_access', false) |
|
| 43 | - ? self::PSD2expiration() |
|
| 44 | - : null; |
|
| 45 | - } |
|
| 40 | + public static function getExpiration() |
|
| 41 | + { |
|
| 42 | + return config('revolut.expire_api_access', false) |
|
| 43 | + ? self::PSD2expiration() |
|
| 44 | + : null; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Delete all expired refresh tokens |
|
| 49 | - * |
|
| 50 | - * @return int The number of deleted tokens |
|
| 51 | - */ |
|
| 52 | - public static function clearExpired() |
|
| 53 | - { |
|
| 54 | - $latest = self::latest()->select('id')->first(); |
|
| 47 | + /** |
|
| 48 | + * Delete all expired refresh tokens |
|
| 49 | + * |
|
| 50 | + * @return int The number of deleted tokens |
|
| 51 | + */ |
|
| 52 | + public static function clearExpired() |
|
| 53 | + { |
|
| 54 | + $latest = self::latest()->select('id')->first(); |
|
| 55 | 55 | |
| 56 | - return (int) self::where('id', '!=', $latest->id)->delete(); |
|
| 57 | - } |
|
| 56 | + return (int) self::where('id', '!=', $latest->id)->delete(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Calculate the expiration date |
|
| 61 | - * |
|
| 62 | - * An expiration should be set if the account is subject to PSD2 regulation, |
|
| 63 | - * under which access to the API expires after 90 days. |
|
| 64 | - * When access to the API expires, existing access tokens may be revoked. |
|
| 65 | - * The refresh token should be treated as expired premajurely, to prevent it from |
|
| 66 | - * being used to request access tokens which may be revoked before their default |
|
| 67 | - * lifetime has expired. |
|
| 68 | - * |
|
| 69 | - * @see https://developer.revolut.com/docs/business-api/#getting-started-usage-and-limits |
|
| 70 | - * @return \Carbon\Carbon |
|
| 71 | - */ |
|
| 72 | - private static function PSD2expiration() |
|
| 73 | - { |
|
| 74 | - return now()->addDays(90)->subMinutes(AccessToken::TTL); |
|
| 75 | - } |
|
| 59 | + /** |
|
| 60 | + * Calculate the expiration date |
|
| 61 | + * |
|
| 62 | + * An expiration should be set if the account is subject to PSD2 regulation, |
|
| 63 | + * under which access to the API expires after 90 days. |
|
| 64 | + * When access to the API expires, existing access tokens may be revoked. |
|
| 65 | + * The refresh token should be treated as expired premajurely, to prevent it from |
|
| 66 | + * being used to request access tokens which may be revoked before their default |
|
| 67 | + * lifetime has expired. |
|
| 68 | + * |
|
| 69 | + * @see https://developer.revolut.com/docs/business-api/#getting-started-usage-and-limits |
|
| 70 | + * @return \Carbon\Carbon |
|
| 71 | + */ |
|
| 72 | + private static function PSD2expiration() |
|
| 73 | + { |
|
| 74 | + return now()->addDays(90)->subMinutes(AccessToken::TTL); |
|
| 75 | + } |
|
| 76 | 76 | } |