Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gammamatrix committed Feb 25, 2024
1 parent 121b3c1 commit b8d25c2
Show file tree
Hide file tree
Showing 4 changed files with 425 additions and 10 deletions.
36 changes: 27 additions & 9 deletions config/playground-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,21 @@
|
| Options for Sanctum:
| - PLAYGROUND_AUTH_USER_PRIVILEGES - allow saving privileges in the user model.
| - PLAYGROUND_AUTH_VERIFY === privileges
| - PLAYGROUND_AUTH_VERIFY === sanctum
|
| Verification:
| - admin: $user->isAdmin()
| - policy: $user->can()
| - privileges: $user->hasPrivilege()
| - roles: $user->hasRole()
| - sanctum: $user->currentAccessToken()->can()
| - user: ! empty($user)
*/

/**
* @var string verify user|privileges|roles
* @var string verify admin|user|policy|privileges|roles|sanctum
*/
'verify' => env('PLAYGROUND_AUTH_VERIFY', 'privileges'),
'verify' => env('PLAYGROUND_AUTH_VERIFY', 'sanctum'),

/**
* @var bool sanctum Enable Sanctum
Expand All @@ -101,19 +108,22 @@
* @var bool hasRole Enable if the user model has $user->hasRole($role)
*/
'hasRole' => (bool) env('PLAYGROUND_AUTH_HAS_ROLE', false),
// 'hasRole' => (bool) env('PLAYGROUND_AUTH_HAS_ROLE', true),

/**
* @var bool userRole Enable if the user model has the attribute User::$role
*/
'userRole' => (bool) env('PLAYGROUND_AUTH_USER_ROLE', false),
// 'userRole' => (bool) env('PLAYGROUND_AUTH_USER_ROLE', true),

/**
* @var bool userRoles Enable if the user model has the attribute User::$roles
*/
'userRoles' => (bool) env('PLAYGROUND_AUTH_USER_ROLES', false),
// 'userRoles' => (bool) env('PLAYGROUND_AUTH_USER_ROLES', true),

/**
* @var string canDefault The default privilege for Auth\Can::class checks.
* A value is required for Sanctum checks.
*/
'canDefault' => env('PLAYGROUND_AUTH_CAN_DEFAULT', 'app'),

/*
|--------------------------------------------------------------------------
Expand All @@ -122,6 +132,8 @@
|
| Enabling Sanctum provides token and API key support.
|
| TODO We could/shoud add Passport support.
|
*/

'token' => [
Expand Down Expand Up @@ -150,20 +162,26 @@
* @var bool roles Check the user role(s) for applying abilities.
*/
'roles' => (bool) env('PLAYGROUND_AUTH_TOKEN_ROLES', false),
// 'roles' => (bool) env('PLAYGROUND_AUTH_TOKEN_ROLES', true),

/**
* @var bool privileges Allow the attribute User::$privileges to be used for authorization.
*/
'privileges' => (bool) env('PLAYGROUND_AUTH_TOKEN_PRIVILEGES', false),
// 'privileges' => (bool) env('PLAYGROUND_AUTH_TOKEN_PRIVILEGES', true),

/**
* @var bool sanctum The token will use Sanctum.
*/
'sanctum' => (bool) env('PLAYGROUND_AUTH_TOKEN_SANCTUM', true),
// 'sanctum' => (bool) env('PLAYGROUND_AUTH_TOKEN_SANCTUM', false),

/**
* @var bool session Save the token in the session.
*/
'session' => (bool) env('PLAYGROUND_AUTH_TOKEN_SESSION', false),

/**
* @var string session_name The session name for the token.
*/
'session_name' => env('PLAYGROUND_AUTH_TOKEN_SESSION_NAME', 'sanctum'),
],

/*
Expand Down
Loading

0 comments on commit b8d25c2

Please sign in to comment.