@@ -10,74 +10,74 @@ |
||
10 | 10 | |
11 | 11 | class JWTCommand extends Command |
12 | 12 | { |
13 | - /** |
|
14 | - * The name and signature of the console command. |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
13 | + /** |
|
14 | + * The name and signature of the console command. |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * The console command description. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
20 | + /** |
|
21 | + * The console command description. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Execute the console command. |
|
29 | - * |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function handle() |
|
33 | - { |
|
34 | - // build the JWT |
|
35 | - $jwt = $this->buildJWT(); |
|
27 | + /** |
|
28 | + * Execute the console command. |
|
29 | + * |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function handle() |
|
33 | + { |
|
34 | + // build the JWT |
|
35 | + $jwt = $this->buildJWT(); |
|
36 | 36 | |
37 | - $this->info('Your JSON web token was created successfully:'); |
|
38 | - $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
37 | + $this->info('Your JSON web token was created successfully:'); |
|
38 | + $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
39 | 39 | |
40 | - // optionally, verify the key |
|
41 | - $key = $this->checkPublicKey($this->option('public') ?? null); |
|
40 | + // optionally, verify the key |
|
41 | + $key = $this->checkPublicKey($this->option('public') ?? null); |
|
42 | 42 | |
43 | - $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
43 | + $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
44 | 44 | |
45 | - $headers = ['parameter', 'value']; |
|
46 | - $data = [ |
|
47 | - ['issuer', $decoded->iss], |
|
48 | - ['subject', $decoded->sub], |
|
49 | - ['expiry', $decoded->exp], |
|
50 | - ['audience', $decoded->aud], |
|
51 | - ]; |
|
45 | + $headers = ['parameter', 'value']; |
|
46 | + $data = [ |
|
47 | + ['issuer', $decoded->iss], |
|
48 | + ['subject', $decoded->sub], |
|
49 | + ['expiry', $decoded->exp], |
|
50 | + ['audience', $decoded->aud], |
|
51 | + ]; |
|
52 | 52 | |
53 | - $this->info('Your JWT has been verified and is valid.'); |
|
54 | - $this->table($headers, $data); |
|
55 | - } |
|
53 | + $this->info('Your JWT has been verified and is valid.'); |
|
54 | + $this->table($headers, $data); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - private function buildJWT() |
|
61 | - { |
|
62 | - try { |
|
63 | - $clientAssertion = resolve(ClientAssertion::class); |
|
64 | - return $clientAssertion->build(); |
|
65 | - } catch (ConfigurationException $e) { |
|
66 | - $this->error($e->getMessage()); |
|
67 | - exit; |
|
68 | - } |
|
69 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + private function buildJWT() |
|
61 | + { |
|
62 | + try { |
|
63 | + $clientAssertion = resolve(ClientAssertion::class); |
|
64 | + return $clientAssertion->build(); |
|
65 | + } catch (ConfigurationException $e) { |
|
66 | + $this->error($e->getMessage()); |
|
67 | + exit; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function checkPublicKey($key = null) |
|
75 | - { |
|
76 | - try { |
|
77 | - return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your private key')); |
|
78 | - } catch (Exception $e) { |
|
79 | - $this->error($e->getMessage()); |
|
80 | - return $this->checkPublicKey(); |
|
81 | - } |
|
82 | - } |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function checkPublicKey($key = null) |
|
75 | + { |
|
76 | + try { |
|
77 | + return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your private key')); |
|
78 | + } catch (Exception $e) { |
|
79 | + $this->error($e->getMessage()); |
|
80 | + return $this->checkPublicKey(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | | authorization process. |
24 | 24 | | |
25 | 25 | */ |
26 | - 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
26 | + 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
27 | 27 | |
28 | - /* |
|
28 | + /* |
|
29 | 29 | |-------------------------------------------------------------------------- |
30 | 30 | | Client ID |
31 | 31 | |-------------------------------------------------------------------------- |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | | selecting the relevant API certificate. |
36 | 36 | | |
37 | 37 | */ |
38 | - 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
38 | + 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | |-------------------------------------------------------------------------- |
42 | 42 | | Oauth Redirect URI |
43 | 43 | |-------------------------------------------------------------------------- |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | | process. This must match the uri provided to Revolut. |
47 | 47 | | |
48 | 48 | */ |
49 | - 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
49 | + 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
50 | 50 | |
51 | - /* |
|
51 | + /* |
|
52 | 52 | |-------------------------------------------------------------------------- |
53 | 53 | | Encryption |
54 | 54 | |-------------------------------------------------------------------------- |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | | production environment |
59 | 59 | | |
60 | 60 | */ |
61 | - 'encrypt_tokens' => true, |
|
61 | + 'encrypt_tokens' => true, |
|
62 | 62 | |
63 | - /* |
|
63 | + /* |
|
64 | 64 | |-------------------------------------------------------------------------- |
65 | 65 | | Tokens table |
66 | 66 | |-------------------------------------------------------------------------- |
@@ -68,5 +68,5 @@ discard block |
||
68 | 68 | | Set the name of the table that will hold your Revolut tokens. |
69 | 69 | | |
70 | 70 | */ |
71 | - 'tokens_table' => 'revolut_tokens' |
|
71 | + 'tokens_table' => 'revolut_tokens' |
|
72 | 72 | ]; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | // if the state doesn't match the latest state, abort |
23 | - if($tokenManager->getState()->value != request('state')) { |
|
23 | + if ($tokenManager->getState()->value != request('state')) { |
|
24 | 24 | abort(405, 'Invalid State'); |
25 | 25 | } |
26 | 26 |
@@ -18,15 +18,15 @@ |
||
18 | 18 | $model->is_encrypted = true; |
19 | 19 | $model->value = $model->encryptValue(); |
20 | 20 | } |
21 | - }); |
|
21 | + }); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | - * Get the decrypted value attribute. |
|
26 | - * |
|
27 | - * @param string $value |
|
28 | - * @return string |
|
29 | - */ |
|
25 | + * Get the decrypted value attribute. |
|
26 | + * |
|
27 | + * @param string $value |
|
28 | + * @return string |
|
29 | + */ |
|
30 | 30 | public function getValueAttribute($value) |
31 | 31 | { |
32 | 32 | return $this->is_encrypted ? $this->decryptValue() : $value; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public static function bootEncryptable() |
15 | 15 | { |
16 | - static::saving(function ($model) { |
|
16 | + static::saving(function($model) { |
|
17 | 17 | if (config('revolut.encrypt_tokens', true)) { |
18 | 18 | $model->is_encrypted = true; |
19 | 19 | $model->value = $model->encryptValue(); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | protected $fillable = ['value']; |
26 | 26 | |
27 | 27 | /** |
28 | - * The attributes that should be cast to native types. |
|
29 | - * |
|
30 | - * @var array |
|
31 | - */ |
|
28 | + * The attributes that should be cast to native types. |
|
29 | + * |
|
30 | + * @var array |
|
31 | + */ |
|
32 | 32 | protected $casts = [ |
33 | 33 | 'is_encrypted' => 'boolean', |
34 | 34 | 'expires_at' => 'datetime', |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | ]; |
37 | 37 | |
38 | 38 | /** |
39 | - * The "booting" method of the model. |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - protected static function boot() |
|
44 | - { |
|
39 | + * The "booting" method of the model. |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + protected static function boot() |
|
44 | + { |
|
45 | 45 | parent::boot(); |
46 | 46 | |
47 | 47 | static::creating(function($model) { |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | $model->expires_at = static::getExpiration(); |
50 | 50 | }); |
51 | 51 | |
52 | - static::addGlobalScope('type', function(Builder $builder) { |
|
53 | - $builder->whereType(static::getType()); |
|
52 | + static::addGlobalScope('type', function(Builder $builder) { |
|
53 | + $builder->whereType(static::getType()); |
|
54 | 54 | }); |
55 | 55 | } |
56 | 56 |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class CreateRevolutTokensTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create(config('revolut.tokens_table'), function (Blueprint $table) { |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create(config('revolut.tokens_table'), function (Blueprint $table) { |
|
17 | 17 | $table->unsignedBigInteger('id'); |
18 | 18 | $table->string('type'); |
19 | - $table->mediumText('value'); |
|
20 | - $table->boolean('is_encrypted')->default(false); |
|
19 | + $table->mediumText('value'); |
|
20 | + $table->boolean('is_encrypted')->default(false); |
|
21 | 21 | $table->timestamp('expires_at')->nullable(); |
22 | - $table->timestamp('created_at')->useCurrent(); |
|
23 | - }); |
|
24 | - } |
|
22 | + $table->timestamp('created_at')->useCurrent(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists(config('revolut.tokens_table')); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists(config('revolut.tokens_table')); |
|
34 | + } |
|
35 | 35 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create(config('revolut.tokens_table'), function (Blueprint $table) { |
|
16 | + Schema::create(config('revolut.tokens_table'), function(Blueprint $table) { |
|
17 | 17 | $table->unsignedBigInteger('id'); |
18 | 18 | $table->string('type'); |
19 | 19 | $table->mediumText('value'); |