Retire this project

The upstream for this project has moved to github. Retire the opendev
repo to avoid any confusion.

Depends-On: https://review.opendev.org/c/openstack/project-config/+/818170
Change-Id: I0e7f14701a75c4cceb76c80d2584534ddbd45f58
This commit is contained in:
Clark Boylan 2021-11-16 14:43:33 -08:00
parent 954e445fda
commit 7ae2662876
1725 changed files with 10 additions and 228454 deletions

View File

@ -1,179 +0,0 @@
APP_ENV=local
APP_DEBUG=true
APP_DEBUG_EMAIL=
APP_KEY=SomeRandomString
APP_URL=http://localhost
APP_SCOPE_BASE_REALM=http://localhost
APP_OAUTH_2_0_CLIENT_ID=clientid
APP_OAUTH_2_0_CLIENT_SECRET=clientsecret
APP_OAUTH_2_0_AUTH_SERVER_BASE_URL=http://localhost
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
SS_DB_HOST=localhost
SS_DB_DATABASE=homestead
SS_DB_USERNAME=homestead
SS_DB_PASSWORD=secret
REDIS_HOST=127.0.0.1
REDIS_PORT=port
REDIS_DB=0
REDIS_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=redis
SESSION_COOKIE_DOMAIN=
SESSION_COOKIE_SECURE=false
QUEUE_DRIVER=database
QUEUE_CONN=
QUEUE_DATABASE=
MAIL_DRIVER=sendgrid
SENDGRID_API_KEY='YOUR_SENDGRID_API_KEY'
CORS_ALLOWED_HEADERS=origin, content-type, accept, authorization, x-requested-with
CORS_ALLOWED_METHODS=GET, POST, OPTIONS, PUT, DELETE
CORS_USE_PRE_FLIGHT_CACHING=true
CORS_MAX_AGE=3200
CORS_EXPOSED_HEADERS=
CURL_TIMEOUT=3600
CURL_ALLOWS_REDIRECT=false
CURL_VERIFY_SSL_CERT=false
ASSETS_BASE_URL=http://www.openstack.org
SSL_ENABLED=true
DB_LOG_ENABLED=true
ACCESS_TOKEN_CACHE_LIFETIME=300
API_RESPONSE_CACHE_LIFETIME=600
LOG_EMAIL_TO=smarcet@gmail.com
LOG_EMAIL_FROM=smarcet@gmail.com
LOG_LEVEL=debug
EVENTBRITE_OAUTH2_PERSONAL_TOKEN=
SS_ENCRYPT_KEY=
SS_ENCRYPT_CYPHER=AES-256-CBC
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GOOGLE_SCOPES=""
SSH_USER=
SSH_PUBLIC_KEY=
SSH_PRIVATE_KEY=
SCP_HOST=
SCP_REMOTE_BASE_PATH=/tmp
GOOGLE_GEO_CODING_API_KEY=
# swift configuration
CLOUD_STORAGE_AUTH_URL=
CLOUD_STORAGE_USERNAME=
CLOUD_STORAGE_APIKEY=
CLOUD_STORAGE_PROJECT_NAME=
CLOUD_STORAGE_REGION=
CLOUD_STORAGE_ASSETS_CONTAINER=
CLOUD_STORAGE_IMAGES_CONTAINER=
CLOUD_STORAGE_MEDIA_UPLOADS_CONTAINER=
# enable/disable cal sync background task
ENABLE_CAL_SYNC=true
# enable/disable bookable rooms reservation revocation task
ENABLE_BOOKABLE_ROOMS_RESERVATION_REVOCATION=false
MAIL_FROM_NAME=
MAIL_FROM_EMAIL=
#stripe
STRIPE_BOOKING_PRIVATE_KEY=
STRIPE_BOOKING_ENDPOINT_SECRET=
STRIPE_REGISTRATION_PRIVATE_KEY=
STRIPE_REGISTRATION_ENDPOINT_SECRET=
#registration
REGISTRATION_SERVICE_OAUTH2_CLIENT_ID=
REGISTRATION_SERVICE_OAUTH2_CLIENT_SECRET=
REGISTRATION_SERVICE_OAUTH2_SCOPES=
REGISTRATION_DASHBOARD_OAUTH2_CLIENT_ID=
REGISTRATION_FROM_EMAIL=
REGISTRATION_DASHBOARD_BASE_URL=
REGISTRATION_DASHBOARD_BACK_URL=%s/a/orders
REGISTRATION_DASHBOARD_INVITATION_FORM_URL=%s/a/invitations/%s
REGISTRATION_DASHBOARD_ATTENDEE_EDIT_FORM_URL=%s/a/guests/%s
REGISTRATION_REMINDER_EMAIL_DAYS_INTERVAL=7
REGISTRATION_SUPPORT_EMAIL=
#IDP
# CHECK /.well-known/openid-configuration at idp
IDP_BASE_URI=
IDP_AUTHORIZATION_ENDPOINT=
IDP_TOKEN_ENDPOINT=
IDP_INTROSPECTION_ENDPOINT=
IDP_USERINFO_ENDPOINT=
REGISTRATION_VALIDATE_TICKET_TYPE_REMOVAL=true
# default stripe config
# if not set at summit level this will be used ( if set by default)
# *_WEBHOOK_SECRET variables should be populated by manually created webhooks at set stripe account
# and should be pointed to $API_BASE_URL/api/public/v1/summits/all/payments/Registration/confirm
# and set to attended following events types
# * payment_intent.payment_failed
# payment_intent.succeeded
REGISTRATION_DEFAULT_PAYMENT_PROVIDER=Stripe
REGISTRATION_DEFAULT_STRIPE_TEST_MODE=
REGISTRATION_DEFAULT_LIVE_STRIPE_PRIVATE_KEY=
REGISTRATION_DEFAULT_LIVE_STRIPE_PUBLISHABLE_KEY=
REGISTRATION_DEFAULT_LIVE_WEBHOOK_SECRET=
REGISTRATION_DEFAULT_TEST_STRIPE_PRIVATE_KEY=
REGISTRATION_DEFAULT_TEST_STRIPE_PUBLISHABLE_KEY=
REGISTRATION_DEFAULT_TEST_WEBHOOK_SECRET=
BOOKABLE_ROOMS_DEFAULT_PAYMENT_PROVIDER=Stripe
BOOKABLE_ROOMS_DEFAULT_STRIPE_TEST_MODE=
BOOKABLE_ROOMS_DEFAULT_LIVE_STRIPE_PRIVATE_KEY=
BOOKABLE_ROOMS_DEFAULT_LIVE_STRIPE_PUBLISHABLE_KEY=
BOOKABLE_ROOMS_DEFAULT_LIVE_WEBHOOK_SECRET=
BOOKABLE_ROOMS_DEFAULT_TEST_STRIPE_PRIVATE_KEY=
BOOKABLE_ROOMS_DEFAULT_TEST_STRIPE_PUBLISHABLE_KEY=
BOOKABLE_ROOMS_DEFAULT_TEST_WEBHOOK_SECRET=
MAIL_API_BASE_URL=
MAIL_API_OAUTH2_CLIENT_ID=
MAIL_API_OAUTH2_CLIENT_SECRET=
MAIL_API_OAUTH2_CLIENT_SCOPES=
CFP_APP_BASE_URL=
CFP_SUPPORT_EMAIL=
## RABBIT MQ
RABBITMQ_EXCHANGE_NAME=databus-exchange
RABBITMQ_HOST=
RABBITMQ_PORT=5671
RABBITMQ_VHOST=databus
RABBITMQ_LOGIN=admin
RABBITMQ_PASSWORD=1qaz2wsx
RABBITMQ_QUEUE=default
RABBITMQ_SSL=true
RABBITMQ_SSL_CAFILE=/certs/rabbit/ca-osf.pem
RABBITMQ_SSL_LOCALCERT=/certs/rabbit/client-cert-osf.pem
RABBITMQ_SSL_LOCALKEY=/certs/rabbit/client-key-osf.pem
RABBITMQ_SSL_VERIFY_PEER=false
DROPBOX_ACCESS_TOKEN=
MUX_TOKEN_ID=
MUX_TOKEN_SECRET=
# S3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_ENDPOINT=

3
.gitattributes vendored
View File

@ -1,3 +0,0 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored

30
.gitignore vendored
View File

@ -1,30 +0,0 @@
/vendor
/node_modules
composer.phar
.DS_Storeapp/storage
.idea/*
app/config/dev/*
app/config/testing/*
app/config/local/*
app/config/production/*
app/config/staging/*
app/config/packages/greggilbert/recaptcha/dev/*
app/config/packages/greggilbert/recaptcha/local/*
app/config/packages/greggilbert/recaptcha/production/*
app/config/packages/greggilbert/recaptcha/staging/*
/bootstrap/compiled.php
/bootstrap/environment.php
.tox
AUTHORS
ChangeLog
doc/build
*.egg
*.egg-info
.env.testing
.env
storage/*
*.log
routes.txt
/storage/logs/
/ss.sql
phpunit.xml

View File

@ -1,4 +1,4 @@
[gerrit]
host=review.opendev.org
port=29418
project=osf/openstackid-resources.git
project=openinfra/openstackid-resources.git

View File

@ -1,311 +0,0 @@
<?php namespace Libs\ModelSerializers;
/**
* Copyright 2016 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 Illuminate\Support\Facades\Log;
use libs\utils\JsonUtils;
use models\oauth2\IResourceServerContext;
use models\utils\IEntity;
use ModelSerializers\SerializerRegistry;
/**
* Class AbstractSerializer
* @package Libs\ModelSerializers
*/
abstract class AbstractSerializer implements IModelSerializer
{
const MaxCollectionPage = 10;
/**
* @var IEntity
*/
protected $object;
/**
* @var IResourceServerContext
*/
protected $resource_server_context;
/**
* AbstractSerializer constructor.
* @param $object
* @param IResourceServerContext $resource_server_context
*/
public function __construct($object, IResourceServerContext $resource_server_context){
$this->object = $object;
$this->resource_server_context = $resource_server_context;
}
protected static $array_mappings = [];
protected static $allowed_fields = [];
protected static $allowed_relations = [];
/**
* @return array
*/
protected function getAllowedFields()
{
$mappings = [];
$hierarchy = $this->getClassHierarchy();
foreach($hierarchy as $class_name){
if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
$class = new $class_name($this->object, $this->resource_server_context);
$mappings = array_merge($mappings, $class->getSelfAllowedFields());
}
$mappings = array_merge($mappings, $this->getSelfAllowedFields());
return $mappings;
}
private function getSelfAllowedFields(){
return static::$allowed_fields;
}
/**
* @return array
*/
protected function getAllowedRelations()
{
$mappings = array();
$hierarchy = $this->getClassHierarchy();
foreach($hierarchy as $class_name){
if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
$class = new $class_name($this->object, $this->resource_server_context);
$mappings = array_merge($mappings, $class->getSelfAllowedRelations());
}
$mappings = array_merge($mappings, $this->getSelfAllowedRelations());
return $mappings;
}
private function getSelfAllowedRelations(){
return static::$allowed_relations;
}
/**
* @return array
*/
private function getAttributeMappings()
{
$mappings = [];
$hierarchy = $this->getClassHierarchy();
foreach($hierarchy as $class_name){
if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
$class = new $class_name($this->object, $this->resource_server_context);
$mappings = array_merge($mappings, $class->getSelfMappings());
}
$mappings = array_merge($mappings, $this->getSelfMappings());
return $mappings;
}
private function getSelfMappings(){
return static::$array_mappings;
}
/**
* @return array
*/
private function getClassHierarchy(){
return array_reverse($this->get_class_lineage($this));
}
private function get_class_lineage($object)
{
$class_name = get_class($object);
$parents = array_values(class_parents($class_name));
return array_merge(array($class_name), $parents);
}
const BoolType = 'json_boolean';
const EpochType = 'datetime_epoch';
const StringType = 'json_string';
const IntType = 'json_int';
const FloatType = 'json_float';
const ObfuscatedEmailType = 'json_obfuscated_email';
const UrlType = 'json_url';
const ColorType = 'json_color';
const ValidTypes = [
self::BoolType,
self::EpochType,
self::StringType,
self::IntType,
self::FloatType,
self::ObfuscatedEmailType,
self::UrlType,
self::ColorType,
];
/**
* @param string $field
* @param string $type
* @return string
*/
public static function buildMapping(string $field, string $type):string {
if(!in_array($type, self::ValidTypes))
throw new \InvalidArgumentException();
return sprintf("%s:%s", $field, $type);
}
protected $expand_mappings = [];
/**
* @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 = [])
{
$values = [];
$method_prefix = ['get', 'is'];
if(!count($fields)) $fields = $this->getAllowedFields();
$mappings = $this->getAttributeMappings();
if (count($mappings)) {
$new_values = [];
foreach ($mappings as $attribute => $mapping) {
$mapping = preg_split('/:/', $mapping);
if(count($fields) > 0 && !in_array($mapping[0], $fields)) continue;
$value = null;
$method_found = false;
foreach($method_prefix as $prefix){
if(method_exists($this->object, $prefix.$attribute)){
try {
$value = call_user_func([$this->object, $prefix . $attribute]);
$method_found = true;
break;
}
catch (\Exception $ex){
Log::warning($ex);
$value = null;
}
}
}
if(!$method_found){
try {
//try dynamic one
$value = call_user_func([$this->object, 'get'.$attribute ]);
}
catch (\Exception $ex){
Log::warning($ex);
$value = null;
}
}
if(count($mapping) > 1)
{
//we have a formatter ...
switch(strtolower($mapping[1]))
{
case 'datetime_epoch':
{
if(!is_null($value)) {
$value = $value->getTimestamp();
}
}
break;
case 'json_string':
{
$value = JsonUtils::toJsonString($value);
}
break;
case 'json_boolean':
{
$value = JsonUtils::toJsonBoolean($value);
}
break;
case 'json_color':
{
$value = JsonUtils::toJsonColor($value);
}
break;
case 'json_int':
{
$value = JsonUtils::toJsonInt($value);
}
break;
case 'json_float':
{
$value = JsonUtils::toJsonFloat($value);
}
break;
case 'json_obfuscated_email':
{
$value = JsonUtils::toObfuscatedEmail($value);
}
case 'json_url':{
$value = JsonUtils::encodeUrl($value);
}
break;
}
}
$new_values[$mapping[0]] = $value;
}
$values = $new_values;
}
// expand logic
if (!empty($expand)) {
$exp_expand = explode(',', $expand);
foreach ($exp_expand as $relation) {
$relation = trim($relation);
if(isset($this->expand_mappings[$relation])){
$values = $this->expand_mappings[$relation]->serialize($values, $expand);
}
}
}
return $values;
}
/**
* @param string $expand_str
* @param string $prefix
* @return string
*/
public static function filterExpandByPrefix($expand_str, $prefix){
$expand_to = explode(',', $expand_str);
$filtered_expand = array_filter($expand_to, function($element) use($prefix){
return preg_match('/^' . preg_quote($prefix, '/') . '\./', strtolower(trim($element))) > 0;
});
$res = '';
foreach($filtered_expand as $filtered_expand_elem){
if(strlen($res) > 0) $res .= ',';
$res .= str_replace_first($prefix.".","", strtolower(trim($filtered_expand_elem)));
}
return $res;
}
/**
* @param string $prefix
* @param string $expand
* @return string
*/
protected static function getExpandForPrefix(string $prefix, string $expand):string {
Log::debug(sprintf("AbstractSerializer::getExpandForPrefix prefix %s expand %s", $prefix, $expand));
$prefix_expand = [];
foreach(explode(',', $expand) as $e){
if(strstr($e, $prefix.".")!==false)
$prefix_expand[] = str_replace($prefix.".","", $e);
}
return implode(',', $prefix_expand);
}
}

View File

@ -1,26 +0,0 @@
<?php namespace Libs\ModelSerializers;
/**
* Copyright 2016 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.
**/
interface IModelSerializer
{
/**
* @param null $expand
* @param array $fields
* @param array $relations
* @param array $params
* @return array
* @throw HTTP403ForbiddenException
*/
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() );
}

View File

@ -1,37 +0,0 @@
<?php namespace Libs\ModelSerializers;
/**
* Copyright 2020 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 ModelSerializers\SerializerRegistry;
/**
* Class Many2OneExpandSerializer
* @package Libs\ModelSerializers
*/
class Many2OneExpandSerializer extends One2ManyExpandSerializer
{
/**
* @param array $values
* @param string $expand
* @return array
*/
public function serialize(array $values, string $expand): array
{
$values = $this->unsetOriginalAttribute($values);
$callback = $this->getRelationFn;
$res = [];
foreach ($callback($this) as $item){
$res[] = SerializerRegistry::getInstance()->getSerializer($item)->serialize(AbstractSerializer::filterExpandByPrefix($expand, $this->attribute_name));
}
$values[$this->attribute_name] = $res;
return $values;
}
}

View File

@ -1,78 +0,0 @@
<?php namespace Libs\ModelSerializers;
/**
* Copyright 2020 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 ModelSerializers\SerializerRegistry;
use Closure;
/**
* Class One2ManyExpandSerializer
* @package Libs\ModelSerializers
*/
class One2ManyExpandSerializer
{
/**
* @var string
*/
protected $original_attribute;
/**
* @var string
*/
protected $attribute_name;
/**
* @var Closure
*/
protected $getRelationFn;
/**
* One2ManyExpandSerializer constructor.
* @param string $attribute_name
* @param Closure $getRelationFn
* @param string|null $original_attribute
*/
public function __construct(
string $attribute_name,
Closure $getRelationFn,
string $original_attribute = null
)
{
$this->attribute_name = $attribute_name;
$this->getRelationFn = $getRelationFn;
$this->original_attribute = $original_attribute;
}
/**
* @param array $values
* @return array
*/
protected function unsetOriginalAttribute(array $values)
{
if (isset($values[$this->original_attribute]))
unset($values[$this->original_attribute]);
return $values;
}
/**
* @param array $values
* @param string $expand
* @return array
*/
public function serialize(array $values, string $expand): array
{
$values = $this->unsetOriginalAttribute($values);
$callback = $this->getRelationFn;
$values[$this->attribute_name] = SerializerRegistry::getInstance()->getSerializer($callback($this))->serialize(AbstractSerializer::filterExpandByPrefix($expand, $this->attribute_name));
return $values;
}
}

View File

@ -1,77 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
/**
* Class BearerAccessTokenAuthorizationHeaderParser
* Parse
* http://tools.ietf.org/html/rfc6750#section-2-1
* @package oauth2
*/
class BearerAccessTokenAuthorizationHeaderParser
{
private static $instance = null;
private function __construct()
{
}
public static function getInstance()
{
if (self::$instance == null)
{
self::$instance = new BearerAccessTokenAuthorizationHeaderParser();
}
return self::$instance;
}
/**
* @param string $http_auth_header_value
* @return string
* @throws OAuth2MissingBearerAccessTokenException
*/
public function parse($http_auth_header_value)
{
$accessTokenValue = '';
if (!is_null($http_auth_header_value) && !empty($http_auth_header_value))
{
// Check for special case, because cURL sometimes does an
// internal second request and doubles the authorization header,
// which always resulted in an error.
//
// 1st request: Authorization: Bearer XXX
// 2nd request: Authorization: Bearer XXX, Bearer XXX
if (strpos($http_auth_header_value, ',') !== false)
{
$headerPart = explode(',', $http_auth_header_value);
$accessTokenValue = trim(preg_replace('/^(?:\s+)?Bearer\s/', '', $headerPart[0]));
}
else
{
$accessTokenValue = trim(preg_replace('/^(?:\s+)?Bearer\s/', '', $http_auth_header_value));
}
$accessTokenValue = ($accessTokenValue == 'Bearer') ? '' : $accessTokenValue;
}
if (empty($accessTokenValue))
{
throw new OAuth2MissingBearerAccessTokenException;
}
return $accessTokenValue;
}
private function __clone()
{
}
}

View File

@ -1,54 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
class HttpMessage implements \ArrayAccess
{
protected $container = array();
public function __construct(array $values)
{
$this->container = $values;
}
/**
* arrayaccess methods
* */
public function offsetSet($offset, $value)
{
if (is_null($offset))
{
$this->container[] = $value;
}
else
{
$this->container[$offset] = $value;
}
}
public function offsetExists($offset)
{
return isset($this->container[$offset]);
}
public function offsetUnset($offset)
{
unset($this->container[$offset]);
}
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
}

View File

@ -1,52 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
abstract class HttpResponse extends HttpMessage
{
const HttpOkResponse = 200;
const HttpErrorResponse = 400;
protected $http_code;
protected $content_type;
public function __construct($http_code, $content_type)
{
$this->http_code = $http_code;
$this->content_type = $content_type;
}
abstract public function getContent();
public function getHttpCode()
{
return $this->http_code;
}
protected function setHttpCode($http_code)
{
$this->http_code = $http_code;
}
public function getContentType()
{
return $this->content_type;
}
abstract public function getType();
public function addParam($name, $value)
{
$this[$name] = $value;
}
}

View File

@ -1,28 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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 Exception;
/**
* Class InvalidGrantTypeException
* @package libs\oauth2
*/
class InvalidGrantTypeException extends Exception
{
public function __construct($message = "")
{
$message = "Invalid Grant Type : " . $message;
parent::__construct($message, 0, null);
}
}

View File

@ -1,39 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
class OAuth2DirectResponse extends OAuth2Response
{
const DirectResponseContentType = "application/json;charset=UTF-8";
const OAuth2DirectResponse = 'OAuth2DirectResponse';
public function __construct($http_code = self::HttpOkResponse, $content_type = self::DirectResponseContentType)
{
// Successful Responses: A server receiving a valid request MUST send a
// response with an HTTP status code of 200.
parent::__construct($http_code, $content_type);
}
public function getContent()
{
$json_encoded_format = json_encode($this->container);
return $json_encoded_format;
}
public function getType()
{
return self::OAuth2DirectResponse;
}
}

View File

@ -1,24 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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 \Exception;
class OAuth2InvalidIntrospectionResponse extends Exception
{
public function __construct($message = "")
{
$message = "Invalid Introspection Response : " . $message;
parent::__construct($message, 0, null);
}
}

View File

@ -1,28 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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 Exception;
/**
* Class OAuth2MissingBearerAccessTokenException
* @package libs\oauth2
*/
class OAuth2MissingBearerAccessTokenException extends Exception
{
public function __construct($message = "")
{
$message = "Missing Bearer Access Token : " . $message;
parent::__construct($message, 0, null);
}
}

View File

@ -1,93 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
class OAuth2Protocol
{
const OAuth2Protocol_GrantType_AuthCode = 'authorization_code';
const OAuth2Protocol_GrantType_Implicit = 'implicit';
const OAuth2Protocol_GrantType_ResourceOwner_Password = 'password';
const OAuth2Protocol_GrantType_ClientCredentials = 'client_credentials';
const OAuth2Protocol_GrantType_RefreshToken = 'refresh_token';
const OAuth2Protocol_ResponseType_Code = 'code';
const OAuth2Protocol_ResponseType_Token = 'token';
const OAuth2Protocol_ResponseType = 'response_type';
const OAuth2Protocol_ClientId = 'client_id';
const OAuth2Protocol_UserId = 'user_id';
const OAuth2Protocol_ClientSecret = 'client_secret';
const OAuth2Protocol_Token = 'token';
const OAuth2Protocol_TokenType = 'token_type';
//http://tools.ietf.org/html/rfc7009#section-2.1
const OAuth2Protocol_TokenType_Hint = 'token_type_hint';
const OAuth2Protocol_AccessToken_ExpiresIn = 'expires_in';
const OAuth2Protocol_RefreshToken = 'refresh_token';
const OAuth2Protocol_AccessToken = 'access_token';
const OAuth2Protocol_RedirectUri = 'redirect_uri';
const OAuth2Protocol_Scope = 'scope';
const OAuth2Protocol_Audience = 'audience';
const OAuth2Protocol_State = 'state';
/**
* Indicates whether the user should be re-prompted for consent. The default is auto,
* so a given user should only see the consent page for a given set of scopes the first time
* through the sequence. If the value is force, then the user sees a consent page even if they
* previously gave consent to your application for a given set of scopes.
*/
const OAuth2Protocol_Approval_Prompt = 'approval_prompt';
const OAuth2Protocol_Approval_Prompt_Force = 'force';
const OAuth2Protocol_Approval_Prompt_Auto = 'auto';
/**
* Indicates whether your application needs to access an API when the user is not present at
* the browser. This parameter defaults to online. If your application needs to refresh access tokens
* when the user is not present at the browser, then use offline. This will result in your application
* obtaining a refresh token the first time your application exchanges an authorization code for a user.
*/
const OAuth2Protocol_AccessType = 'access_type';
const OAuth2Protocol_AccessType_Online = 'online';
const OAuth2Protocol_AccessType_Offline = 'offline';
const OAuth2Protocol_GrantType = 'grant_type';
const OAuth2Protocol_Error = 'error';
const OAuth2Protocol_ErrorDescription = 'error_description';
const OAuth2Protocol_ErrorUri = 'error_uri';
const OAuth2Protocol_Error_InvalidRequest = 'invalid_request';
const OAuth2Protocol_Error_UnauthorizedClient = 'unauthorized_client';
const OAuth2Protocol_Error_AccessDenied = 'access_denied';
const OAuth2Protocol_Error_UnsupportedResponseType = 'unsupported_response_type';
const OAuth2Protocol_Error_InvalidScope = 'invalid_scope';
const OAuth2Protocol_Error_UnsupportedGrantType = 'unsupported_grant_type';
const OAuth2Protocol_Error_InvalidGrant = 'invalid_grant';
//error codes definitions http://tools.ietf.org/html/rfc6749#section-4.1.2.1
const OAuth2Protocol_Error_ServerError = 'server_error';
const OAuth2Protocol_Error_TemporallyUnavailable = 'temporally_unavailable';
//http://tools.ietf.org/html/rfc7009#section-2.2.1
const OAuth2Protocol_Error_Unsupported_TokenType = ' unsupported_token_type';
//http://tools.ietf.org/html/rfc6750#section-3-1
const OAuth2Protocol_Error_InvalidToken = 'invalid_token';
const OAuth2Protocol_Error_InsufficientScope = 'insufficient_scope';
public static $valid_responses_types = array(
self::OAuth2Protocol_ResponseType_Code => self::OAuth2Protocol_ResponseType_Code,
self::OAuth2Protocol_ResponseType_Token => self::OAuth2Protocol_ResponseType_Token
);
public static $protocol_definition = array(
self::OAuth2Protocol_ResponseType => self::OAuth2Protocol_ResponseType,
self::OAuth2Protocol_ClientId => self::OAuth2Protocol_ClientId,
self::OAuth2Protocol_RedirectUri => self::OAuth2Protocol_RedirectUri,
self::OAuth2Protocol_Scope => self::OAuth2Protocol_Scope,
self::OAuth2Protocol_State => self::OAuth2Protocol_State
);
}

View File

@ -1,58 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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 Exception;
/**
* Class OAuth2ResourceServerException
* @package libs\oauth2
*/
class OAuth2ResourceServerException extends Exception
{
private $http_code;
private $error;
private $error_description;
private $scope;
public function __construct($http_code, $error, $error_description, $scope = null)
{
$this->http_code = $http_code;
$this->error = $error;
$this->error_description = $error_description;
$this->scope = $scope;
$message = "Resource Server Exception : " . sprintf('http code : %s - error : %s - error description: %s', $http_code, $error, $error_description);
parent::__construct($message, 0, null);
}
public function getError()
{
return $this->error;
}
public function getErrorDescription()
{
return $this->error_description;
}
public function getScope()
{
return $this->scope;
}
public function getHttpCode()
{
return $this->http_code;
}
}

View File

@ -1,18 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
abstract class OAuth2Response extends HttpResponse
{
}

View File

@ -1,71 +0,0 @@
<?php namespace libs\oauth2;
/**
* Copyright 2015 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.
**/
/**
* Class OAuth2WWWAuthenticateErrorResponse
* http://tools.ietf.org/html/rfc6750#section-3
* @package oauth2\responses
*/
class OAuth2WWWAuthenticateErrorResponse extends OAuth2DirectResponse
{
private $realm;
private $error;
private $error_description;
private $scope;
private $http_error;
public function __construct($realm, $error, $error_description, $scope, $http_error)
{
parent::__construct($http_error, self::DirectResponseContentType);
$this->realm = $realm;
$this->error = $error;
$this->error_description = $error_description;
$this->scope = $scope;
$this->http_error = $http_error;
}
public function getWWWAuthenticateHeaderValue()
{
$value = sprintf('Bearer realm="%s"', $this->realm);
$value = $value . sprintf(', error="%s"', $this->error);
$value = $value . sprintf(', error_description="%s"', $this->error_description);
if (!is_null($this->scope)) {
$value = $value . sprintf(', scope="%s"', $this->scope);
}
return $value;
}
public function getContent()
{
$content = array(
'error' => $this->error,
'error_description' => $this->error_description
);
if (!is_null($this->scope)) {
$content['scope'] = $this->scope;
}
return $content;
}
public function getType()
{
return null;
}
}

View File

@ -1,29 +0,0 @@
<?php namespace libs\utils;
/**
* Copyright 2015 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 Exception;
/**
* Class ConfigurationException
* @package libs\utils
*/
class ConfigurationException extends Exception
{
public function __construct($message = "")
{
$message = "Configuration Exception : " . $message;
parent::__construct($message, 0, null);
}
}

View File

@ -1,54 +0,0 @@
<?php namespace libs\utils;
/**
* Copyright 2016 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 Doctrine\Common\Persistence\ManagerRegistry;
use Illuminate\Contracts\Container\Container;
use LaravelDoctrine\ORM\BootChain;
use LaravelDoctrine\ORM\DoctrineServiceProvider;
use LaravelDoctrine\ORM\IlluminateRegistry;
/**
* Class CustomDoctrineServiceProvider
* @package libs\utils
*/
final class CustomDoctrineServiceProvider extends DoctrineServiceProvider
{
/**
* Register the manager registry
*/
protected function registerManagerRegistry()
{
$this->app->singleton('registry', function ($app) {
$registry = new IlluminateRegistry($app, $app->make(CustomEntityManagerFactory::class));
// Add all managers into the registry
foreach ($app->make('config')->get('doctrine.managers', []) as $manager => $settings) {
$registry->addManager($manager, $settings);
}
return $registry;
});
// Once the registry get's resolved, we will call the resolve callbacks which were waiting for the registry
$this->app->afterResolving('registry', function (ManagerRegistry $registry, Container $container) {
$this->bootExtensionManager();
BootChain::boot($registry);
});
$this->app->alias('registry', ManagerRegistry::class);
$this->app->alias('registry', IlluminateRegistry::class);
}
}

View File

@ -1,88 +0,0 @@
<?php namespace libs\utils;
/**
* Copyright 2016 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 Doctrine\ORM\Cache\DefaultCacheFactory;
use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger;
use Doctrine\ORM\Cache\RegionsConfiguration;
use Doctrine\ORM\Configuration;
use LaravelDoctrine\ORM\EntityManagerFactory;
/**
* Class CustomEntityManagerFactory
* @package libs\utils
*/
final class CustomEntityManagerFactory extends EntityManagerFactory
{
/**
* @param Configuration $configuration
*/
protected function setSecondLevelCaching(Configuration $configuration)
{
$second_level_cache_config = $this->config->get('doctrine.cache.second_level', []);
if (!is_array($second_level_cache_config)) return;
if (!isset($second_level_cache_config['enabled'])) return;
if (!$second_level_cache_config['enabled']) return;
$configuration->setSecondLevelCacheEnabled(true);
$cacheConfig = $configuration->getSecondLevelCacheConfiguration();
$regions_config = isset($second_level_cache_config['regions']) ? $second_level_cache_config['regions'] : [];
if (is_array($regions_config) && count($regions_config) > 0) {
$regions_configuration = new RegionsConfiguration
(
isset($second_level_cache_config['region_lifetime']) ? $second_level_cache_config['region_lifetime'] : 3600,
isset($second_level_cache_config['region_lock_lifetime']) ? $second_level_cache_config['region_lock_lifetime'] : 60
);
foreach ($regions_config as $region_name => $region_config) {
if (isset($region_config['lifetime']))
$regions_configuration->setLifetime($region_name, $region_config['lifetime']);
if (isset($region_config['lock_lifetime']))
$regions_configuration->setLockLifetime($region_name, $region_config['lock_lifetime']);
}
$cacheConfig->setRegionsConfiguration($regions_configuration);
}
// Cache logger
if (isset($second_level_cache_config['log_enabled']) && $second_level_cache_config['log_enabled']){
$logger = new StatisticsCacheLogger();
$cacheConfig->setCacheLogger($logger);
}
$factory = new DefaultCacheFactory
(
$cacheConfig->getRegionsConfiguration(),
$this->cache->driver()
);
$file_lock_region_directory = isset($second_level_cache_config['file_lock_region_directory']) ?
$second_level_cache_config['file_lock_region_directory'] :
'/tmp';
$factory->setFileLockRegionDirectory($file_lock_region_directory);
$cacheConfig->setCacheFactory
(
$factory
);
}
}

View File

@ -1,33 +0,0 @@
<?php
/**
* Copyright 2015 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.
**/
namespace libs\utils;
/**
* Class DateTimeUtils
* @package libs\utils
*/
abstract class DateTimeUtils
{
const MicrosecondsPrecision = 6;
/**
* @return string
*/
public static function nowRfc2822(){
list($usec, $sec) = explode(' ', microtime());
$usec = substr($usec, 2, self::MicrosecondsPrecision);
return gmdate('Y-m-d H:i:s', $sec).'.'.$usec;
}
}

View File

@ -1,40 +0,0 @@
<?php