aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CamilStaps/BotleaguesApi/AuthProvider.php18
-rw-r--r--src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php18
-rw-r--r--src/CamilStaps/BotleaguesApi/User.php2
-rw-r--r--src/config/auth.php34
-rw-r--r--src/routes.php2
5 files changed, 68 insertions, 6 deletions
diff --git a/src/CamilStaps/BotleaguesApi/AuthProvider.php b/src/CamilStaps/BotleaguesApi/AuthProvider.php
new file mode 100644
index 0000000..6cf152d
--- /dev/null
+++ b/src/CamilStaps/BotleaguesApi/AuthProvider.php
@@ -0,0 +1,18 @@
+<?php
+namespace CamilStaps\BotleaguesApi;
+
+use Illuminate\Http\Request;
+use Dingo\Api\Routing\Route;
+use Dingo\Api\Auth\ProviderInterface;
+use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
+
+class AuthProvider implements ProviderInterface {
+
+ public function authenticate(Request $request, Route $route) {
+ var_dump($request, $route):
+ die('hello');
+ }
+
+}
+
+ die('hello'); \ No newline at end of file
diff --git a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
index 76debfd..a13972c 100644
--- a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
+++ b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
@@ -1,8 +1,11 @@
<?php
namespace CamilStaps\BotleaguesApi;
-use \Illuminate\Support\ServiceProvider;
use \Illuminate\Database\Eloquent\ModelNotFoundException;
+use \Illuminate\Support\ServiceProvider;
+use \Illuminate\Support\Facades\Hash;
+use \Illuminate\Support\Facades\Config;
+use \Illuminate\Support\Facades\Auth;
use \Dingo\Api\Facade\API;
use Response;
@@ -22,13 +25,20 @@ class BotleaguesApiServiceProvider extends ServiceProvider {
*/
public function boot()
{
- $this->package('camil-staps/botleagues-api');
+ $this->package('camil-staps/botleagues-api', null, __DIR__.'/../..');
+
+ include __DIR__ . '/../../routes.php';
API::error(function(ModelNotFoundException $e) {
return Response::make(['error' => 'Resource not found'], 404);
});
- include __DIR__ . '/../../routes.php';
+// var_dump(Auth::logout());
+ var_dump(Auth::check());
+// var_dump(Auth::attempt(array('email' => 'camilstaps', 'password' => 'secret')));
+
+// var_dump(Config::get('auth'));
+// var_dump(Config::get('botleagues-api'));
}
/**
@@ -40,7 +50,7 @@ class BotleaguesApiServiceProvider extends ServiceProvider {
{
$this->app->register('Dingo\Api\Provider\ApiServiceProvider');
-
+
}
/**
diff --git a/src/CamilStaps/BotleaguesApi/User.php b/src/CamilStaps/BotleaguesApi/User.php
index 50f37b8..f8cf46b 100644
--- a/src/CamilStaps/BotleaguesApi/User.php
+++ b/src/CamilStaps/BotleaguesApi/User.php
@@ -5,6 +5,6 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model {
-
+ protected $hidden = array('password', 'remember_token', 'key');
} \ No newline at end of file
diff --git a/src/config/auth.php b/src/config/auth.php
new file mode 100644
index 0000000..ee836e2
--- /dev/null
+++ b/src/config/auth.php
@@ -0,0 +1,34 @@
+<?php
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Debug Mode
+ |--------------------------------------------------------------------------
+ |
+ | Enabling debug mode will result in error responses caused by thrown
+ | exceptions to have a "debug" key that will be populated with
+ | more detailed information on the exception.
+ |
+ */
+
+ 'debug' => true,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Providers
+ |--------------------------------------------------------------------------
+ |
+ | The authentication providers that should be used when attempting to
+ | authenticate an incoming API request.
+ |
+ */
+
+ 'auth' => [
+ 'custom' => function ($app) {
+ return new AuthProvider;
+ },
+ ]
+
+];
diff --git a/src/routes.php b/src/routes.php
index 065d24a..2f7a375 100644
--- a/src/routes.php
+++ b/src/routes.php
@@ -3,7 +3,7 @@ Route::get('users', function(){
return 'hello world';
});
-Route::api(['version' => 'v1', 'protected' => true], function () {
+Route::api(['version' => 'v1', 'before' => 'auth'], function () {
Route::resource('bot', 'CamilStaps\BotleaguesApi\BotController');
Route::resource('user', 'CamilStaps\BotleaguesApi\UserController');
}); \ No newline at end of file