aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2015-04-26 12:37:58 +0200
committerCamil Staps2015-04-26 12:37:58 +0200
commitbcb71edf812c9c41833d5a66c39844ec35466190 (patch)
tree1a7d04482ca4676b4384fce3367f49e67b8b10f6
parentmigrations have package's namespace for compatibility (diff)
Fixed basic authentication
-rw-r--r--src/CamilStaps/BotleaguesApi/AuthProvider.php18
-rw-r--r--src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php2
-rw-r--r--src/CamilStaps/BotleaguesApi/User.php3
-rw-r--r--src/config/auth.php34
-rw-r--r--src/filters.php3
-rw-r--r--src/migrations/2015_02_23_184402_botleaguesapi-create_users.php2
-rw-r--r--src/routes.php11
7 files changed, 5 insertions, 68 deletions
diff --git a/src/CamilStaps/BotleaguesApi/AuthProvider.php b/src/CamilStaps/BotleaguesApi/AuthProvider.php
deleted file mode 100644
index 6cf152d..0000000
--- a/src/CamilStaps/BotleaguesApi/AuthProvider.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?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 1fbd3e2..f38429f 100644
--- a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
+++ b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
@@ -36,7 +36,7 @@ class BotleaguesApiServiceProvider extends ServiceProvider {
});
// var_dump(Auth::logout());
- var_dump(Auth::check());
+// var_dump(Auth::check());
// var_dump(Auth::attempt(array('email' => 'camilstaps', 'password' => 'secret')));
// var_dump(Config::get('auth'));
diff --git a/src/CamilStaps/BotleaguesApi/User.php b/src/CamilStaps/BotleaguesApi/User.php
index f8cf46b..f9db0ee 100644
--- a/src/CamilStaps/BotleaguesApi/User.php
+++ b/src/CamilStaps/BotleaguesApi/User.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model {
- protected $hidden = array('password', 'remember_token', 'key');
+ protected $table = 'users';
+ protected $hidden = array('password', 'remember_token', 'api_key');
} \ No newline at end of file
diff --git a/src/config/auth.php b/src/config/auth.php
deleted file mode 100644
index ee836e2..0000000
--- a/src/config/auth.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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/filters.php b/src/filters.php
index 17daa3a..b3d9bbc 100644
--- a/src/filters.php
+++ b/src/filters.php
@@ -1,4 +1 @@
<?php
-Route::filter('botleaguesapi-http-auth', function(){
- header('WWW-Authenticate: Basic realm="Botleagues"');
-}); \ No newline at end of file
diff --git a/src/migrations/2015_02_23_184402_botleaguesapi-create_users.php b/src/migrations/2015_02_23_184402_botleaguesapi-create_users.php
index 0df36d0..10d6660 100644
--- a/src/migrations/2015_02_23_184402_botleaguesapi-create_users.php
+++ b/src/migrations/2015_02_23_184402_botleaguesapi-create_users.php
@@ -18,7 +18,7 @@ class BotleaguesapiCreateUsers extends Migration {
$table->string('email', 127)->unique();
$table->string('password', 60);
$table->rememberToken();
- $table->string('key', 255);
+ $table->string('api_key', 255);
$table->timestamps();
});
}
diff --git a/src/routes.php b/src/routes.php
index 1ac35ab..f866789 100644
--- a/src/routes.php
+++ b/src/routes.php
@@ -1,14 +1,5 @@
<?php
-Route::get('users', ['before' => 'auth.basic', function(){
- return 'hello world';
-}]);
-
Route::api(['version' => 'v1', 'protected' => true, 'providers' => 'basic'], function () {
Route::resource('bot', 'CamilStaps\BotleaguesApi\BotController');
Route::resource('user', 'CamilStaps\BotleaguesApi\UserController');
-});
-
-Route::when('bot', 'botleaguesapi-http-auth');
-Route::when('bot/*', 'botleaguesapi-http-auth');
-Route::when('user', 'botleaguesapi-http-auth');
-Route::when('user/*', 'botleaguesapi-http-auth'); \ No newline at end of file
+}); \ No newline at end of file