wfcreations / yii2-satellizer-server
Yii2 Satellizer server
Installs: 415
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Type:yii2-extension
Requires
- firebase/php-jwt: dev-master
- guzzlehttp/guzzle: 4.2.1
- guzzlehttp/oauth-subscriber: 0.1.2
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-21 05:57:00 UTC
README
Satellizer is a simple to use, end-to-end, token-based authentication module for AngularJS with built-in support for Google, Facebook, LinkedIn, Twitter, Yahoo, Windows Live authentication providers, as well as Email and Password sign-in. You are not limited to the sign-in options above, in fact you can add any OAuth 1.0 or OAuth 2.0 provider by passing provider-specific information during the configuration step.
Installation
The preferred way to install this extension is through composer.
Either run
composer require "wfcreations/yii2-satellizer-server:*"
or add
"wfcreations/yii2-satellizer-server": "*",
to the require
section of your composer.json
file.
Usage
To use this extension, simply add the following code in your application configuration:
'components' => [ 'satellizer' => [ 'class' => \wfcreations\satellizer\Satellizer::className(), 'identityClass' => \common\models\ar\Advertiser::className(), 'tokenLifetime' => 2 * 7 * 24 * 60 * 60, 'jwtKey' => 'jwtsecret', 'facebook' => [ 'clientSecret' => 'facebookscecret', ], ], // ... ]
In your auth controller
use yii\rest\Controller; class AuthController extends Controller { public function actions() { return [ 'facebook' => [ 'class' => 'wfcreations\satellizer\actions\FacebookAction', ], ]; } protected function verbs() { return [ 'facebook' => ['post', 'options'], ]; } // ... }
In others controllers that require authenticated user, just configure authenticator in behaviors:
'authenticator' => [ 'class' => HttpBearerAuth::className(), ],
If you want get authenticated user:
Yii::$app->user->identity
Provider supported
- Foursquare
- Github
- Via email and password
For more information about yii2 api see Guide rest - Quick-start and yii2-app-api.