Giter VIP home page Giter VIP logo

zf3-apigilty-oauth2's Introduction

API Development using ZF3, Apigility with OAuth2 support

Requirements

Please see the composer.json file.

Installation

Via Composer (create-project)

You can use the create-project command from Composer to create the project in one go (you need to install composer):

$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ ./composer create-project -sdev aqilix/zf3-apigilty-oauth2 path/to/install

Via Git (clone)

First, clone the repository:

# git clone https://github.com/aqilix/zf3-apigilty-oauth2.git # optionally, specify the directory in which to clone
$ cd path/to/install

I have prepare docker-compose.yml, so you can use docker-compose to build this application.

docker-compose up -d

Install dependencies via the container:

docker-compose run api composer install

Manipulate dev mode from the container:

docker-compose run api composer development-enable
docker-compose run api composer development-status

Creating Database

docker-compose run api composer development-db-create

Importing Data Fixtures

docker-compose run api composer development-db-data-fixture-import

Or if you don't want to use Docker, you need to use Composer to install dependencies. Assuming you already have Composer:

$ ./composer install

Configuration

There are several configuration files in config/autoload/*.local.php.dist need to be configured to use this application. And please remove .dist extension on the files. Example:

mv config/autoload/local.php.dist config/autoload/local.php

Database Configuration

For database configuration, the related files need to be configured are:

Email Transport Configuration

To configure mail transport, please modify this file mailtransport.local.php.dist. For this example, I use Mailgun you can use another mail service by configure host, username and password.

Email Configuration

At the moment, there are 3 events send emails from this application.

  • Signup (Welcome Email)
  • Account Activated
  • Request Reset Password

You can configure the From, Sender Name, and Subject from this file user.local.php.dist

Project Configuration

For project configuration, there are 2 sections configuration. Those are sites and php_process. I think you just need to configure sites section to adjust with url on your site. And php_process is purposed to configure cli.

CORS Configuration

You can configure zfr-cors on this file zfr_cors.local.php.dist

Run Application

After configure all configs, you can access this application from browser http://localhost:8080 (I configure this container using port 8080).

If you have set this as dev mode you will see Apigility Admin on this url http://localhost:8080/apigility/ui#/

API Testing

I use Swagger for built in API Documentation. You can see it on dev mode by access this URL http://localhost:8080/apigility/swagger. You also can try the API Resources by using this Swagger

zf3-apigilty-oauth2's People

Contributors

dollyaswin avatar man4red avatar sergiohermes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zf3-apigilty-oauth2's Issues

frontend resetpassword and activation url

Dear Mr. Dolly,

I have a doubt regarding the url for the reset password and activation url. I do not see any code for these sites.

correct me if I am wrong, but from the code what I understand is that after the user signs up, the user would then get an email with an activation url https://aqilix.xyz/user/activation/:code that says i.e. "Your Account has been registered",

and if the user sent a resetpassword user would get an email with the resetpassword URL, now where would the resetpassword form would be? do i need to develop it myself? or does this source code handle it by itself?

I know they are located in project.global.php,

'sites' => [
           'reset_password_url' => 'https://aqilix.xyz/user/resetpassword/:code',
           'activation_url' => 'https://aqilix.xyz/user/activation/:code',

my question is, do I need to write a code for them? or are they included?

Regards,
uggy

EmailController extends AbstractActionController

is it correct?

...
use Zend\Mvc\Controller\AbstractActionController;
...
class EmailController extends AbstractActionController
...

to

use Zend\Mvc\Console\Controller\AbstractConsoleController;
...
class EmailController extends AbstractConsoleController
...

UnauthorizedUserListener break on Zend\Console\Response

'/usr/bin/php' '/var/www/domains/zf3-apigilty-oauth2.local/data/public/index.php' 'v1' 'user' 'send-welcome-email'

Fatal error: Uncaught Error: Call to undefined method Zend\Console\Response::getStatusCode() in /var/www/domains/zf3-apigilty-oauth2.local/data/module/User/src/Service/Listener/UnauthorizedUserListener.php on line 16

Error: Call to undefined method Zend\Console\Response::getStatusCode() in /var/www/domains/zf3-apigilty-oauth2.local/data/module/User/src/Service/Listener/UnauthorizedUserListener.php on line 16

Call Stack:
    0.0002     350800   1. {main}() /var/www/domains/zf3-apigilty-oauth2.local/data/public/index.php:0
    0.1724    3758376   2. Zend\Mvc\Application->run() /var/www/domains/zf3-apigilty-oauth2.local/data/public/index.php:43
    4.8272    4324832   3. Zend\Mvc\Application->completeRequest() /var/www/domains/zf3-apigilty-oauth2.local/data/vendor/zendframework/zend-mvc/src/Application.php:348
    4.8280    4331496   4. Zend\EventManager\EventManager->triggerEvent() /var/www/domains/zf3-apigilty-oauth2.local/data/vendor/zendframework/zend-mvc/src/Application.php:371
    4.8280    4331496   5. Zend\EventManager\EventManager->triggerListeners() /var/www/domains/zf3-apigilty-oauth2.local/data/vendor/zendframework/zend-eventmanager/src/EventManager.php:171
    4.8280    4332176   6. User\Service\Listener\UnauthorizedUserListener->__invoke() /var/www/domains/zf3-apigilty-oauth2.local/data/vendor/zendframework/zend-eventmanager/src/EventManager.php:322

I believe it's here

Service/Listener/UnauthorizedUserListener.php

    public function __invoke(MvcEvent $mvcEvent)
    {
        $mvcResponse = $mvcEvent->getResponse();
        if ($mvcResponse->getStatusCode() === \Zend\Http\Response::STATUS_CODE_401) {
            $mvcResponse->getHeaders()->addHeaderLine('Www-Authenticate', 'Bearer realm="Service"');
        }
        return;
    }

Is it correct to fix it like this or am I doing smth wrong?

    public function __invoke(MvcEvent $mvcEvent)
    {
        $mvcResponse = $mvcEvent->getResponse();
        if (!($mvcResponse instanceof \Zend\Console\Response) && $mvcResponse->getStatusCode() === \Zend\Http\Response::STATUS_CODE_401) {
            $mvcResponse->getHeaders()->addHeaderLine('Www-Authenticate', 'Bearer realm="Service"');
        }

        return;
    }

Send Mail without Mailgun?

Firstly, terima kasih banyak atas project ini yang saya cari carii berbulanbulan. I have zero experience in php, but I ultimately have a good understanding of how the system and the api works. I don't think I'll be asking this question if not from the above.

but is Mailgun necessary in order to advance? I haven't cloned the project yet. I just read through the source code.

I am hoping to use my Hosting providers smtp mailer instead of Mailgun. I know Mailgun is an impressive validator, but I believe my own webmail server could handle these events.

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.