public function run() { foreach ($this->grants as $grant) { $thisGrant = new OAuthGrant(['id' => $grant]); $thisGrant->save(); } foreach ($this->scopes as $scopeName => $scopeDescription) { $thisScope = new OAuthScope(['id' => $scopeName, 'description' => $scopeDescription]); $thisScope->save(); } }
function updateAUserAvatar(APITester $I) { $client = factory(App\Models\OAuthClient::class, 1)->create(); $grant = \App\Models\OAuthGrant::find('password'); $client->oauth_grants()->attach($grant); $scopes = \App\Models\OAuthScope::all()->lists('id')->toArray(); $client->oauth_scopes()->attach($scopes); $I->wantTo('Update a user avatar'); }
function createAUserWithInvalidEmail(APITester $I) { $client = factory(App\Models\OAuthClient::class, 1)->create(); $grant = \App\Models\OAuthGrant::find('password'); $client->oauth_grants()->attach($grant); $scopes = \App\Models\OAuthScope::all()->lists('id')->toArray(); $client->oauth_scopes()->attach($scopes); $I->wantTo('See an error message when providing an incorrect email'); $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendPOST('users', ['username' => 'username', 'email' => 'testnotcorrect', 'password' => 'password', 'password_conf' => 'password']); $I->seeResponseCodeIs(400); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['status' => 'fail']); }
public function run() { DB::table("oauth_scopes")->delete(); OAuthScope::create(['id' => 'all', 'description' => '所有权限', 'level' => '3']); OAuthScope::create(['id' => 'all_read', 'description' => '所有读取权限', 'level' => '2']); OAuthScope::create(['id' => 'all_write', 'description' => '所有写入权限', 'level' => '2']); OAuthScope::create(['id' => 'user_info_read', 'description' => '读取用户信息', 'level' => '1']); OAuthScope::create(['id' => 'user_info_write', 'description' => '写入用户信息', 'level' => '1']); OAuthScope::create(['id' => 'app_info_read', 'description' => '读取应用信息', 'level' => '1']); OAuthScope::create(['id' => 'app_info_write', 'description' => '写入应用信息', 'level' => '1']); OAuthScope::create(['id' => 'message_info_read', 'description' => '读取消息信息', 'level' => '1']); OAuthScope::create(['id' => 'new_info_write', 'description' => '写入消息信息', 'level' => '1']); OAuthScope::create(['id' => 'news_info_read', 'description' => '读取动态信息', 'level' => '1']); OAuthScope::create(['id' => 'news_info_write', 'description' => '写入动态信息', 'level' => '1']); DB::table("oauth_clients")->delete(); OAuthClient::create(['id' => 'koala', 'secret' => '$2y$10$8Gz5X7XkQtVzwFU8C9zSQ.FzIH6OZNd5D', 'name' => 'Koala']); DB::table("oauth_client_endpoints")->delete(); OAuthClientEndPoint::create(['client_id' => 'koala', 'redirect_uri' => 'http://121.42.144.117:2111/connect/adam/callback']); DB::table("oauth_client_scopes")->delete(); OAuthClientScope::create(['client_id' => 'koala', 'scope_id' => 'all']); }
function obtainAuthCodeGrantRedirectsToLogin(ApiTester $I) { $client = factory(App\Models\OAuthClient::class, 1)->create(); $grant = \App\Models\OAuthGrant::find('authorization_code'); $client->oauth_grants()->attach($grant); $scope = \App\Models\OAuthScope::find('user_read'); $client->oauth_scopes()->attach($scope); $endpoint = factory(App\Models\OAuthClientEndpoint::class, 1)->make(); $endpoint->oauth_client()->associate($client); $endpoint->save(); $I->wantTo('Be redirected to login page when un authenticated user visits auth code page'); $I->amOnPage('authorize?client_id=' . $client->id . '&redirect_uri=' . $endpoint->redirect_uri . '&response_type=code&scope=user_read'); $I->seeInCurrentUrl('login'); }
public function getOAuthScopes() { $scopes = OAuthScope::all(); return response()->json($scopes); }
private function checkOAuthScope($scopeString) { $scopes = []; if ($scopeString !== null) { $scopes = explode(',', $scopeString); } $not_exists = []; foreach ($scopes as $scope_id) { $scope = OAuthScope::where('id', $scope_id)->first(); if (!$scope) { array_push($not_exists, $scope_id); } } return $not_exists; }