|
13 | 13 |
|
14 | 14 | beforeEach(function (): void { |
15 | 15 | $this->secret = uniqid(); |
| 16 | + $this->domain = uniqid() . '.auth0.com'; |
| 17 | + $this->clientId = uniqid(); |
| 18 | + $this->audience = [uniqid()]; |
| 19 | + $this->cookieSecret = uniqid(); |
16 | 20 |
|
17 | 21 | config([ |
18 | 22 | 'auth0.AUTH0_CONFIG_VERSION' => 2, |
19 | 23 | 'auth0.guards.default.strategy' => SdkConfiguration::STRATEGY_API, |
20 | | - 'auth0.guards.default.domain' => uniqid() . '.auth0.com', |
21 | | - 'auth0.guards.default.clientId' => uniqid(), |
22 | | - 'auth0.guards.default.audience' => [uniqid()], |
| 24 | + 'auth0.guards.default.domain' => $this->domain, |
| 25 | + 'auth0.guards.default.clientId' => $this->clientId, |
| 26 | + 'auth0.guards.default.audience' => $this->audience, |
23 | 27 | 'auth0.guards.default.clientSecret' => $this->secret, |
24 | | - 'auth0.guards.default.cookieSecret' => uniqid(), |
| 28 | + 'auth0.guards.default.cookieSecret' => $this->cookieSecret, |
25 | 29 | 'auth0.guards.default.tokenAlgorithm' => Token::ALGO_HS256, |
| 30 | + // Also configure 'web' since legacyGuard uses configuration => 'web' |
| 31 | + 'auth0.guards.web.strategy' => SdkConfiguration::STRATEGY_API, |
| 32 | + 'auth0.guards.web.domain' => $this->domain, |
| 33 | + 'auth0.guards.web.clientId' => $this->clientId, |
| 34 | + 'auth0.guards.web.audience' => $this->audience, |
| 35 | + 'auth0.guards.web.clientSecret' => $this->secret, |
| 36 | + 'auth0.guards.web.cookieSecret' => $this->cookieSecret, |
| 37 | + 'auth0.guards.web.tokenAlgorithm' => Token::ALGO_HS256, |
26 | 38 | ]); |
27 | 39 |
|
28 | 40 | $this->laravel = app('auth0'); |
|
74 | 86 | $token = Generator::create($this->secret, Token::ALGO_HS256, [ |
75 | 87 | "iss" => 'https://' . config('auth0.guards.default.domain') . '/', |
76 | 88 | "sub" => "auth0|123456", |
77 | | - "aud" => [ |
78 | | - "https://example.com/health-api", |
79 | | - "https://my-domain.auth0.com/userinfo", |
80 | | - config('auth0.guards.default.clientId') |
81 | | - ], |
| 89 | + "aud" => array_merge( |
| 90 | + $this->audience, |
| 91 | + [config('auth0.guards.default.clientId')] |
| 92 | + ), |
82 | 93 | "azp" => config('auth0.guards.default.clientId'), |
83 | 94 | "exp" => time() + 60, |
84 | 95 | "iat" => time(), |
|
103 | 114 | $token = Generator::create($this->secret, Token::ALGO_HS256, [ |
104 | 115 | "iss" => 'https://' . config('auth0.guards.default.domain') . '/', |
105 | 116 | "sub" => "auth0|123456", |
106 | | - "aud" => [ |
107 | | - "https://example.com/health-api", |
108 | | - "https://my-domain.auth0.com/userinfo", |
109 | | - config('auth0.guards.default.clientId') |
110 | | - ], |
| 117 | + "aud" => array_merge( |
| 118 | + $this->audience, |
| 119 | + [config('auth0.guards.default.clientId')] |
| 120 | + ), |
111 | 121 | "azp" => config('auth0.guards.default.clientId'), |
112 | 122 | "exp" => time() + 60, |
113 | 123 | "iat" => time(), |
|
132 | 142 | $token = Generator::create($this->secret, Token::ALGO_HS256, [ |
133 | 143 | "iss" => 'https://' . config('auth0.guards.default.domain') . '/', |
134 | 144 | "sub" => "auth0|123456", |
135 | | - "aud" => [ |
136 | | - "https://example.com/health-api", |
137 | | - "https://my-domain.auth0.com/userinfo", |
138 | | - config('auth0.guards.default.clientId') |
139 | | - ], |
| 145 | + "aud" => array_merge( |
| 146 | + $this->audience, |
| 147 | + [config('auth0.guards.default.clientId')] |
| 148 | + ), |
140 | 149 | "azp" => config('auth0.guards.default.clientId'), |
141 | 150 | "exp" => time() + 60, |
142 | 151 | "iat" => time(), |
|
0 commit comments