Download the PHP package macfly/yii2-webserver-auth without Composer

On this page you can find all versions of the php package macfly/yii2-webserver-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-webserver-auth

yii2-webserver-auth

The module allow you to restrict access to any website behind an Nginx or htaccess file can do.

Some useful usage:

Test

There is a complete docker-compose example for Apache HTTPD and Nginx in the example directory, just do :

The yii site is just the yii basic template with the extension installed

You can access the following components:

There is 2 users :

The login and password is used only for SSO on Nginx when you're redirect to http://127.0.0.1:8080/site/login. If you're directly prompt by your browser for login and password you should use login: x-sso-token (name define in the module configuration for token_name) and the access token has the password (for admin user 100-token).

Yii setup

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Configure

Configure config/web.php as follows

The module bootstrap will attached on user component handler macfly\yii\webserver\events\NginxAuthEvent->setTokenCookie on afterLogin and macfly\yii\webserver\events\NginxAuthEvent->unsetTokenCookie on afterLogout.

Nginx setup

Installation

You need to have Nginx Auth Request Module installed ngx_http_auth_request_module

Configure

You need to update the configuration of your Nginx for the site you want to restrict be adding the following elements :

You'll find in the example/nginx/ directory a more advanced configuration.

Usage

From a browser

When you will go to http://www.website.com, if you don't have the cookie defined by token_name (default: x-sso-token) or the identityCookie, you browser will be redirect to http://yii.website.com/site/login. After login you can go again to http://www.website.com and you will get acces to site (if your user has got the right permission).

From a cli

You can also do authentication with cli tool, like wget or curl, in that case you can use two methods:

With an invalid token:

If you don't have permission to access the location (only in sso mode, if you're testing with no-sso return code will be 401):

Apache Httpd setup

Installation

You need to install and enable the module mod_authnz_external.

Because we're using a shell script to do the request you also need to install curl.

You need to put the script apache-auth.sh, on your server which will launch the proper curl command :

Configure

You need to update the configuration of your Httpd server for the site you want to restrict be adding the following elements :

You'll find in the example/httpd/ directory a more advanced configuration.

From a cli

You can also do authentication with cli tool, like wget or curl, in that case you can use following method:

With an invalid token:


All versions of yii2-webserver-auth with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0.13
macfly/yii2-filter-auth-cookie Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package macfly/yii2-webserver-auth contains the following files

Loading the files please wait ....