snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.21k stars 3.2k forks source link

API Unauthorized #8882

Open zm1868179 opened 3 years ago

zm1868179 commented 3 years ago

Please confirm you have done the following before posting your bug report: I have enabled debug mode I have read checked the Common Issues page Not able to use any API method all method return Unauthorized

To Reproduce Steps to reproduce the behavior: attempted to use Postman and PowerShell to test API with only performing a get request against any API method

User token is generated with a Super Admin user and have attempted other tokens from other users Attempted to grant all perms including super admin and still get unauthorized. Have reinstalled Snipe IT 2 times and still get the same results

Postman image

Powershell: $APIkey = SECRECT-KEY $url = "https://SERVERNAME" $Uri = "$url/api/v1/users" $_headers = @{ "Accept" = "application/json" 'Content-Type' = 'application/json' 'Authorization' = "Bearer $apikey"

    }

Invoke-RestMethod -Method Get -Uri $Uri -Header $_headers

Response : Unauthorized

Expected behavior recieve Hardware list or users etc

Server (please complete the following information):

Snipe-IT Version v5.0.11 - build 5695 (master) OS: Windows Server 2019 Web Server: IIS PHP Version PHP 7.4.13 Desktop (please complete the following information):

OS: Windows 10 Enterprise Browser Microsoft Edge Version 87

welcome[bot] commented 3 years ago

šŸ‘‹ Thanks for opening your first issue here! If you're reporting a šŸž bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

zm1868179 commented 3 years ago

Thought I would give an update here is from the error log:

[2020-12-10 00:11:29] production.ERROR: The resource owner or authorization server denied the request. {"exception":"[object] (League\OAuth2\Server\Exception\OAuthServerException(code: 9): The resource owner or authorization server denied the request. at C:\inetpub\wwwroot\snipit\vendor\league\oauth2-server\src\Exception\OAuthServerException.php:243) [stacktrace]

0 C:\inetpub\wwwroot\snipit\vendor\league\oauth2-server\src\AuthorizationValidators\BearerTokenValidator.php(84): League\OAuth2\Server\Exception\OAuthServerException::accessDenied()

1 C:\inetpub\wwwroot\snipit\vendor\league\oauth2-server\src\ResourceServer.php(84): League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator->validateAuthorization()

2 C:\inetpub\wwwroot\snipit\vendor\laravel\passport\src\Guards\TokenGuard.php(184): League\OAuth2\Server\ResourceServer->validateAuthenticatedRequest()

3 C:\inetpub\wwwroot\snipit\vendor\laravel\passport\src\Guards\TokenGuard.php(131): Laravel\Passport\Guards\TokenGuard->getPsrRequestViaBearerToken()

4 C:\inetpub\wwwroot\snipit\vendor\laravel\passport\src\Guards\TokenGuard.php(94): Laravel\Passport\Guards\TokenGuard->authenticateViaBearerToken()

5 C:\inetpub\wwwroot\snipit\vendor\laravel\passport\src\PassportServiceProvider.php(283): Laravel\Passport\Guards\TokenGuard->user()

6 [internal function]: Laravel\Passport\PassportServiceProvider->Laravel\Passport\{closure}()

7 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Auth\RequestGuard.php(58): call_user_func()

8 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Auth\GuardHelpers.php(60): Illuminate\Auth\RequestGuard->user()

9 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php(62): Illuminate\Auth\RequestGuard->check()

10 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php(41): Illuminate\Auth\Middleware\Authenticate->authenticate()

11 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Auth\Middleware\Authenticate->handle()

12 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

13 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(683): Illuminate\Pipeline\Pipeline->then()

14 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(658): Illuminate\Routing\Router->runRouteWithinStack()

15 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(624): Illuminate\Routing\Router->runRoute()

16 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Routing\Router.php(613): Illuminate\Routing\Router->dispatchToRoute()

17 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(170): Illuminate\Routing\Router->dispatch()

18 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()

19 C:\inetpub\wwwroot\snipit\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php(58): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

20 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()

21 C:\inetpub\wwwroot\snipit\app\Http\Middleware\SecurityHeaders.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

22 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): App\Http\Middleware\SecurityHeaders->handle()

23 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

24 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()

25 C:\inetpub\wwwroot\snipit\app\Http\Middleware\CheckForDebug.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

26 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): App\Http\Middleware\CheckForDebug->handle()

27 C:\inetpub\wwwroot\snipit\app\Http\Middleware\CheckForSetup.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

28 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): App\Http\Middleware\CheckForSetup->handle()

29 C:\inetpub\wwwroot\snipit\vendor\fideloper\proxy\src\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

30 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle()

31 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

32 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\View\Middleware\ShareErrorsFromSession->handle()

33 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(56): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

34 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle()

35 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

36 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()

37 C:\inetpub\wwwroot\snipit\vendor\barryvdh\laravel-cors\src\HandlePreflight.php(29): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

38 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Barryvdh\Cors\HandlePreflight->handle()

39 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

40 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(145): Illuminate\Pipeline\Pipeline->then()

41 C:\inetpub\wwwroot\snipit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()

42 C:\inetpub\wwwroot\snipit\public\index.php(58): Illuminate\Foundation\Http\Kernel->handle()

43 {main}

"}