gandra404

Experience

4,320

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 35 Lessons Completed
  • 0 Favorites

30th January, 2017

gandra404 left a reply on Authenticating With Eloquent And Without Database (How To Handle User Roles And Permissions?) • 1 year ago

@Dario , inside CustomUserProvider therte is a function:

protected function createUser($model, $body_resp)`{
    ....
}

$model is created in createModel() function inside CustomGuard. What is the type of $model? GenericUser?

gandra404 left a reply on Authenticating With Eloquent And Without Database (How To Handle User Roles And Permissions?) • 1 year ago

I will check it. Thanks! Meanwhile I have made something with laravel 5.4 , laravel passport and custom user provider but curerntly have some issue ... you can check it here if you can help: http://stackoverflow.com/questions/41947149/how-to-fix-unauthorized-access-on-post-oauth-token

And I believe that this example could be valuable for others who are looking for similar solution.

gandra404 started a new conversation How To Fix Unauthorized Access On POST /oauth/token? • 1 year ago

I am trying to make demo of SPA app in Vue.js which communicates with backend API made in laravel 5.4 with passport and oauth. I am passing along with tutorial on https://www.youtube.com/watch?v=JEn16aQoowE&list=PLkZU2rKh1mT9TgMvpFY1QVrX2z4I3D3Jq&index=1

The only difference is that my backend API has Custom User Provider to simulate autehntication to another database table via table view.

POST to http://127.0.0.1:8000/oauth/token gives me following eror:

Response {url: "http://127.0.0.1:8000/oauth/token", ok: false, status: 401, statusText: "Unauthorized", headers: Headers…}

Here is how to reproduce it:

  1. Setup backend API:
git clone https://github.com/gandra/laravel54-passport-demo-external-user
cd laravel54-passport-demo-external-user
cp .env.example .env
composer install
php artisan key:generate
npm install
npm run dev
php artisan migrate
php artisan db:seed
php artisan passport:install
  1. Update your laravel54-passport-demo-external-user/.env file with your database info

  2. Bring up API server with:

php artisan serve  
  1. Setup frontend:
git clone https://github.com/gandra/laravel54-passport-demo-vue-client.git
cd laravel54-passport-demo-vue-client
npm install
  1. Update client secret in laravel54-passport-demo-vue-client\src\App.vue with value of secret field from table oauth_clients where name = 'Laravel Password Grant Client'

  2. Bring up frontend:

npm run dev

This should open url http://localhost:8080/ in browser. Open browser console and check for error. You will see something like this:

enter image description here

gandra404 started a new conversation Custome Guard Or Custom User Provider? • 1 year ago

My laravel app should authenticate over extwernal database/API so I need to implement one of the following approaches:

  1. Create custom guard
  2. Create custom user provder

What is the difference between this 2 approaches?

I have succeed to implement custom User provider using this as starting point: http://stackoverflow.com/questions/41912867/can-i-put-and-retrieve-the-user-information-to-and-from-session-into-a-laravel-c

According to https://gistlog.co/corbosman/d0951f9c6cdba20f644e: The docs don't mention this, but you can actually use the same method to replace the Guard class as you use to replace the UserProvider.

So this is the main question.

Another question is related to Guard class itself. Almost all articles on net talks about extending the base Guard class. I ma using laravel 5.4 and I can not find base Guard class? I have found only Guard interface so I canot extend it. I have to implement it?

gandra404 left a reply on L5 Extending Auth Guard • 1 year ago

Seems that in laravel 5.4 there is no generic Guard? There is only interface you should implement it?

29th January, 2017

gandra404 left a reply on Authenticating With Eloquent And Without Database (How To Handle User Roles And Permissions?) • 1 year ago

@Dario , can you put in some public repo(github, gitlab, bitbucket, ...) Prrof of Concept code?

Best, Dragan

gandra404 left a reply on Can I Use Laravel Passport For SSO? • 1 year ago

No, seems that laravel passport is not made for this purpose.

The closest thing I have found, for similar use case, so far is this: https://laracasts.com/discuss/channels/laravel/authenticating-with-eloquent-and-without-database-how-to-handle-user-roles-and-permissions

In this use case user, roles and permissions table are in another database managed by another system.

Anyway, still looking for better solution for my question.

26th January, 2017

gandra404 started a new conversation Can I Use Laravel Passport For SSO? • 1 year ago

I am also wondering is it possible to use laravel passport as pure oauth/SSO server ? I mean the following:

  • I have 3 different project in different code bases.
  • I want to introduce SSO ad fourth project/codebase

Could I achieve it using laravel passport?

24th January, 2017

gandra404 started a new conversation Laravel Passport, Oauth Scopes And Roles And Permissions • 1 year ago

Hi! I am developing SPA in angular and backend API in laravel 5.3. I have integrated laravel passport for oauth.

I have to make roles and permissions impl using views on tables from other database which is maintained by other system. In this system user has 1 role. And role has self reference so there is hierarchical structure, for example:

  • canSeeAnimals
  • canSeeMammals (child of canSeeAnimals)
  • canSeeWolf (child of canSeeMammals)

So I am thinking of following workflow but not sure hjow to implement it:

  1. Another system manage users, roles and permissions
  2. API server(under my control) has access to another system tables via views:
    • user
    • role
    • v_role_level (in this table is defined parent child relationship between roles)
  3. Client app(angular) request resource from the API server
  4. API server load users data with roles and permissions and generate token with scope which is mapped to roles and permissions.

Point 4 is under the question. How I can manage to intercept/override token generation in order generate token with scope which depends on user roles and permissions?

gandra404 started a new conversation Romanbican/roles Vs Zizaco/entrust For Roles And Permissions • 1 year ago

I am working on laravel 5.3 project and evaluation following packages for roles and permissions:

They are pretty similar and both looks promising. One advantage Zizaco/entrust has over romanbican/roles is ability to use AND/OR operators in the middleware(https://github.com/romanbican/roles/issues/208)

Great advantage of romanbican/roles over Zizaco/entrust is Permissions Inheriting (https://github.com/romanbican/roles#permissions-inheriting)

I have to make roles and permissions impl using views on tables from other database which is maintained by other system. In this system user has 1 role. And role has self reference so there is hierarchical structure, for example:

  1. canSeeAnimals
  2. canSeeMammals (child of canSeeAnimals)
  3. canSeeWolf (child of canSeeMammals)

So, for this use case romanbican/roles is better suited than Zizaco/entrust?

Feedback?

22nd January, 2017

gandra404 started a new conversation How To Run Laravel Database Seeder From Phpunit Test SetUp? • 1 year ago

I am trying to recreate database before each tests in some phpunit teast case. I am using laravel 5.3. Here is TestCase:

class CourseTypesTest extends TestCase
{
    public function setUp()
    {
        parent::setUp();
        Artisan::call('migrate');
        Artisan::call('db:seed', ['--class' => 'TestDatabaseSeeder ', '--database' => 'testing']);
    }

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function test_list_course_types()
    {
        $httpRequest = $this->json('GET', '/api/course-types');
        $httpRequest->assertResponseOk();
        $httpRequest->seeJson();

    }

    public function tearDown()
    {
        Artisan::call('migrate:reset');
        parent::tearDown();
    }
}

Running phpunit fails with error:

$ phpunit PHPUnit 5.7.5 by Sebastian Bergmann and contributors.

E 1 / 1 (100%)

Time: 2.19 seconds, Memory: 12.00MB

There was 1 error:

  1. CourseTypesTest::test_list_course_types ReflectionException: Class TestDatabaseSeeder does not exist

D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.php:749 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.php:644 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:709 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.php:74 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.php:63 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:2292 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.php:64 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.php:508 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Command.php:169 D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Command\Command.php:254 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Command.php:155 D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.php:821 D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.php:187 D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.php:118 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Application.php:107 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:218 D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:237 D:\www\learn-laravel\my-folder-api\tests\rest\CourseTypesTest.php:17

ERRORS! Tests: 1, Assertions: 0, Errors: 1.

but this class exists: TestDatabaseSeeder inside database/seeds

10th January, 2017

gandra404 left a reply on Which Use To Create APIs, Built-in Laravel 5.3 Features Or Dingo ? • 1 year ago

This reply from https://github.com/dingo/api/issues/1189add some value to discussion:

I am not so sure this is true. It depends very much on your use case. Passport for example is very focused on having other people build applications for your API, which might not be what your use-case is.

Also I do not think Laravel comes with any kind of Transformers, does it?

gandra404 left a reply on Which Use To Create APIs, Built-in Laravel 5.3 Features Or Dingo ? • 1 year ago

This question is related to this discussion: https://laracasts.com/discuss/channels/laravel/internal-usage-of-passport-for-own-api

I am still not sure what advatages I will have if using dingo with passport and what approach should I take.

gandra404 started a new conversation Use Built-in Laravel 5.3 Features Or Dingo To Create APIs? • 1 year ago

I asking the very same question as http://stackoverflow.com/questions/40058456/use-built-in-laravel-5-3-features-or-dingo-to-create-apis

I want to create my first API that can respond to any kind of clients like Android , iOS or an Angular powered Application. I've done a lot of research in this case that How can I make an API via laravel. I found that there is a package named dingo/api that simplifies and provide requirements to create flexible APIs. And in the other hand, in last version of Laravel (5.3) added new features that help to create APIs like Passport. But I am confused and do not know which are best approach. Whether the use of Laravel in this case alone is enough? or will I surely need Dingo?

Aside, I have foiund some interesting bolirplate https://github.com/francescomalatesta/laravel-api-boilerplate-jwt

According to this https://github.com/dingo/api/issues/1159 dingo already has some support for passport.

So, any feedback on going with dingo or passport or both?

9th January, 2017

gandra404 left a reply on Laravel CI Testing With GitLab • 1 year ago

Finally I manage to run sucesfully tests on GitLab. Here is the project: https://gitlab.com/gandra404/ticketbeast

This article helped me a lot: https://woohuiren.me/blog/how-to-laravel-testing-on-gitlab-ci-with-docker/

I have code on GitLab. Runner installed on my host(probably would work only with shared runner?) with docker as executor.

I have copied this files in my root: https://github.com/GIANTCRAB/gitlabby-dockerish-laravel

8th January, 2017

gandra404 left a reply on Laravel CI Testing With GitLab • 1 year ago

I have just tried @Refringe setup and Gitlab build fails with similar error as @Mythos33. I have copied files from https://github.com/didikz/laravel-gitlab-ci into my project and push it into GitLab and build fails with error:

Running with gitlab-ci-multi-runner 1.9.0 (82714ae)
Using Docker executor with image php:5.6 ...
Pulling docker image mysql:5.6 ...
Starting service mysql:5.6 ...
Waiting for services to be up and running...
Pulling docker image php:5.6 ...
Running on runner-e11ae361-project-2277718-concurrent-0 via runner-e11ae361-machine-1483904340-0654037a-digital-ocean-4gb...
Cloning repository...
Cloning into '/builds/gandra404/ticketbeast'...
Checking out bacd084d as master...
$ bash .gitlab-ci.sh
$ php vendor/bin/phpunit --colors
Could not open input file: vendor/bin/phpunit
ERROR: Build failed: exit code 1

gandra404 left a reply on Laravel CI Testing With GitLab • 1 year ago

I have just tried @Refringe setup and Gitlab build fails. I have copied files from https://github.com/didikz/laravel-gitlab-ci into my project and push it into GitLab and build fails with error:

Running with gitlab-ci-multi-runner 1.9.0 (82714ae)
Using Docker executor with image php:5.6 ...
Pulling docker image mysql:5.6 ...
Starting service mysql:5.6 ...
Waiting for services to be up and running...
Pulling docker image php:5.6 ...
Running on runner-e11ae361-project-2277718-concurrent-0 via runner-e11ae361-machine-1483904340-0654037a-digital-ocean-4gb...
Cloning repository...
Cloning into '/builds/gandra404/ticketbeast'...
Checking out bacd084d as master...
$ bash .gitlab-ci.sh
$ php vendor/bin/phpunit --colors
Could not open input file: vendor/bin/phpunit
ERROR: Build failed: exit code 1

gandra404 left a reply on Homestead Environment Encapsulation • 1 year ago

So in order to fix it I had to:

  • ssh into vagrant
  • install phpunit

and then run tests succesfully:

vagrant ssh
composer global require phpunit/phpunit
cd hello-world
phpunit

gandra404 started a new conversation Homestead Environment Encapsulation • 1 year ago

I am confused with homestead. I thought that its primary objective is to encapsulate environment. I have created fresh laravel project and add homestead with following commands:

laravel new hello-world
cd hello-world
composer require laravel/homestead --dev
homestead make

Then I have booted up Vagrant VM: vagrant up and logged in via ssh: vagrant ssh

Then I have tried to execute test:

cd hello-world
phpunit

and following error occurs: -bash: phpunit: command not found

So homestead VM does not have encapsulated phpunit?

If I log out from ssh and execut phpunit on host machine than everything is fine. So even if I am using homestead I have to configure env on host machine in order to execute tests?

6th January, 2017

gandra404 left a reply on How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

@svpernova09, I totallly agree with you. But at the moment company has site on shared hosting with PHP 5.4. Any new deploy of functionality may be broken if developer couint on some feature in PHP > 5.4 and he is not able to test it before delivery. Until migration is made reality is that production is on PHP 5.4 and we have to live with that fact untill migration. So looking for solution how to mimic that enviroment.

5th January, 2017

gandra404 left a reply on How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

@svpernova09, I have succeed to install env with PHP 5.5.9. Can you provide code behind your vagrant box to try to accomodate it to use php 5.4?

gandra404 left a reply on How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

@svpernova09, error instralling homestead-legacy ....

==> default: Box 'Svpernova/homestead-legacy' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
The box 'Svpernova/homestead-legacy' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://atlas.hashicorp.com/Svpernova/homestead-legacy"]
Error: The requested URL returned error: 404 Not Found

22nd December, 2016

gandra404 left a reply on How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

@svpernova09, according to this: https://github.com/laravel/homestead/blob/v2.2.1/composer.json v2.2.1 shouild work? Thaks for info!

gandra404 left a reply on How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

Thanks @TerrePorter ! I didn't find which homestead version has which PHP version. Here is example of what info is provided for some homestead version: https://i.imgur.com/sJ61n3k.png

Meanwhile I have found how to get this info. Seems that homestead v2.2.2 supports php 5.4: https://github.com/laravel/homestead/blob/v2.2.2/composer.json

So I will try to checkout this version of homestead.

gandra404 started a new conversation How To Setup Homestead With Php 5.4 On Linux? • 1 year ago

There is one production app made in laravel 4 on shared hosting which still use php 5.4. I have linux development machine with php 7. Is it possible to install homestead with php 5.4? If yes, please feedback how.

14th December, 2016

gandra404 left a reply on Localization Series • 1 year ago

+1

25th July, 2016

gandra404 started a new conversation How To Acces Is_* Property In Laravel Model? • 2 years ago

I am working with laravel 4.2 and have table in db with property is_active. When I try to access this model property: $model->is_active I am getting following error:

Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation So question is how to access this property? This is already existing database in production so renaming field in the database is the ultimate option.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.