Commit 354870a4 authored by Mark Harding's avatar Mark Harding
Browse files

(chore): remove old dev files

parent 4fd9792d
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5.0"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
#v.gui = true
end
config.vm.provider "virtualbox" do |v|
host = RbConfig::CONFIG['host_os']
slowNetworkFix = false
# Give VM 1/4 system memory & access to all physical cpu cores on the host
if host =~ /darwin/
cpus = `sysctl -n hw.physicalcpu`.to_i
# sysctl returns Bytes and we need to convert to MB
sysmem = `sysctl -n hw.memsize`.to_i / 1024 / 1024
elsif host =~ /linux|arch/
cpus = `nproc`.to_i # @todo: get physical cpus (for VBox enhanced performance)
# meminfo shows KB and we need to convert to MB
sysmem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024
elsif host =~ /mswin|windows|mingw/
cpus = `powershell (Get-WmiObject Win32_ComputerSystem).numberoflogicalprocessors`.to_i # @todo: get physical cpus (for VBox enhanced performance)
sysmem = `powershell (Get-WmiObject Win32_ComputerSystem).totalphysicalmemory`.to_i / 1024 / 1024
slowNetworkFix = true
else # unknown platform
cpus = 1
sysmem = 1024
slowNetworkFix = true
end
mem = sysmem / 4
mem = 2560 if mem < 2560
v.customize ["modifyvm", :id, "--memory", mem]
v.customize ["modifyvm", :id, "--cpus", cpus]
if slowNetworkFix
v.customize ["modifyvm", :id, "--nictype1", "virtio"]
v.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
end
config.vm.hostname = "minds"
config.vm.synced_folder ".", "/var/www/Minds", type: "nfs"
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "10.54.0.111"
config.vm.network :forwarded_port, guest: 80, host: 8800
config.vm.network :forwarded_port, guest: 8010, host: 8810
config.vm.provision :shell, path: "bin/bootstrap-ubuntu.sh", run: 'always'
end
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/Minds/front/public;
index index.php index.html;
server_name _;
sendfile off;
location / {
try_files $uri $uri/ @rewrite;
}
location ~ ^(/api|/fs|/icon|/carousel) {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With';
add_header 'X-foo' 'Bar';
set $cors "api";
rewrite ^(.+)$ /index.php last;
}
location @rewrite {
rewrite ^(.+)$ /index.php last;
}
# pass the PHP scripts to FastCGI server listening on socket
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME /var/www/Minds/index.php;
fastcgi_index index.php;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
deny all;
}
}
user www-data;
worker_processes 4;
worker_rlimit_nofile 20480;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
use epoll;
multi_accept on;
}
http {
##
# Basic Settings
##
#fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:10m max_size=1000m inactive=60m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100000;
types_hash_max_size 2048;
# server_tokens off;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
#access_log /var/log/nginx/access.log;
access_log off;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 9;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Cache Settingss
#
open_file_cache max=1000 inactive=60s;
open_file_cache_valid 60s;
open_file_cache_min_uses 1;
open_file_cache_errors on;
client_body_buffer_size 8K;
client_header_buffer_size 1k;
client_max_body_size 20G;
large_client_header_buffers 2 1k;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
upstream php {
server unix:/run/php/php7.0-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
<?php
/**
* Delete blog entity
*
* @package Blog
*/
$guid = get_input('guid');
$entity = get_entity($guid, 'object');
if (elgg_instanceof($entity, 'object', 'oauth2_client') && $entity->canEdit()) {
if ($entity->delete()) {
system_message(elgg_echo('oauth2:application:deleted'));
} else {
register_error(elgg_echo('oauth2:application:cannot_delete'));
}
} else {
register_error(elgg_echo('oauth2:application:not_found'));
}
forward(REFERER);
<?php
elgg_load_library('oauth2');
$guid = get_input('guid');
$title = get_input('name');
$description = get_input('url');
$secret = get_input('secret');
if ($guid) {
$entity = get_entity($guid, 'object');
if (!elgg_instanceof($entity, 'object', 'oauth2_client') || !$entity->canEdit()) {
register_error(elgg_echo('oauth2:register:app_not_found'));
forward(REFERRER);
}
} else {
$entity = new ElggObject();
$entity->subtype = 'oauth2_client';
$entity->owner_guid = elgg_get_logged_in_user_guid();
$entity->access_id = ACCESS_PRIVATE;
}
$entity->title = $title;
$entity->description = $description;
if (!$entity->save()) {
register_error(elgg_echo('oauth2:error:save_failed'));
forward(REFERRER);
}
if (!$guid) {
$entity->client_id = $entity->guid;
$entity->client_secret = oauth2_generate_client_secret();
}
if ($secret) {
$entity->client_secret = $secret;
}
$entity->save();
$label = $guid ? 'updated' : 'registered';
system_message(elgg_echo("oauth2:register:$label"));
forward(elgg_get_site_url() . 'oauth2/applications');
<?php
/**
* OAUTH2 Access Token Entity
*/
namespace minds\plugin\oauth2\entities;
use Minds\Entities;
use Minds\Core\data;
class accessToken extends Entities\Entity
{
protected $attributes = array(
'type' => 'oauth2',
'subtype' => 'accessToken'
);
public function __construct($token = null)
{
if ($token) {
$this->load($token);
}
}
public function load($token)
{
$lookup = new Data\lookup('oauth2:token');
$guid = $lookup->get($token);
if (!isset($guid[0])) {
throw new \Exception('Lookup failed');
}
$db = new Data\Call('entities');
$data = $db->getRow($guid[0], array('limit'=>200));
foreach ($data as $k => $v) {
$this->$k = $v;
}
}
public function save()
{
$guid = parent::save();
error_log($guid);
$lookup = new Data\lookup('oauth2:token');
$lookup->set($this->access_token, $guid);
}
public function delete()
{
parent::delete();
}
/*
* Return an array in OAuth2 format
*/
public function export()
{
return array(
'access_token' => $this->access_token,
'client_id' => $this->client_id,
'user_id' => $this->owner_guid,
'expires' => $this->expires,
'scope' => $this->scope,
'entity' => $this,
);
}
}
<?php
/**
* OAUTH2 Access Token Entity
*/
namespace minds\plugin\oauth2\entities;
use Minds\Entities;
use Minds\Core\data;
class client extends Entities\Object
{
protected $attributes = array(
'type' => 'object',
'subtype' => 'oauth2_client'
);
/*
* Return an array in OAuth2 format
*/
public function export()
{
return array(
'client_secret' => $this->client_secret,
'client_id' => $this->client_id,
'scopes' => $this->scopes
);
}
}
<?php
/**
* OAUTH2 code entity
*/
namespace minds\plugin\oauth2\entities;
use Minds\Entities;
use Minds\Core\data;
class code extends Entities\Entity
{
protected $attributes = array(
'type' => 'oauth2',
'subtype' => 'code'
);
public function __construct($code = null)
{
if ($code) {
$this->load($code);
}
}
public function load($code)
{
$lookup = new Data\lookup('oauth2:code');
$guid = $lookup->get($code);
if (!isset($guid[0])) {
throw new \Exception('Lookup failed');
}
$db = new Data\Call('entities');
$data = $db->getRow($guid[0], array('limit'=>200));
foreach ($data as $k => $v) {
$this->$k = $v;
}
}
public function save()
{
$guid = parent::save();
$lookup = new Data\lookup('oauth2:code');
$lookup->set($this->authorization_code, $guid);
}
public function delete()
{
//parent::delete();
$lookup = new Data\lookup('oauth2:code');
$lookup->remove($this->authorization_code);
}
/*
* Return an array in OAuth2 format
*/
public function export()
{
return array(
'authorization_code' => $this->authorization_code,
'client_id' => $this->client_id,
'user_id' => $this->owner_guid,
'redirect_uri' => $this->redirect_uri,
'expires' => $this->expires,
'scope' => $this->scope,
'entity' => $this,
);
}
}
<?php
/**
* OAUTH2 Refresh Token Entity
*/
namespace minds\plugin\oauth2\entities;
use Minds\Entities;
use Minds\Core\data;
class refreshToken extends Entities\Entity
{
protected $attributes = array(
'type' => 'oauth2',
'subtype' => 'refreshToken'
);
public function __construct($token = null)
{
if ($token) {
$this->load($token);
}
}
public function load($token)
{
$lookup = new Data\lookup('oauth2:token');
$guid = $lookup->get($token);
if (!isset($guid[0])) {
throw new \Exception('Lookup failed');
}
$db = new Data\Call('entities');
$data = $db->getRow($guid[0], array('limit'=>200));
foreach ($data as $k => $v) {
$this->$k = $v;
}
}
public function save()
{
$guid = parent::save();
$lookup = new Data\lookup('oauth2:token');
$lookup->set($this->refresh_token, $guid);
}
public function delete()
{
parent::delete();
}
/*
* Return an array in OAuth2 format
*/
public function export()
{
return array(
'access_token' => $this->refresh_token,
'client_id' => $this->client_id,
'user_id' => $this->owner_guid,
'expires' => $this->expires,
'scope' => $this->scope,
'entity' => $this,
);
}
}
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
<?php
/**
* OAuth2 English language file.
*
*/
$english = array(
// Object subtypes
'item:object:oauth2_client' => 'OAuth2 Clients',
'item:object:oauth2_access_token' => 'OAuth2 Access Tokens',
'item:object:oauth2_refresh_token' => 'OAuth2 Refresh Tokens',
'item:object:oauth2_auth_code' => 'OAuth2 Authoriation Codes',
'admin:settings:oauth2' => 'Connected Applications',
'oauth2:register:title' => 'Register Application',
'oauth2:applications:admin_title' => 'Registered Applications',
'oauth2:applications:title' => 'Your Registered Applications',
'oauth2:add' => 'Register Application',
'oauth2:authorize' => '%s is requesting access to your personal information in order to connect to minds.com.',
'oauth2:register:app_not_found' => 'Application not found',
'oauth2:error:save_failed' => 'Failed to save application',
'oauth2:developers' => 'Developers',
'oauth2' => 'Minds Connect',
// Forms
'oauth2:name:label' => 'Application Name',
'oauth2:url:label' => 'Application URL',
'oauth2:client_id:label' => 'Client ID',
'oauth2:client_secret:label' => 'Client Secret',
'oauth2:regenerate:confirm' => 'Regenerating your secret will prevent any applications currently using this secret to fail once you click Save. Continue?',
// Register action
'auth2:register:app_not_found' => 'Failed to update application',
'oauth2:register:updated' => 'Successfully updated application',
'oauth2:register:registered' => 'Successfully registered application',
// Delete action
'oauth2:application:not_found' => 'Application not found',
'oauth2:application:deleted' => 'The application was successfully deleted',
'oauth2:application:cannot_delete' => 'Failed to delete the application',
);
add_translation('en', $english);
<?php
/**
* OAuth2::applications
*/
namespace minds\plugin\oauth2\pages;
use Minds\Core;
use Minds\Interfaces;
use minds\plugin\oauth2\entities;
use minds\plugin\oauth2\storage;
use OAuth2;
use OAuth2\GrantType\AuthorizationCode;
use OAuth2\GrantType\UserCredentials;
use OAuth2\GrantType\RefreshToken;
use OAuth2\HttpFoundationBridge\Response as BridgeResponse;
class applications extends core\page implements Interfaces\page
{
public function get($pages)
{
$content = elgg_view_form('oauth2/register', array('action'=>'oauth2/applications'));