stormpath / stormpath-laravel

Build simple, secure web applications with Stormpath and Laravel
Other
29 stars 6 forks source link

this package is not working on Laravel 5.2.x #47

Closed nurettintopal closed 8 years ago

nurettintopal commented 8 years ago

when I add "stormpath/laravel": "^0.4" to composer.json file, run ''composer update" from my command line, I have received Runtime Exception.

I think so, this package not compatible with new Laravel 5.2.x

screen shot 2016-05-02 at 16 42 48

bretterer commented 8 years ago

@nurettintopal

I cant seem to re-produce this error. Can you give me step by step what you did here so I can try to troubleshoot this.

Here are the steps that I did.

  1. Run laravel new test
  2. Open composer.json
  3. Add "stormpath/laravel": "^0.4" to require section and save file
  4. Run composer update
  5. Open config/app.php
  6. Add Stormpath\Laravel\Support\StormpathLaravelServiceProvider::class, at the bottom of the providers section and save
  7. Run php artisan optimize

This seems to work on my end. If you have any error logs that is more than what shows in terminal, Please send those along and I can take a look at them.

-Brian

nurettintopal commented 8 years ago

@bretterer

in my project

if you have STORMPATH_CLIENT_APIKEY_ID, STORMPATH_CLIENT_APIKEY_SECRET, STORMPATH_APPLICATION_HREF in your .env file. You can see that exception.

screen shot 2016-05-03 at 08 21 09

screen shot 2016-05-03 at 08 21 49


Also, when I remove STORMPATH_CLIENT_APIKEY_ID, STORMPATH_CLIENT_APIKEY_SECRET, STORMPATH_APPLICATION_HREF from my .env file.

php artisan route:list output :

screen shot 2016-05-03 at 10 24 41

But when .env file has STORMPATH_CLIENT_APIKEY_ID, STORMPATH_CLIENT_APIKEY_SECRET, STORMPATH_APPLICATION_HREF.

php artisan route:list output :

screen shot 2016-05-03 at 10 25 05


When I use only stormpath/sdk without laravel project, I can connect stormpath and login successfuly.

{
    "require": {
        "stormpath/sdk": "1.14.*"
    }
}
<?php

require 'vendor/autoload.php';

\Stormpath\Client::$apiKeyFileLocation = $_SERVER['HOME'] . '/.stormpath/apiKey.properties';
$client = Stormpath\Client::getInstance();

$application = Stormpath\Resource\Application::get('https://api.stormpath.com/v1/applications/XXXXXX');

try {
  $result = $application->authenticate('User', 'Pass');
  $account = $result->account;

  echo "<pre>";
  print_r($account);
} catch (\Stormpath\Resource\ResourceError $e) {
  echo $e->getMessage();
}
nurettintopal commented 8 years ago

@bretterer

I have resolved this issue this way:

stormpath-laravel/src/Support/StormpathLaravelServiceProvider.php

before: $accountStoreArray[] = [ 'href' => $mapping->accountStore->href, 'name' => $mapping->accountStore->name, 'provider' => [ 'href' => $mapping->accountStore->provider->href, 'providerId' => $mapping->accountStore->provider->providerId, ] ];

after: $accountStoreArray[] = [ 'href' => $mapping->accountStore->href, 'name' => $mapping->accountStore->name, 'provider' => [ 'href' => isset($mapping->accountStore->provider->href) ? $mapping->accountStore->provider->href : null, 'providerId' => isset($mapping->accountStore->provider->providerId) ? $mapping->accountStore->provider->providerId : null, ] ];

Do you think that this is a correct way to resolve this issue?

I have sent a pull request(https://github.com/stormpath/stormpath-laravel/pull/48). please review it.

bretterer commented 8 years ago

@nurettintopal please see comments on the PR. I think what is happening here is that your application has something other than directories in the account store mappings. I would guess groups or organizations. This brought in a bug with the laravel integration. We will need to get this resolved.

nurettintopal commented 8 years ago

@bretterer I updated my pull request.

I set the accountStoreArray without provider and if the $mapping->accountStore->provider is exist, I attach it.

I think it seems to be fine.