Skip to content

Commit

Permalink
update native auth
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Feb 25, 2023
1 parent 5460aa4 commit ee43c75
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Auth/NativeAuthServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function validate(string $accessToken): NativeAuthValidateResult {

$hasAcceptedOrigins = count($this->acceptedOrigins) > 0;
$isInvalidOrigin = !in_array($decoded->origin, $this->acceptedOrigins) && !in_array('https://' . $decoded->origin, $this->acceptedOrigins);
throw_if($hasAcceptedOrigins && $isInvalidOrigin, InvalidArgumentException::class, 'invalid origin');
throw_if($hasAcceptedOrigins && $isInvalidOrigin, InvalidArgumentException::class, "invalid origin: {$decoded->origin}");

// TODO: implement block timestamp & ttl verification:
// https://github.com/multiversx/mx-sdk-js-native-auth-server/blob/5707b04c3d1e40088a1cbe12c3b51fdd6a8ada90/src/native.auth.server.ts#L98
Expand Down
2 changes: 1 addition & 1 deletion src/Multiversx.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Multiversx extends MultiversxBase
public static function verifyNativeAuthToken(string $accessToken): NativeAuthValidateResult
{
$nativeAuth = new NativeAuthServer(
apiUrl: config('multiversx.native_auth.api_url') ?? throw new Exception('missing native auth config: api_url'),
apiUrl: config('multiversx.urls.api') ?? throw new Exception('missing config: urls.api'),
acceptedOrigins: config('multiversx.native_auth.accepted_origins') ?? throw new Exception('missing native auth config: accepted_origins'),
maxExpirySeconds: config('multiversx.native_auth.max_expiry_seconds') ?? throw new Exception('missing native auth config: max_expiry_seconds'),
skipLegacyValidation: config('multiversx.native_auth.skip_legacy_validation') ?? throw new Exception('missing native auth config: skip_legacy_validation'),
Expand Down
2 changes: 0 additions & 2 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
],

'native_auth' => [
'api_url' => env('MULTIVERSX_NATIVEAUTH_APIURL', 'https://api.multiversx.com'),

'accepted_origins' => [
'https://api.multiversx.com',
],
Expand Down

0 comments on commit ee43c75

Please sign in to comment.