openstackid/app/ModelSerializers/OAuth2/ClientSerializer.php
smarcet b52c932636 IDP - User Management
* Added user registration process
* Added user password reset process
* Added user email verification proccess
* update token id to return custom claims
* update access token instrospection to return user custom claims
* Migrated to Doctrine ORM ( from eloquent)
* Added User CRUD
* Added User Groups CRUD
* Refactoring
* Bug Fixing
* added user registration oauth2 endpoint
  POST /api/v1/user-registration-requests

payload

* first_name ( required )
* last_name ( required)
* email ( required )
* country ( optional )

scope

user-registration ( private scope)

Change-Id: I36e8cd4473ccad734565051442e2c6033b204f27
2020-01-23 03:06:05 -03:00

55 lines
2.1 KiB
PHP

<?php namespace App\ModelSerializers\OAuth2;
/**
* Copyright 2019 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\ModelSerializers\BaseSerializer;
use Illuminate\Support\Facades\Auth;
use Models\OAuth2\Client;
/**
* Class ClientSerializer
* @package App\ModelSerializers\OAuth2
*/
final class ClientSerializer extends BaseSerializer
{
protected static $array_mappings = [
'ApplicationName' => 'app_name:json_string',
'ApplicationDescription' => 'app_description:json_string',
'ApplicationType' => 'application_type:json_string',
'FriendlyApplicationType' => 'friendly_application_type:json_string',
'Active' => 'active:json_boolean',
'Locked' => 'locked:json_boolean',
'ClientId' => 'client_id:json_string',
'ClientSecret' => 'client_secret:json_string',
'ClientType' => 'client_type:json_string',
];
/**
* @param null $expand
* @param array $fields
* @param array $relations
* @param array $params
* @return array
*/
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [])
{
$client = $this->object;
if(!$client instanceof Client) return [];
$values = parent::serialize($expand, $fields, $relations, $params);
$current_user = Auth::user();
if(!is_null($current_user))
$values['is_own'] = $client->getUserId() == $current_user->getId();
$values['modified_by'] = $client->getEditedByNice();
return $values;
}
}