Created
May 13, 2014 06:02
-
-
Save dannewns/7ab8b933c8cf24865f8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Patina\Extensions; | |
use Illuminate\Http\Request; | |
use Illuminate\Routing\Route; | |
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; | |
class PatinaApiAuthenticationProvider extends \Dingo\Api\Auth\Provider { | |
/** | |
* Illuminate authentication manager. | |
* | |
* @var \Illuminate\Auth\AuthManager | |
*/ | |
protected $auth; | |
/** | |
* Create a new Dingo\Api\Auth\BasicProvider instance. | |
* | |
* @param \Illuminate\Auth\AuthManager $auth | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->auth = new \ParseRestClient; | |
} | |
/** | |
* Authenticate request with Basic. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Illuminate\Routing\Route $route | |
* @return int | |
*/ | |
public function authenticate(Request $request, Route $route) | |
{ | |
$this->validateAuthorizationHeader($request); | |
return '12'; | |
} | |
/** | |
* Get the providers authorization method. | |
* | |
* @return string | |
*/ | |
public function getAuthorizationMethod() | |
{ | |
return 'custom'; | |
} | |
} | |
my configuration looks like below | |
/* | |
|-------------------------------------------------------------------------- | |
| Authentication Providers | |
|-------------------------------------------------------------------------- | |
| | |
| The authentication providers that should be used when attempting to | |
| authenticate an incoming API request. | |
| | |
*/ | |
'auth' => [ | |
'custom' => function($app) | |
{ | |
return new \Patina\Extensions\PatinaApiAuthenticationProvider; | |
} | |
], | |
when i try and hit a api endpoint that has a protected route internally it doesnt seemt to go into the authentication provider at all, when i use postman it does go into it but then i get issues with it asking for my user model which i dont have as the site doesnt use eloquent models its using parse to authenticate im not 100% sure what im doing wrong her, any thoughts? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey sorry for the late reply. Only just installed Skype on my new laptop. Internal API calls bypass any authentication. This could be related to this: dingo/api#56