mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-07 01:30:06 +00:00
Started work on API token controls
- Added access-api permission. - Started user profile UI work. - Created database table and model for tokens. - Fixed incorrect templates down migration :(
This commit is contained in:
parent
04137e7c98
commit
d336ba6874
10 changed files with 143 additions and 15 deletions
database/migrations
|
@ -46,9 +46,9 @@ class AddTemplateSupport extends Migration
|
|||
|
||||
// Remove templates-manage permission
|
||||
$templatesManagePermission = DB::table('role_permissions')
|
||||
->where('name', '=', 'templates_manage')->first();
|
||||
->where('name', '=', 'templates-manage')->first();
|
||||
|
||||
DB::table('permission_role')->where('permission_id', '=', $templatesManagePermission->id)->delete();
|
||||
DB::table('role_permissions')->where('name', '=', 'templates_manage')->delete();
|
||||
DB::table('role_permissions')->where('name', '=', 'templates-manage')->delete();
|
||||
}
|
||||
}
|
||||
|
|
59
database/migrations/2019_12_29_120917_add_api_auth.php
Normal file
59
database/migrations/2019_12_29_120917_add_api_auth.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddApiAuth extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
// Add API tokens table
|
||||
Schema::create('api_tokens', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('client_id')->index();
|
||||
$table->string('client_secret');
|
||||
$table->integer('user_id')->unsigned()->index();
|
||||
$table->timestamp('expires_at')->index();
|
||||
$table->nullableTimestamps();
|
||||
});
|
||||
|
||||
// Add access-api permission
|
||||
$adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
|
||||
$permissionId = DB::table('role_permissions')->insertGetId([
|
||||
'name' => 'access-api',
|
||||
'display_name' => 'Access system API',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
]);
|
||||
DB::table('permission_role')->insert([
|
||||
'role_id' => $adminRoleId,
|
||||
'permission_id' => $permissionId
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Remove API tokens table
|
||||
Schema::dropIfExists('api_tokens');
|
||||
|
||||
// Remove access-api permission
|
||||
$apiAccessPermission = DB::table('role_permissions')
|
||||
->where('name', '=', 'access-api')->first();
|
||||
|
||||
DB::table('permission_role')->where('permission_id', '=', $apiAccessPermission->id)->delete();
|
||||
DB::table('role_permissions')->where('name', '=', 'access-api')->delete();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue