Skip to content

Commit f965e5f

Browse files
[9.x] Document prompt parameter when redirecting for authorization (#8193)
* document prompt parameter when redirecting for authorization * formatting Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 7c98ae8 commit f965e5f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

passport.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,26 +371,33 @@ Once a client has been created, developers may use their client ID and secret to
371371
'response_type' => 'code',
372372
'scope' => '',
373373
'state' => $state,
374+
// 'prompt' => '', // "none", "consent", or "login"
374375
]);
375376

376377
return redirect('http://passport-app.test/oauth/authorize?'.$query);
377378
});
378379

380+
The `prompt` parameter may be used to specify the authentication behavior of the Passport application.
381+
382+
If the value is `none`, Passport will always throw an authentication error if the user is not already authenticated with the Passport application. If the value is `consent`, Passport will always display the authorization approval screen, even if all scopes were previously granted to the consuming application. When the value is `login`, the Passport application will always prompt the user to re-login to the application, even if they already have an existing session.
383+
384+
If no `prompt` value is provided, the user will be prompted for authorization only if they have not previously authorized access to the consuming application for the requested scopes.
385+
379386
> **Note**
380387
> Remember, the `/oauth/authorize` route is already defined by Passport. You do not need to manually define this route.
381388
382389
<a name="approving-the-request"></a>
383390
#### Approving The Request
384391

385-
When receiving authorization requests, Passport will automatically display a template to the user allowing them to approve or deny the authorization request. If they approve the request, they will be redirected back to the `redirect_uri` that was specified by the consuming application. The `redirect_uri` must match the `redirect` URL that was specified when the client was created.
392+
When receiving authorization requests, Passport will automatically respond based on the value of `prompt` parameter (if present) and may display a template to the user allowing them to approve or deny the authorization request. If they approve the request, they will be redirected back to the `redirect_uri` that was specified by the consuming application. The `redirect_uri` must match the `redirect` URL that was specified when the client was created.
386393

387394
If you would like to customize the authorization approval screen, you may publish Passport's views using the `vendor:publish` Artisan command. The published views will be placed in the `resources/views/vendor/passport` directory:
388395

389396
```shell
390397
php artisan vendor:publish --tag=passport-views
391398
```
392399

393-
Sometimes you may wish to skip the authorization prompt, such as when authorizing a first-party client. You may accomplish this by [extending the `Client` model](#overriding-default-models) and defining a `skipsAuthorization` method. If `skipsAuthorization` returns `true` the client will be approved and the user will be redirected back to the `redirect_uri` immediately:
400+
Sometimes you may wish to skip the authorization prompt, such as when authorizing a first-party client. You may accomplish this by [extending the `Client` model](#overriding-default-models) and defining a `skipsAuthorization` method. If `skipsAuthorization` returns `true` the client will be approved and the user will be redirected back to the `redirect_uri` immediately, unless the consuming application has explicitly set the `prompt` parameter when redirecting for authorization:
394401

395402
<?php
396403

@@ -591,6 +598,7 @@ Once a client has been created, you may use the client ID and the generated code
591598
'state' => $state,
592599
'code_challenge' => $codeChallenge,
593600
'code_challenge_method' => 'S256',
601+
// 'prompt' => '', // "none", "consent", or "login"
594602
]);
595603

596604
return redirect('http://passport-app.test/oauth/authorize?'.$query);
@@ -778,6 +786,7 @@ Once the grant has been enabled, developers may use their client ID to request a
778786
'response_type' => 'token',
779787
'scope' => '',
780788
'state' => $state,
789+
// 'prompt' => '', // "none", "consent", or "login"
781790
]);
782791

783792
return redirect('http://passport-app.test/oauth/authorize?'.$query);

0 commit comments

Comments
 (0)