Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/l4nos/laravel-auth0-multi-tenancy
This package was built to sit alongside the main auth0 package which has limited management API capabilities / facades. This package aims to remedy that..
https://github.com/l4nos/laravel-auth0-multi-tenancy
Last synced: about 1 month ago
JSON representation
This package was built to sit alongside the main auth0 package which has limited management API capabilities / facades. This package aims to remedy that..
- Host: GitHub
- URL: https://github.com/l4nos/laravel-auth0-multi-tenancy
- Owner: l4nos
- License: mit
- Created: 2023-01-22T00:50:27.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-25T20:17:20.000Z (over 1 year ago)
- Last Synced: 2024-09-28T23:21:12.392Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Auth0 Multi Tenancy Management## This is incomplete, but the below items have been tested and are working.
## Intro
This package was built to sit alongside the main auth0 package. Unfortunately that package has limited management API capabilities / facades. This package aims to remedy that.
## Progress
So far the following items are working:
- Authentication
- User Management
- Branding Management
- Organization Management##### As I complete other modules, they will be listed above. If anyone from Auth0 wishes to merge this extra functionality into the main package, please feel free to fork and extract what you need, all I ask is to be credited.
### Documentation Notes
More comprehensive documentation will be written eventually, I'm working on this in my spare time, so you'll need ot bare with me.
For now i'll explain the simple premise. I've essentially created static functions for each endpoint on the API documentation.
### Data Formatting
Unless specified otherwise, all POST endpoints that require body data should be posted exactly as outlined in the corresponding documentation (you can post it as an associated array and the package will convert it to JSON). The same goes for query parameters, all is exactly as the documentation### Authentication Setup
You will need a machine to machine application (client) set up within your auth0 tenant that has management api access. Ideally you should use an application that only accesses the management API, that way any tokens generated from these interactions will not eat into your M2M quote.You can just set these in .env as follows:
````
AUTH0_MGMT_CLIENT_ID=
AUTH0_MGMT_CLIENT_SECRET=
AUTH0_MGMT_DOMAIN=
AUTH0_MGMT_AUDIENCE=
````The reason for the slightly different env variables is that you may wish to use a separate application to authenticate your users and act as your API. Which is recommended as stated above due to token quotas.
## Examples
Once you have added the .env variables you should be good to go. When you make your first request, the package will automatically get a token using the above credentials and store it in cache. Any subsequent requests will not require this unless of course the token has expired, then the package will get a new token.
Each of the endpoint entities is available as an importable class. Given the generic nature of the class naming conventions, it seemed controversial to create these as pre-imported facades as they may conflict with other packages.
Once I have more time I will explore this, for now it's no harm to import the class.
### Get Users
````
2,
"per_page" => 20
];
// This will get page 2 of the results with 20 per page
$paginated = User::get($queryParams);}
````
### Get User Organizations
Gets the tenants / organizations a user belongs to. Handy for multi tenant applications. Again, has the same pagination query param options.
````
2,
"per_page" => 20
];
// This will get page 2 of the results with 20 per page
$paginated = User::organizations($queryParams);}
````
### Add Users To An Organization
````