Download the PHP package own3d/id without Composer
On this page you can find all versions of the php package own3d/id. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package id
OWN3D ID
PHP OWN3D ID API Client for Laravel 5+
Table of contents
- Installation
- OAuth2 Documentation
- Remarks
- Socialite Event Listener
- Configuration
- Examples
- Documentation
- Development
Installation
Install the own3d id package with composer:
OAuth2 Documentation
You can find the documentation for OAuth2 here. There you can find all the information about registering your application and the scopes you can request.
Remarks
In the StreamTV / OWN3D ID Library all SSO IDs are defined as strings. This comes from the origin that all IDs should become UUIDs. We will simply continue the id assignment on big-integers, since we never implemented this step. We recommend to store all ids as big-integers (20) in your database. It is not guaranteed that we will assign IDs incrementally.
E-Mail Verification
Every oauth client needs to check itself if they need a (verified) email address from the user.
The current email address can be fetched via /api/users/@me
, it will be returned in the email
attribute.
To see if the email is verified by the user, you can lookup the email_verified_at
attribute.
If the email
attribute is null
, this means the user has no email associated with his account.
You need to call /api/users/@me/update-email
by yourself to assign and trigger the email verification process.
Socialite Event Listener
- Add
SocialiteProviders\Manager\SocialiteWasCalled
event to yourlisten[]
array inapp/Providers/EventServiceProvider
. - Add your listeners (i.e. the ones from the providers) to the
SocialiteProviders\Manager\SocialiteWasCalled[]
that you just created. - The listener that you add for this provider is
'Own3d\\Id\\Socialite\\Own3dIdExtendSocialite@handle',
. - Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
Configuration
Copy configuration to config folder:
Add environmental variables to your .env
You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command artisan config:cache
) all config is still available.
Add to config/services.php
:
Examples
Basic
Setters
OAuth Tokens
Facade
Documentation
Oauth
Users
Events
OAuth Scopes Enums
Protecting Routes
Via Middleware
OWN3D ID includes an authentication guard that will validate access tokens on incoming requests. Once you have configured the api
guard to use the own3d-id
driver, you only need to specify the auth:api
middleware on any routes that should require a valid access token:
Multiple Authentication Guards
If your application authenticates different types of users that perhaps use entirely different Eloquent models, you will likely need to define a guard configuration for each user provider type in your application. This allows you to protect requests intended for specific user providers. For example, given the following guard configuration the config/auth.php
configuration file:
The following route will utilize the api-customers guard, which uses the customers user provider, to authenticate incoming requests:
Token Scopes
Scopes allow your application's users to limit the actions a third-party application can perform on their behalf. For example, not all API consumers will need the ability to fetch entitlements.
Defining Scopes
Scopes are registered globally by the OWN3D ID service. If a OWN3D first-party specific application needs a additional scope, then they need to define it in the OWN3D ID service.
Assigning Scopes To Tokens
When requesting an access token using the authorization code grant, consumers should specify their desired scopes as the scope
query string parameter. The scope
parameter should be a space-delimited list of scopes:
Requesting all Tokens
When using the password grant or client credentials grant, you may wish to authorize the token for all of the scopes supported by your application. You can do this by requesting the *
scope. If you request the *
scope, the can
method on the token instance will always return true
. This scope may only be assigned to a token that is issued using the password
or client_credentials
grant:
Checking Scopes
Using the
scopes
andscope
middleware requires a authorization guard. For first-party apps, you may want to use a special authentication guard to create users dynamically. If you're interested in machine-to-machine authentication or want to skip the authorization guard, then have a look at client credentials grant tokens.
OWN3D ID includes two middleware that may be used to verify that an incoming request is authenticated with a token that has been granted a given scope. To get started, add the following middleware to the $routeMiddleware
property of your app/Http/Kernel.php
file:
Check For All Scopes
The scopes
middleware may be assigned to a route to verify that the incoming request's access token has all of the listed scopes:
Check For Any Scopes
The scope
middleware may be assigned to a route to verify that the incoming request's access token has at least one of the listed scopes:
Checking Scopes On A Token Instance
Once an access token authenticated request has entered your application, you may still check if the token has a given scope using the tokenCan
method on the authenticated App\Models\User
instance:
Client Credentials Grant Tokens
The client credentials grant is suitable for machine-to-machine authentication. For example, to performing maintenance tasks over an API.
Before your application can issue tokens via the client credentials grant, you will need to request a client credentials grant client. You may do this by writing to [email protected].
Next, to use this grant type, you need to add the CheckClientCredentials
middleware to the $routeMiddleware
property of your app/Http/Kernel.php
file:
Then, attach the middleware to a route:
To restrict access to the route to specific scopes, you may provide a comma-delimited list of the required scopes when attaching the client
middleware to the route:
Using OWN3D ID as API Guard
If you want to accept OWN3D ID Access tokens within you API Server, you can easily add/modify your guards, to enable support.
If you also want to generate users automatically in your local database, then use the sso-users
provider within your api
guard.
config/auth.php
:
After configure your guards, you need to register the own3d-id
and sso-users
drivers within your AuthServiceProvider
.
Development
Run Tests
Generate Documentation
All versions of id with dependencies
ext-json Version *
illuminate/support Version ~5.4|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/console Version ~5.4|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
guzzlehttp/guzzle Version ^6.3|^7.0
socialiteproviders/manager Version ^3.4|^4.0.1
doctrine/dbal Version ^2.10|^3.6|^4.0
firebase/php-jwt Version ^6.2