-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#34722] Add Authentication and Authorization to api routes (#90)
* initial sanctum setup and concept api controller protection * add sanctum middleware to api group, update controllers to protect routes, update axios bootstrapping * add reconcile to methods allowed on concept controller without auth * add role and permission models to application * update isVocabularyEditor to use Permission model * [#34722] add phpunit cache to gitignore * [#34722] Scaffold out Concepts Authorization * feat: Set up authorization for Concept model using policies and tests * update user factory for Laravel 11 * fix: Clean up example tests and concept test, simplify concept api controller * feat: Factories and model bindings for Term, Concept, and User * formatting fix * feat: Working concept testing * feat: Create interactive artisan command to add user with role * chore: concepts api controller comment cleanup * feat: Add TermPolicy for managing terms and conditions access * feat: Add authorization for Term API in policy and controller * refactor: Update TermController to use type hinting for Term model * fix: update return status for concept deletion * feat: Add Term API testing * refactor: Update TermController authorization * feat: Add resource authorization to ConceptSourceController * refactor: Update method signatures to type hint ConceptSource model * feat: Add ConceptSources API testing * fix: Update type hinting to use correct variable name
- Loading branch information
Showing
35 changed files
with
1,280 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
.phpunit.cache | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Models\User; | ||
use App\Models\Role; | ||
|
||
class AddUser extends Command | ||
{ | ||
protected $signature = 'user:add'; | ||
|
||
protected $description = 'Add a new user with a role'; | ||
|
||
public function handle() | ||
{ | ||
$firstName = $this->ask('Enter the user\'s first name'); | ||
$lastName = $this->ask('Enter the user\'s last name'); | ||
$email = $this->ask('Enter the user\'s email'); | ||
|
||
// Fetch available roles | ||
$roles = Role::all()->pluck('label')->toArray(); | ||
$role = $this->choice('Select a role for the user', $roles); | ||
|
||
// Create the user | ||
$user = User::create([ | ||
'first' => $firstName, | ||
'last' => $lastName, | ||
'fullname' => "{$firstName} {$lastName}", | ||
'email' => $email, | ||
'username' => $email, | ||
]); | ||
|
||
// Assign the role to the user | ||
$user->assignRole($role); // Ensure you have a method to assign roles | ||
|
||
$this->info("User {$firstName} {$lastName} with role {$role} has been created successfully."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.