Skip to content

Commit

Permalink
Remove the OAuth 2 feature (will be separated plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
triasrahman committed Feb 27, 2018
1 parent 86dd0f0 commit 92358c3
Show file tree
Hide file tree
Showing 46 changed files with 8 additions and 4,308 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Octobro
Copyright (c) 2018 Octobro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 1 addition & 26 deletions Plugin.php
Expand Up @@ -7,46 +7,21 @@

class Plugin extends PluginBase
{
public function registerComponents()
{
}

public function registerSettings()
{
}

public function boot()
{
// Register Cors
App::register('\Barryvdh\Cors\ServiceProvider');

// Register oAuth
App::register('\Octobro\API\Storage\FluentStorageServiceProvider');
App::register('\Octobro\API\Classes\OAuth2ServerServiceProvider');

// Add alias
$alias = AliasLoader::getInstance();
$alias->alias('Authorizer', '\Octobro\API\Facades\Authorizer');

// Add cors middleware
app('router')->aliasMiddleware('cors', \Barryvdh\Cors\HandleCors::class);

// Add oauth middleware
// $this->middleware(\Octobro\API\Middleware\OAuthExceptionHandlerMiddleware::class);

// Add oauth route middleware
app('router')->aliasMiddleware('oauth' , \Octobro\API\Middleware\OAuthMiddleware::class);
app('router')->aliasMiddleware('oauth-user' , \Octobro\API\Middleware\OAuthUserOwnerMiddleware::class);
app('router')->aliasMiddleware('oauth-client' , \Octobro\API\Middleware\OAuthClientOwnerMiddleware::class);
app('router')->aliasMiddleware('check-authorization-params', \Octobro\API\Middleware\CheckAuthCodeRequestMiddleware::class);

// Handle error
App::error(function(\Exception $e) {
header("Access-Control-Allow-Origin: *");
$trace = $e->getTraceAsString();

// Not sure it's the right way to do...
if (\mb_strpos($trace, 'Octobro\API\Controllers') || \mb_strpos($trace, 'Octobro\API\Middleware\OAuthMiddleware')) {
if (\mb_strpos($trace, 'Octobro\API\Controllers')) {
$error = [
'error' => [
'code' => 'INTERNAL_ERROR',
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# API Framework with oAuth 2.0
# API Framework

It's a plugin for OctoberCMS for you that want to create an extensible and easy to use API server.

Expand Down
298 changes: 0 additions & 298 deletions classes/Authorizer.php

This file was deleted.

0 comments on commit 92358c3

Please sign in to comment.