auth0/auth0-authentication-api-webhooks

Name: auth0-authentication-api-webhooks

Owner: Auth0

Description: This webtask allows you to define webhooks for Auth0's Authentication API. It will go through the audit logs and call a webhook for specific events.

Created: 2016-02-25 16:22:43.0

Updated: 2018-05-10 17:08:53.0

Pushed: 2018-05-24 10:33:44.0

Homepage: null

Size: 185

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Auth0 Authentication API webhooks

Auth0 Extensions

Auth0 Authentication API webhooks allows you to define webhooks for Auth0's Authentication API. It will go through the audit logs and call a webhook for specific events. This can address use cases like:

I want to be notified each time a user is blocked

I want to be notified each time a login fails

Hosting on Webtask.io

If you haven't configured Webtask on your machine run this first:

i -g wt-cli
nit

Requires at least node 0.10.40 - if you're running multiple version of node make sure to load the right version, e.g. “nvm use 0.10.40”

Deploy as a Webtask Cron

If you want to run it on a schedule (run every 5 minutes for example):

m run build
 cron schedule \
--name auth0-auth-api-hooks \
--secret AUTH0_DOMAIN="YOUR_AUTH0_DOMAIN" \
--secret AUTH0_GLOBAL_CLIENT_ID="YOUR_AUTH0_GLOBAL_CLIENT_ID" \
--secret AUTH0_GLOBAL_CLIENT_SECRET="YOUR_AUTH0_GLOBAL_CLIENT_SECRET" \
--secret LOG_LEVEL="1" \
--secret LOG_TYPES="s,f" \
--secret WEBHOOK_URL="http://my.webhook.url/something" \
--secret WEBHOOK_CONCURRENT_CALLS="10" \
--json \
"*/5 * * * *" \
../build/bundle.js

You can get your Global Client Id/Secret here: https://auth0.com/docs/api/v1

The following settings are optional:

How it works

This webtask will process the Auth0 audit logs. Calls to the Authentication API are logged there and will be picked up by the webtask. These will then optionally be filtered will then be sent to your Webhook URL (POST).

Note that, if the URL we are sending the events to is offline or is returning anything that is not 200 OK (eg: Internal Server Error) processing will stop and the batch of logs will be retried in the next run. This means 2 things:

To test this you could easily setup an endpoint on http://requestb.in/ and use that as a Webhook URL.

Filters

The LOG_LEVEL can be set to (setting it to a value will also send logs of a higher value):

The LOG_TYPES filter can be set to:

So for example, if I want to filter on a few events I would set the LOG_TYPES filter to: sce,fce,scu,fcu.

Sample Payload

Here's an example of the payload that will be sent:


te: '2016-02-25T13:42:08.791Z',
pe: 'f',
scription: 'Wrong email or password.',
nnection: 'My-Users',
ient_id: 'lIkP1Wn4qQPj56k9bE7fyMrbsaaHXd6c',
ient_name: 'Default App',
: '11.22.33.44',
er_agent: 'Chrome 48.0.2564 / Mac OS X 10.11.3',
tails:
 error:
  { message: 'Wrong email or password.',
    oauthError: 'Wrong email or password.',
    type: 'invalid_user_password' },
 body:
  { client_id: 'lIkP1Wn4qQPj56k9bE7fyMrbsaaHXd6c',
    username: 'john@example.com',
    password: '*****',
    connection: 'My-Users'',
    grant_type: 'password',
    scope: 'openid',
    device: '' },
 qs: {},
 connection: 'My-Users' },
er_id: '',
er_name: 'Default App',
rategy: 'auth0',
rategy_type: 'database',
d: '49556539073893675610923042044589174982043486779166687234',
Mobile: false

Troubleshooting

To troubleshoot you can use the wt logs command to see the output of your Webtask in real time.

Issue Reporting

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.

Author

Auth0

What is Auth0?

Auth0 helps you to:

Create a free Auth0 Account
  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub or Microsoft Account to login.
License

This project is licensed under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.