You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -286,11 +286,39 @@ public function boot()
286
286
$this->registerPolicies();
287
287
288
288
Auth::provider('dynamodb', function ($app, array $config) {
289
-
return new AuthUserProvider(new $config['model']);
289
+
return new AuthUserProvider(
290
+
$app['hash'],
291
+
$config['model'],
292
+
$config['api_token_name'] ?? null,
293
+
$config['api_token_index'] ?? null
294
+
);
290
295
});
291
296
}
292
297
```
293
298
299
+
### Modify LoginController
300
+
301
+
The default authentication uses the `email` and `password` column to validate, which is not the primary key of the table. However, DynamoDB needs to use the primary key to identify, so we need to tweak the LoginController a bit.
302
+
303
+
```php
304
+
namespace App\Http\Controllers\Auth;
305
+
306
+
class LoginController extends Controller
307
+
{
308
+
...
309
+
310
+
/**
311
+
* Get the login username to be used by the controller.
312
+
*
313
+
* @return string
314
+
*/
315
+
public function username()
316
+
{
317
+
return 'your-primary-key';
318
+
}
319
+
}
320
+
```
321
+
294
322
### Change auth config
295
323
296
324
Then specify driver and model name for authentication in `config/auth.php`.
@@ -307,10 +335,14 @@ Then specify driver and model name for authentication in `config/auth.php`.
307
335
'users' => [
308
336
'driver' => 'dynamodb',
309
337
'model' => App\User::class,
338
+
'api_token_name' => 'api_token',
339
+
'api_token_index' => 'api_token-index'
310
340
],
311
341
],
312
342
```
313
343
344
+
`api_token_name` and `api_token_index` are optional, but we need them if we use api token authentication.
Some applications might need to perform many kinds of queries, using a variety of different attributes as query criteria. To support these requirements, you can create one or more global secondary indexes and issue `query` requests against these indexes in Amazon DynamoDB.
0 commit comments