Skip to content

Commit 1eb9f37

Browse files
committed
Make consumer of user info configurable
1 parent 7b6eca8 commit 1eb9f37

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

config/config.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313

1414
// The base URL for the user service
1515
'user_api_base_url' => env('AUTH0_USER_API'),
16+
17+
// The consumer name for the user data
18+
'user_api_consumer' => env('AUTH0_USER_API_CONSUMER', 'auth0'),
1619
];

src/GsvAuth0ProviderServiceProvider.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public function register()
3232

3333
// Register the user service
3434
$this->app->singleton('gsv-auth0-user-service', function () {
35-
return new UserService(config('gsv-auth0-provider.user_api_base_url'));
35+
return new UserService(
36+
config('gsv-auth0-provider.user_api_base_url'),
37+
config('gsv-auth0-provider.user_api_consumer')
38+
);
3639
});
3740

3841
// Open the gates

src/UserService.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ class UserService
1111
*/
1212
protected $baseUrl;
1313

14+
/**
15+
* @var string
16+
*/
17+
protected $consumer;
18+
1419
/**
1520
* @var string
1621
*/
1722
protected string $token;
1823

19-
public function __construct(?string $baseUrl = null)
24+
public function __construct(?string $baseUrl = null, ?string $consumer = null)
2025
{
2126
$this->baseUrl = $baseUrl;
27+
$this->consumer = $consumer;
2228
}
2329

2430
/**
@@ -83,8 +89,7 @@ public function fetch()
8389
}
8490

8591
return Http::withToken($this->token)
86-
->withoutVerifying()
87-
->get($this->baseUrl . '/api/users/auth0')
92+
->get(sprintf('%s/api/users/%s', $this->baseUrl, $this->consumer))
8893
->json();
8994
}
9095
}

0 commit comments

Comments
 (0)