Name: auth0-extension-boilerplate-hooks
Owner: Auth0
Description: null
Created: 2016-06-06 15:02:15.0
Updated: 2018-04-24 15:29:56.0
Pushed: 2016-09-30 01:07:20.0
Homepage: null
Size: 17
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Auth0 extensions supports hooks where you can add logic for creating artifacts required by your extension like rules
, resource servers
, etc.
For using hooks you will have to do two things.
onInstallPath
and/or onUninstallPath
to your webtask.json
h0": {
reateClient": true,
copes": "create:rules read:rules delete:rules",
nInstallPath": "/.extensions/on-install",
nUninstallPath": "/.extensions/on-uninstall"
use('/.extensions/on-install', ...);
use('/.extensions/on-uninstall', ...);
Note: if you don't add the entries to the webtask.json
Auth0 extensions will not execute the hooks.
Auth0 extensions will call the hook and if everything is OK it will process to install the extension.
In this example, we are creating a rule that will be used by the extension.
s.post('/on-install', function (req, res) {
q.auth0.rules.create({
name: 'extension-rule',
script: "function (user, context, callback) {\n callback(null, user, context);\n}",
order: 2,
enabled: true,
stage: "login_success"
hen(function () {
res.sendStatus(204);
atch(function () {
res.sendStatus(500);
;
Auth0 extensions will call the hook and if everything is OK it will proceed to delete the extension.
In this example, we are deleting the rule created for the extension.
s.delete('/on-uninstall', function (req, res) {
q.auth0
.rules.getAll()
.then(function (rules) {
var rule = _.find(rules, {name: 'extension-rule'});
if (rule) {
req.auth0
.rules.delete({ id: rule.id })
.then(function () {
res.sendStatus(204);
})
.catch(function () {
res.sendStatus(500);
});
}
})
.catch(function () {
res.sendStatus(500);
});
+ Create Extension
https://github.com/auth0/auth0-extension-boilerplate-hooks
continue
install
Auth0 helps you to:
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
This project is licensed under the MIT license. See the LICENSE file for more info.