Giter VIP home page Giter VIP logo

ldczfcuseroauth2's Introduction

LdcZfcUserOAuth2

What?

An extension for zf-oauth2 allowing use of ZfcUser as authentication source


Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality


How?

  1. Install module using Composer

    composer require adamlundrigan/ldc-zfc-user-oauth2:<version>
    
  2. Enable required modules in your application.config.php file:

    • ZfcBase
    • ZfcUser
    • LdcZfcUserOAuth2
  3. Configure ZfcUser

  4. Override the zf-ouath2 configuration to use the provided storage provider:

     return array(
        'zf-oauth2' => array(
            'storage' => 'ldc-zfc-user-oauth2-storage-pdo', 
        ),
    );
    
  5. Override the authentication adapter used by ZfcUser. Locate the auth_adapters key in your zfc-user.global.php config file and replace it with this:

    'auth_adapters' => array( 100 => 'ldc-zfc-user-oauth2-authentication-adapter-db' ),
    

TODO

  • Use ZfcUser's authentication mechanism in OAuth2 server
  • Populate ZfcUser auth storage when OAuth2 server authentication succeeds
  • Some tests might be a good idea
  • Some documentation and an example might also be good ideas

ldczfcuseroauth2's People

Contributors

adamlundrigan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ldczfcuseroauth2's Issues

Cannot authenticate user from ZFC user table

Hi, just trying your module and have few quesions.

I set up Apigility, and oAuth2.
I can make POST to /oauth

{"grant_type":"password", "username":"testuser", "client_id":"testclient2", "password":"testpass" }

('testuser' is stored in oauth tables - oauth_users) and got response:

{"access_token":"e59610ddeab7dd559bcea5e25e46092c7d8f25b1","expires_in":3600,"token_type":"Bearer","scope":null,"refresh_token":"10e6a1769bd133bb766bd87fdea5d86e51d4af1a"}

I believe oauth as is - is working.
I installed zfc user tested /user/login (sing up, login, logout - everything works)

Now I installed LdcZfcUserOAuth2 module, config it by instruction

  • in \vendor\zfcampus\zf-oauth2\config\module.config.php - I added in 'zf-oauth2' => array

'zf-oauth2' => array(
'storage' => 'ldc-zfc-user-oauth2-storage-pdo',
'db' => array(
'dsn' => 'mysql:dbname=mydevtest;host=localhost',
'username' => 'mydevtest',
'password' => 'pass',
),

in this step I must add also 'db' because without it I got error "...configuration ['zf-oauth2']['db'] for OAuth2 is missing..."

  • From \vendor\zf-commons\zfc-user\config\ i copy file 'zfcuser.global.php.dist' to \config\autoload and renamed it to 'zfcuser.global.php' - inside that file I changed 'auth_adapters' to:

'auth_adapters' => array( 100 => 'ldc-zfc-user-oauth2-authentication-adapter-db' ),

After that I test POST to /oauth with user/pass combination from ZFCUser (user) table (created in step when testing ZFCUser's /user/login):
{"grant_type":"password", "username":"[email protected]", "client_id":"testclient2", "password":"password"}

and response is:

{"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"invalid_grant","status":401,"detail":"Invalid username and password combination"}

If i try user/pass from oauth table it works. It seems that it does NOT look for user/pass from ZFC user table..
Any idea/hint how to solve this?

Thnx

Using both ZfcUser Authentication adapter and LdcZfcUserOAuth2

Hello,

We have a large existing project, which uses the ZfcUser module and authentication. Now we must develop a REST API for mobile application and would like to use Apigility with OAuth2 authentication, but still reusing the existing project's code and users.

We are considering to add the REST API in its own module in the existing project to be able to reuse its modules and services. That's why I would like to ask is it possible to use the ZfcUser authentication adapter and LdcZfcUserOAuth2 in the same project?

I see in the LdcZfcUserOAuth2 Readme that we need to override the authentication adapter used by ZfcUser in order to use this one. But can we have them both together and they work with different priorities? Or even allow the LdcZfcUserOAuth2 only for our API module and leave the ZfcUser adapter for all other modules?

Any advice and suggestion how can we do this and connect our API with our existing code will be much appreciated!

Thank you in advance.

Need better documentation or an example :(

Hi, I installed your module. but could not make it work, after following the five steps:

Here is the error message:

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'An alias "zfcuser_zend_db_adapter" was requested but no service could be found.' in \www\ttpApi\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:544

Stack trace:
#0 \www\Api\vendor\zf-commons\zfc-user\Module.php(192): Zend\ServiceManager\ServiceManager->get('zfcuser_zend_db...')

Can you please provide a little more detail on how to install your module? I followed every step to the letter. Not working :(.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.