[smarcet] - #5032 - Client Registration
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use oauth2\services\IApiScopeService;
|
||||
use oauth2\services\IClientService;
|
||||
use oauth2\services\IMementoOAuth2AuthenticationRequestService;
|
||||
use openid\requests\OpenIdAuthenticationRequest;
|
||||
use openid\services\IMementoOpenIdRequestService;
|
||||
use openid\services\IServerConfigurationService;
|
||||
@ -9,14 +12,12 @@ use openid\XRDS\XRDSDocumentBuilder;
|
||||
use services\IPHelper;
|
||||
use services\IUserActionService;
|
||||
use strategies\DefaultLoginStrategy;
|
||||
use strategies\OAuth2ConsentStrategy;
|
||||
use strategies\OAuth2LoginStrategy;
|
||||
use strategies\OpenIdConsentStrategy;
|
||||
use strategies\OpenIdLoginStrategy;
|
||||
use utils\services\IAuthService;
|
||||
use oauth2\services\IMementoOAuth2AuthenticationRequestService;
|
||||
use strategies\OAuth2LoginStrategy;
|
||||
use strategies\OAuth2ConsentStrategy;
|
||||
use oauth2\services\IClientService;
|
||||
use oauth2\services\IApiScopeService;
|
||||
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
@ -31,6 +32,7 @@ class UserController extends BaseController
|
||||
private $login_strategy;
|
||||
private $consent_strategy;
|
||||
private $client_service;
|
||||
private $scope_service;
|
||||
|
||||
public function __construct(IMementoOpenIdRequestService $openid_memento_service,
|
||||
IMementoOAuth2AuthenticationRequestService $oauth2_memento_service,
|
||||
@ -43,15 +45,16 @@ class UserController extends BaseController
|
||||
IClientService $client_service,
|
||||
IApiScopeService $scope_service)
|
||||
{
|
||||
$this->openid_memento_service = $openid_memento_service;
|
||||
$this->oauth2_memento_service = $oauth2_memento_service;
|
||||
$this->auth_service = $auth_service;
|
||||
$this->openid_memento_service = $openid_memento_service;
|
||||
$this->oauth2_memento_service = $oauth2_memento_service;
|
||||
$this->auth_service = $auth_service;
|
||||
$this->server_configuration_service = $server_configuration_service;
|
||||
$this->trusted_sites_service = $trusted_sites_service;
|
||||
$this->discovery = $discovery;
|
||||
$this->user_service = $user_service;
|
||||
$this->user_action_service = $user_action_service;
|
||||
$this->client_service = $client_service;
|
||||
$this->trusted_sites_service = $trusted_sites_service;
|
||||
$this->discovery = $discovery;
|
||||
$this->user_service = $user_service;
|
||||
$this->user_action_service = $user_action_service;
|
||||
$this->client_service = $client_service;
|
||||
$this->scope_service = $scope_service;
|
||||
//filters
|
||||
$this->beforeFilter('csrf', array('only' => array('postLogin', 'postConsent')));
|
||||
|
||||
@ -61,17 +64,16 @@ class UserController extends BaseController
|
||||
//openid stuff
|
||||
$this->beforeFilter('openid.save.request');
|
||||
$this->beforeFilter('openid.needs.auth.request', array('only' => array('getConsent')));
|
||||
$this->login_strategy = new OpenIdLoginStrategy($openid_memento_service, $user_action_service, $auth_service);
|
||||
$this->login_strategy = new OpenIdLoginStrategy($openid_memento_service, $user_action_service, $auth_service);
|
||||
$this->consent_strategy = new OpenIdConsentStrategy($openid_memento_service, $auth_service, $server_configuration_service, $user_action_service);
|
||||
}
|
||||
else if(!is_null($oauth2_msg) && $oauth2_msg->isValid()){
|
||||
} else if (!is_null($oauth2_msg) && $oauth2_msg->isValid()) {
|
||||
$this->beforeFilter('oauth2.save.request');
|
||||
$this->beforeFilter('oauth2.needs.auth.request', array('only' => array('getConsent')));
|
||||
$this->login_strategy = new OAuth2LoginStrategy();
|
||||
$this->consent_strategy = new OAuth2ConsentStrategy($auth_service,$oauth2_memento_service,$scope_service,$client_service);
|
||||
$this->login_strategy = new OAuth2LoginStrategy();
|
||||
$this->consent_strategy = new OAuth2ConsentStrategy($auth_service, $oauth2_memento_service, $scope_service, $client_service);
|
||||
} else {
|
||||
//default stuff
|
||||
$this->login_strategy = new DefaultLoginStrategy($user_action_service, $auth_service);
|
||||
$this->login_strategy = new DefaultLoginStrategy($user_action_service, $auth_service);
|
||||
$this->consent_strategy = null;
|
||||
}
|
||||
|
||||
@ -200,21 +202,21 @@ class UserController extends BaseController
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
$user = $this->auth_service->getCurrentUser();
|
||||
$sites = $this->trusted_sites_service->getAllTrustedSitesByUser($user);
|
||||
$user = $this->auth_service->getCurrentUser();
|
||||
$sites = $this->trusted_sites_service->getAllTrustedSitesByUser($user);
|
||||
$actions = $user->getActions();
|
||||
$clients = $user->getClients();
|
||||
|
||||
return View::make("profile", array(
|
||||
"username" => $user->getFullName(),
|
||||
"openid_url" => $this->server_configuration_service->getUserIdentityEndpointURL($user->getIdentifier()),
|
||||
"identifier " => $user->getIdentifier(),
|
||||
"sites" => $sites,
|
||||
"show_pic" => $user->getShowProfilePic(),
|
||||
"username" => $user->getFullName(),
|
||||
"openid_url" => $this->server_configuration_service->getUserIdentityEndpointURL($user->getIdentifier()),
|
||||
"identifier " => $user->getIdentifier(),
|
||||
"sites" => $sites,
|
||||
"show_pic" => $user->getShowProfilePic(),
|
||||
"show_full_name" => $user->getShowProfileFullName(),
|
||||
"show_email" => $user->getShowProfileEmail(),
|
||||
'actions' => $actions,
|
||||
'clients' => $clients,
|
||||
"show_email" => $user->getShowProfileEmail(),
|
||||
'actions' => $actions,
|
||||
'clients' => $clients,
|
||||
));
|
||||
}
|
||||
|
||||
@ -234,16 +236,152 @@ class UserController extends BaseController
|
||||
return Redirect::action("UserController@getProfile");
|
||||
}
|
||||
|
||||
public function getEditRegisteredClient($id){
|
||||
public function getEditRegisteredClient($id)
|
||||
{
|
||||
$client = $this->client_service->getClientByIdentifier($id);
|
||||
|
||||
if (is_null($client)) {
|
||||
Log::warning(sprintf("invalid oauth2 client id %s", $id));
|
||||
return View::make("404");
|
||||
}
|
||||
|
||||
$allowed_uris = $client->getClientRegisteredUris();
|
||||
$selected_scopes = $client->getClientScopes();
|
||||
$aux_scopes = array();
|
||||
foreach ($selected_scopes as $scope) {
|
||||
array_push($aux_scopes, $scope->id);
|
||||
}
|
||||
$scopes = $this->scope_service->getAvailableScopes();
|
||||
|
||||
return View::make("edit-registered-client",
|
||||
array('client' => $client,
|
||||
'allowed_uris' => $allowed_uris,
|
||||
'selected_scopes' => $aux_scopes,
|
||||
'scopes' => $scopes
|
||||
));
|
||||
}
|
||||
|
||||
public function getDeleteRegisteredClient($id)
|
||||
{
|
||||
return 'error';
|
||||
}
|
||||
|
||||
public function getDeleteRegisteredClient($id){
|
||||
return 'error';
|
||||
public function postAddRegisteredClient()
|
||||
{
|
||||
try {
|
||||
$input = Input::All();
|
||||
$user = $this->auth_service->getCurrentUser();
|
||||
// todo: check application unique name
|
||||
// Build the validation constraint set.
|
||||
$rules = array(
|
||||
'app_name' => 'required',
|
||||
'app_desc' => 'required',
|
||||
'app_type' => 'required',
|
||||
);
|
||||
|
||||
// Create a new validator instance.
|
||||
$validator = Validator::make($input, $rules);
|
||||
|
||||
if ($validator->passes()) {
|
||||
$app_name = trim($input['app_name']);
|
||||
$app_desc = trim($input['app_desc']);
|
||||
$app_type = $input['app_type'];
|
||||
$this->client_service->addClient($app_type, $user->getId(), $app_name, $app_desc, '');
|
||||
return Response::json(array('status' => 'OK'));
|
||||
}
|
||||
|
||||
throw new Exception("invalid param!");
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return Response::json(array('status' => 'ERROR'));
|
||||
}
|
||||
}
|
||||
|
||||
public function postAddRegisteredClient(){
|
||||
//$this->client_service->addClient()
|
||||
return 'error';
|
||||
public function postAddAllowedRedirectUri()
|
||||
{
|
||||
try {
|
||||
$input = Input::All();
|
||||
// Build the validation constraint set.
|
||||
$rules = array(
|
||||
'redirect_uri' => 'url',
|
||||
'client_id' => 'required',
|
||||
);
|
||||
|
||||
$messages = array(
|
||||
'url' => 'You must give a valid url'
|
||||
);
|
||||
|
||||
// Create a new validator instance.
|
||||
$validator = Validator::make($input, $rules, $messages);
|
||||
if ($validator->passes()) {
|
||||
$this->client_service->addClientAllowedUri($input['client_id'], $input['redirect_uri']);
|
||||
return Redirect::back();
|
||||
} else {
|
||||
return Redirect::back()
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return View::make("404");
|
||||
}
|
||||
}
|
||||
|
||||
public function getDeleteClientAllowedUri($id, $uri_id)
|
||||
{
|
||||
try {
|
||||
$this->client_service->deleteClientAllowedUri($id, $uri_id);
|
||||
return Redirect::back();
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return View::make("404");
|
||||
}
|
||||
}
|
||||
|
||||
public function getRegenerateClientSecret($id)
|
||||
{
|
||||
try {
|
||||
$this->client_service->regenerateClientSecret($id);
|
||||
return Redirect::back();
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return View::make("404");
|
||||
}
|
||||
}
|
||||
|
||||
public function postAddAllowedScope()
|
||||
{
|
||||
try {
|
||||
$input = Input::All();
|
||||
$user = $this->auth_service->getCurrentUser();
|
||||
|
||||
// Build the validation constraint set.
|
||||
$rules = array(
|
||||
'id' => 'required',
|
||||
'checked' => 'required',
|
||||
'client_id' => 'required',
|
||||
);
|
||||
|
||||
// Create a new validator instance.
|
||||
$validator = Validator::make($input, $rules);
|
||||
if ($validator->passes()) {
|
||||
$client_id = $input['client_id'];
|
||||
$client = $this->client_service->getClientByIdentifier($client_id);
|
||||
if(is_null($client) || $client->getUserId()!==$user->getId())
|
||||
throw new Exception('invalid client id for current user');
|
||||
$checked = $input['checked'];
|
||||
$scope_id = $input['id'];
|
||||
if($checked){
|
||||
$this->client_service->addClientScope($client_id,$scope_id);
|
||||
}
|
||||
else{
|
||||
$this->client_service->deleteClientScope($client_id,$scope_id);
|
||||
}
|
||||
return Response::json(array('status' => 'OK'));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return Response::json(array('status' => 'ERROR'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ class CreateOauth2ClientsTable extends Migration {
|
||||
$table->string('app_name',255)->unique();
|
||||
$table->text('app_description');
|
||||
$table->string('app_logo',255);
|
||||
$table->string('client_id',32)->unique();
|
||||
$table->string('client_secret',64)->unique();
|
||||
$table->string('client_id',255)->unique();
|
||||
$table->string('client_secret',255)->unique();
|
||||
$table->smallInteger('client_type');
|
||||
$table->boolean('active');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->bigInteger("user_id")->unsigned();
|
||||
$table->index('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('openid_users');
|
||||
|
@ -17,7 +17,9 @@ class CreateOauth2ApiScope extends Migration {
|
||||
$table->string('name',512);
|
||||
$table->string('short_description',512);
|
||||
$table->text('description');
|
||||
$table->boolean('active');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->boolean('default')->default(false);
|
||||
$table->boolean('system')->default(false);
|
||||
$table->timestamps();
|
||||
$table->bigInteger("api_id")->unsigned();
|
||||
$table->index('api_id');
|
||||
|
@ -12,6 +12,7 @@ interface IClient {
|
||||
public function getClientId();
|
||||
public function getClientSecret();
|
||||
public function getClientType();
|
||||
public function getFriendlyClientType();
|
||||
public function getClientAuthorizedRealms();
|
||||
public function getClientScopes();
|
||||
public function getClientRegisteredUris();
|
||||
@ -22,4 +23,5 @@ interface IClient {
|
||||
public function getApplicationLogo();
|
||||
public function getApplicationDescription();
|
||||
public function getDeveloperEmail();
|
||||
public function getUserId();
|
||||
}
|
@ -7,4 +7,9 @@ interface IApiScopeService {
|
||||
* @return mixed
|
||||
*/
|
||||
public function getScopesByName(array $scopes_names);
|
||||
|
||||
/** get all active scopes
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAvailableScopes();
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace oauth2\services;
|
||||
|
||||
use oauth2\models\IClient;
|
||||
|
||||
/**
|
||||
* Interface IClientService
|
||||
* @package oauth2\services
|
||||
*/
|
||||
interface IClientService {
|
||||
/**
|
||||
* @param $client_id
|
||||
@ -18,12 +21,33 @@ interface IClientService {
|
||||
public function getCurrentClientAuthInfo();
|
||||
|
||||
public function getClientByIdentifier($id);
|
||||
public function addClient($client_id, $client_secret,$client_type, $user_id, $app_name, $app_description, $app_logo=null);
|
||||
public function addClient($client_type, $user_id, $app_name, $app_description, $app_logo='');
|
||||
public function addClientScope($id,$scope_id);
|
||||
public function deleteClientScope($id,$scope_id);
|
||||
|
||||
/**
|
||||
* Add a new allowed redirection uri
|
||||
* @param $id client id
|
||||
* @param $uri allowed redirection uri
|
||||
* @return mixed
|
||||
*/
|
||||
public function addClientAllowedUri($id,$uri);
|
||||
public function deleteClientAllowedUri($id,$uri);
|
||||
|
||||
/**
|
||||
* Deletes a former client allowed redirection Uri
|
||||
* @param $id client identifier
|
||||
* @param $uri_id uri identifier
|
||||
*/
|
||||
public function deleteClientAllowedUri($id,$uri_id);
|
||||
|
||||
public function addClientAllowedRealm($id,$realm);
|
||||
public function deleteClientAllowedRealm($id,$realm);
|
||||
public function deleteClientAllowedRealm($id,$realm_id);
|
||||
public function deleteClientByIdentifier($id);
|
||||
|
||||
/**
|
||||
* Regenerates Client Secret
|
||||
* @param $id client id
|
||||
* @return mixed
|
||||
*/
|
||||
public function regenerateClientSecret($id);
|
||||
}
|
@ -5,6 +5,16 @@ class Client extends Eloquent implements IClient {
|
||||
|
||||
protected $table = 'oauth2_client';
|
||||
|
||||
public function getFriendlyClientType(){
|
||||
switch($this->client_type){
|
||||
case IClient::ClientType_Confidential:
|
||||
return 'Web Application';
|
||||
break;
|
||||
default:
|
||||
return 'Browser (JS Client)';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
@ -16,6 +26,11 @@ class Client extends Eloquent implements IClient {
|
||||
return $this->belongsToMany('ApiScope','oauth2_client_api_scope','client_id','scope_id');
|
||||
}
|
||||
|
||||
public function authorized_uris()
|
||||
{
|
||||
return $this->hasMany('ClientAuthorizedUri','client_id');
|
||||
}
|
||||
|
||||
public function getClientId()
|
||||
{
|
||||
return $this->client_id;
|
||||
@ -38,12 +53,12 @@ class Client extends Eloquent implements IClient {
|
||||
|
||||
public function getClientScopes()
|
||||
{
|
||||
// TODO: Implement getClientScopes() method.
|
||||
return $this->scopes()->get();
|
||||
}
|
||||
|
||||
public function getClientRegisteredUris()
|
||||
{
|
||||
// TODO: Implement getClientRegisteredUris() method.
|
||||
return $this->authorized_uris()->get();
|
||||
}
|
||||
|
||||
public function isScopeAllowed($scope)
|
||||
@ -93,6 +108,11 @@ class Client extends Eloquent implements IClient {
|
||||
return $email;
|
||||
}
|
||||
|
||||
public function getUserId(){
|
||||
$user = $this->user()->first();
|
||||
return $user->id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -49,5 +49,9 @@ Route::group(array("before" => array("ssl", "auth")), function () {
|
||||
Route::post('/accounts/user/profile/update', 'UserController@postUserProfileOptions');
|
||||
Route::get('/accounts/user/profile/clients/edit/{id}','UserController@getEditRegisteredClient');
|
||||
Route::get('/accounts/user/profile/clients/delete/{id}','UserController@getDeleteRegisteredClient');
|
||||
Route::get('/accounts/user/profile/clients/add','UserController@postAddRegisteredClient');
|
||||
Route::post('/accounts/user/profile/clients/add','UserController@postAddRegisteredClient');
|
||||
Route::get('/accounts/user/profile/clients/regenerate/clientsecret/{id}','UserController@getRegenerateClientSecret');
|
||||
Route::post('/accounts/user/profile/clients/redirect_uri/add','UserController@postAddAllowedRedirectUri');
|
||||
Route::get('/accounts/user/profile/clients/redirect_uri/delete/{id}/{uri_id}','UserController@getDeleteClientAllowedUri');
|
||||
Route::post('/accounts/user/profile/clients/scope/add','UserController@postAddAllowedScope');
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ namespace services\oauth2;
|
||||
use oauth2\services\IApiScopeService;
|
||||
use ApiScope;
|
||||
|
||||
class ApiScopeService implements IApiScopeService{
|
||||
class ApiScopeService implements IApiScopeService {
|
||||
|
||||
/**
|
||||
* @param array $scopes_names
|
||||
@ -15,4 +15,12 @@ class ApiScopeService implements IApiScopeService{
|
||||
{
|
||||
return ApiScope::where('active','=',true)->whereIn('name',$scopes_names)->get();
|
||||
}
|
||||
|
||||
/** get all active scopes
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAvailableScopes(){
|
||||
return ApiScope::where('active','=',true)->where('system','=',false)->get();
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,9 @@ use Client;
|
||||
use oauth2\OAuth2Protocol;
|
||||
use Request;
|
||||
use Input;
|
||||
use ClientAuthorizedUri;
|
||||
use Zend\Math\Rand;
|
||||
|
||||
|
||||
class ClientService implements IClientService{
|
||||
|
||||
@ -50,11 +53,14 @@ class ClientService implements IClientService{
|
||||
|
||||
public function getClientByIdentifier($id)
|
||||
{
|
||||
// TODO: Implement getClientByIdentifier() method.
|
||||
$client = Client::where('id', '=', $id)->first();
|
||||
return $client;
|
||||
}
|
||||
|
||||
public function addClient($client_id, $client_secret,$client_type, $user_id, $app_name, $app_description, $app_logo=null)
|
||||
public function addClient($client_type, $user_id, $app_name, $app_description, $app_logo='')
|
||||
{
|
||||
$client_id = Rand::getString(32).'.openstack.client';
|
||||
$client_secret = Rand::getString(16);
|
||||
$client = new Client;
|
||||
$client->app_name = $app_name;
|
||||
$client->app_logo = $app_logo;
|
||||
@ -64,26 +70,44 @@ class ClientService implements IClientService{
|
||||
$client->user_id = $user_id;
|
||||
$client->active = true;
|
||||
$client->Save();
|
||||
//default allowed url
|
||||
$this->addClientAllowedUri($client->getId(),'https://localhost');
|
||||
}
|
||||
|
||||
public function addClientScope($id, $scope_id)
|
||||
{
|
||||
// TODO: Implement addClientScope() method.
|
||||
$client = Client::find($id);
|
||||
if(!is_null($client)){
|
||||
$client->scopes()->attach($scope_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteClientScope($id, $scope_id)
|
||||
{
|
||||
// TODO: Implement deleteClientScope() method.
|
||||
$client = Client::find($id);
|
||||
if(!is_null($client)){
|
||||
$client->scopes()->detach($scope_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function addClientAllowedUri($id, $uri)
|
||||
{
|
||||
// TODO: Implement addClientAllowedUri() method.
|
||||
$client_authorized_uri = new ClientAuthorizedUri;
|
||||
$client_authorized_uri->client_id = $id;
|
||||
$client_authorized_uri->uri = $uri;
|
||||
$client_authorized_uri->Save();
|
||||
}
|
||||
|
||||
public function deleteClientAllowedUri($id, $uri)
|
||||
/**
|
||||
* Deletes a former client allowed redirection Uri
|
||||
* @param $id client identifier
|
||||
* @param $uri_id uri identifier
|
||||
*/
|
||||
public function deleteClientAllowedUri($id, $uri_id)
|
||||
{
|
||||
// TODO: Implement deleteClientAllowedUri() method.
|
||||
$uri = ClientAuthorizedUri::where('id','=',$uri_id)->where('client_id','=',$id);
|
||||
if(!is_null($uri))
|
||||
$uri->Delete();
|
||||
}
|
||||
|
||||
public function addClientAllowedRealm($id, $realm)
|
||||
@ -91,7 +115,7 @@ class ClientService implements IClientService{
|
||||
// TODO: Implement addClientAllowedRealm() method.
|
||||
}
|
||||
|
||||
public function deleteClientAllowedRealm($id, $realm)
|
||||
public function deleteClientAllowedRealm($id, $realm_id)
|
||||
{
|
||||
// TODO: Implement deleteClientAllowedRealm() method.
|
||||
}
|
||||
@ -100,4 +124,16 @@ class ClientService implements IClientService{
|
||||
{
|
||||
// TODO: Implement deleteClientByIdentifier() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerates Client Secret
|
||||
* @param $id client id
|
||||
* @return mixed
|
||||
*/
|
||||
public function regenerateClientSecret($id){
|
||||
$client_secret = Rand::getString(16);
|
||||
$client = $this->getClientByIdentifier($id);
|
||||
$client->client_secret = $client_secret;
|
||||
$client->Save();
|
||||
}
|
||||
}
|
134
app/views/edit-registered-client.blade.php
Normal file
@ -0,0 +1,134 @@
|
||||
@extends('layout')
|
||||
|
||||
@section('title')
|
||||
<title>Welcome to openstackId - Edit Registered Application</title>
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<a href="{{ URL::previous() }}">Go Back</a>
|
||||
|
||||
<legend>{{ $client->app_name }}</legend>
|
||||
|
||||
@if($errors->any())
|
||||
<div class="errors">
|
||||
<ul>
|
||||
@foreach($errors->all() as $error)
|
||||
<div class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
{{ $error }}
|
||||
</div>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div id="accordion">
|
||||
<h3>OAuth 2.0 Client ID</h3>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="client_id" class="label-client-secret">Client ID</label>
|
||||
<span id="client_id">{{ $client->client_id }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="client_secret" class="label-client-secret">Client Secret</label>
|
||||
<span id="client_secret">{{ $client->client_secret }}</span>
|
||||
{{ HTML::link(URL::action("UserController@getRegenerateClientSecret",array("id"=>$client->id)),'Regenerate',array('class'=>'btn regenerate-client-secret','title'=>'Regenerates Client Secret')) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3>Allowed Redirect Uris</h3>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
{{ Form::open(array('url' => URL::action('UserController@postAddAllowedRedirectUri'), 'method' => 'post')) }}
|
||||
<label for="redirect_uri">New Allowed Redirect Uri</label>
|
||||
<input type="text" value="" id="redirect_uri" name="redirect_uri"/>
|
||||
<input type="hidden" value="{{ $client->id }}" id="client_id" name="client_id"/>
|
||||
{{ Form::submit('Add',array('id'=>'add_uri','class'=>'btn')) }}
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@if (count($allowed_uris)>0)
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Allowed Uri</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($allowed_uris as $uri)
|
||||
<tr>
|
||||
<td>{{ $uri->uri }}</td>
|
||||
<td> {{ HTML::link(URL::action("UserController@getDeleteClientAllowedUri",array("id"=>$client->id,'uri_id'=>$uri->id)),'Delete',array('class'=>'btn del-allowed-uri','title'=>'Deletes a Allowed Uri')) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<h3>Allowed Scopes</h3>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<ul class="unstyled list-inline">
|
||||
@foreach ($scopes as $scope)
|
||||
<li>
|
||||
<label class="checkbox">
|
||||
@if ( in_array($scope->id,$selected_scopes))
|
||||
<input type="checkbox" class="scope-checkbox" id="scope[]" checked value="{{$scope->id}}"/>{{$scope->short_description}}<i class="icon-info-sign accordion-toggle" title="{{$scope->description}}"></i>
|
||||
@else
|
||||
<input type="checkbox" class="scope-checkbox" id="scope[]" value="{{$scope->id}}"/>{{$scope->short_description}}<i class="icon-info-sign accordion-toggle" title="{{$scope->description}}"></i>
|
||||
@endif
|
||||
</label>
|
||||
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
|
||||
@section('scripts')
|
||||
<script type="application/javascript">
|
||||
$(document).ready(function() {
|
||||
$( "#accordion" ).accordion();
|
||||
$("body").on('click',".scope-checkbox",function(event){
|
||||
var scope = {};
|
||||
scope.id = $(this).attr('value');
|
||||
scope.checked = $(this).is(':checked');
|
||||
scope.client_id = {{ $client->id }};
|
||||
$.ajax(
|
||||
{
|
||||
type: "POST",
|
||||
url: '{{URL::action("UserController@postAddAllowedScope",null)}}',
|
||||
data: JSON.stringify(scope),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
timeout:60000,
|
||||
success: function (data,textStatus,jqXHR) {
|
||||
//load data...
|
||||
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert( "Request failed: " + textStatus );
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@stop
|
@ -5,6 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ HTML::style('css/bootstrap.min.css') }}
|
||||
{{ HTML::style('css/main.css') }}
|
||||
{{ HTML::style('css/smoothness/jquery-ui-1.10.3.custom.min.css') }}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@ -23,6 +24,9 @@
|
||||
</div>
|
||||
{{ HTML::script('js/jquery-2.0.3.min.js')}}
|
||||
{{ HTML::script('js/bootstrap.min.js')}}
|
||||
{{ HTML::script('js/jquery-ui-1.10.3.custom.min.js')}}
|
||||
{{ HTML::script('js/jquery.validate.min.js')}}
|
||||
{{ HTML::script('js/additional-methods.min.js')}}
|
||||
@yield('scripts')
|
||||
</body>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<div class="span7" id="sidebar">
|
||||
<div class="span8" id="sidebar">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
@ -73,13 +73,13 @@
|
||||
<div class="row-fluid">
|
||||
<div id="clients" class="span12">
|
||||
<legend><i class="icon-info-sign accordion-toggle" title="Users can keep track of their registered applications and manage them"></i> Registered Applications</legend>
|
||||
{{ HTML::link(URL::action("UserController@postAddRegisteredClient",null),'Add',array('class'=>'btn add-client','title'=>'Adds a Registered Application')) }}
|
||||
{{ HTML::link(URL::action("UserController@postAddRegisteredClient",null),'Register Application',array('class'=>'btn add-client','title'=>'Adds a Registered Application')) }}
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application Name</th>
|
||||
<th>Client Id</th>
|
||||
<th>Client Secret</th>
|
||||
<th>Type</th>
|
||||
<th>Modified</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -87,8 +87,8 @@
|
||||
@foreach ($clients as $client)
|
||||
<tr>
|
||||
<td>{{ $client->app_name }}</td>
|
||||
<td>{{ $client->client_id}}</td>
|
||||
<td>{{ $client->client_secret }}</td>
|
||||
<td>{{ $client->getFriendlyClientType()}}</td>
|
||||
<td>{{ $client->updated_at }}</td>
|
||||
<td>
|
||||
{{ HTML::link(URL::action("UserController@getEditRegisteredClient",array("id"=>$client->id)),'Edit',array('class'=>'btn edit-client','title'=>'Edits a Registered Application')) }}
|
||||
{{ HTML::link(URL::action("UserController@getDeleteRegisteredClient",array("id"=>$client->id)),'Delete',array('class'=>'btn del-client','title'=>'Deletes a Registered Application')) }}</td>
|
||||
@ -98,6 +98,27 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dialog-form" title="Register new Application">
|
||||
<p style="font-size: 10px;">* You need to register your application to get the necessary credentials to call a Openstack API</p>
|
||||
<form>
|
||||
<fieldset>
|
||||
<label for="app-name">Application Name</label>
|
||||
<input type="text" name="app-name" id="app-name">
|
||||
|
||||
<label for="app-description">Application Description</label>
|
||||
<textarea style="resize: none;" rows="4" cols="50" name="app-description" id="app-description">
|
||||
</textarea>
|
||||
|
||||
<label for="app-type">Application Type</label>
|
||||
<select name="app-type" id="app-type">
|
||||
<option value="2">Web Application</option>
|
||||
<option value="1">Browser (JS Client)</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
@if (count($actions)>0)
|
||||
@ -166,8 +187,55 @@
|
||||
$("body").on('click',".add-client",function(event){
|
||||
var link = $(this).attr('href');
|
||||
event.preventDefault();
|
||||
$( "#dialog-form" ).dialog( "open" );
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#dialog-form").dialog({
|
||||
autoOpen: false,
|
||||
height: 450,
|
||||
width: 455,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Register": function() {
|
||||
var app_name = $('#app-name','#dialog-form').val()
|
||||
var app_desc = $('#app-description','#dialog-form').val()
|
||||
var app_type = $('#app-type','#dialog-form').val()
|
||||
var application = {};
|
||||
application.app_name = app_name;
|
||||
application.app_desc = app_desc;
|
||||
application.app_type = app_type;
|
||||
|
||||
var link = $(this).attr('href');
|
||||
$.ajax(
|
||||
{
|
||||
type: "POST",
|
||||
url: '{{URL::action("UserController@postAddRegisteredClient",null)}}',
|
||||
data: JSON.stringify(application),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
timeout:60000,
|
||||
success: function (data,textStatus,jqXHR) {
|
||||
//load data...
|
||||
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert( "Request failed: " + textStatus );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$(this).dialog( "close" );
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@stop
|
||||
|
1002
public/css/main.css
BIN
public/css/smoothness/images/animated-overlay.gif
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
Executable file
After Width: | Height: | Size: 212 B |
BIN
public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
Executable file
After Width: | Height: | Size: 208 B |
BIN
public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
Executable file
After Width: | Height: | Size: 335 B |
BIN
public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
Executable file
After Width: | Height: | Size: 207 B |
BIN
public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
Executable file
After Width: | Height: | Size: 262 B |
BIN
public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
Executable file
After Width: | Height: | Size: 262 B |
BIN
public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
Executable file
After Width: | Height: | Size: 332 B |
BIN
public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
Executable file
After Width: | Height: | Size: 280 B |
BIN
public/css/smoothness/images/ui-icons_222222_256x240.png
Executable file
After Width: | Height: | Size: 6.8 KiB |
BIN
public/css/smoothness/images/ui-icons_2e83ff_256x240.png
Executable file
After Width: | Height: | Size: 4.4 KiB |
BIN
public/css/smoothness/images/ui-icons_454545_256x240.png
Executable file
After Width: | Height: | Size: 6.8 KiB |
BIN
public/css/smoothness/images/ui-icons_888888_256x240.png
Executable file
After Width: | Height: | Size: 6.8 KiB |
BIN
public/css/smoothness/images/ui-icons_cd0a0a_256x240.png
Executable file
After Width: | Height: | Size: 4.4 KiB |