PUT /api/webtask/TENANT_NAME/HOOK_NAME HTTP/1.1
Host: sandbox.it.auth0.com
Authorization: Bearer YOUR_WEBTASK_TOKEN
Content-Type: application/json
{
"code": "module.exports = function (user, context, cb) { /* YOUR CODE HERE */ }",
"meta": {
"wt-compiler": "auth0-ext-compilers/pre-user-registration",
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const FILENAME = 'tham.json' | |
const lines = fs.readFileSync(FILENAME, 'utf8').split('\n').filter(x => !!x) | |
const connections = {} | |
lines.map(l => JSON.parse(l)).forEach(user => { | |
user.identities.forEach(id => { | |
const conn = id.connection | |
if (connections[conn]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateResults = (err, authResult) => { | |
if (err) { | |
// handle error | |
} else { | |
const at = authResult.accessToken; | |
// A naïve check to verify if we received a JWT access token | |
if (!at || !at.startsWith('eyJ')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function (user, context, callback) { | |
// Ensure every user has the user role | |
if (context.authorization.roles.length === 0) { | |
console.log(`No roles for the user ${user.user_id}. Assigning default role`); | |
try { | |
const request = require('request-promise'); | |
await request.post(`${auth0.baseUrl}/users/${user.user_id}/roles`, { | |
body: { | |
"roles": ["rol_6KcsnzJ7Bd4YZeG1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xpath = require('xpath') | |
const dom = require('xmldom').DOMParser | |
const crypto = require('crypto') | |
const fs = require('fs') | |
const calcThumbprint = function (cert) { | |
const shasum = crypto.createHash('sha1') | |
const der = new Buffer(cert, 'base64').toString('binary') | |
shasum.update(der, 'binary') | |
return shasum.digest('hex') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(user, context, callback) { | |
var _ = require('lodash'); | |
var groupsAllowed = ['group1', 'group2', 'group3']; | |
var userHasAccess = _.intersection(user.groups, groupsAllowed) > 0; | |
if (!userHasAccess) { | |
return callback(new UnauthorizedError('Access denied.')); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (user, context, callback) { | |
/* Disclaimer: Not well-tested. Might have clashes with existing linking rules, enterprise connections, etc */ | |
console.log('-- User creation/linking rule --'); | |
var DB_CONN = 'DB_CONNECTION_NAME_HERE'; | |
if (context.clientID !== 'CLIENT_ID_HERE') { | |
return callback(null, user, context); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## | |
# Privacy Settings | |
################## | |
# Privacy: Let apps use my advertising ID: Disable | |
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0 | |
# To Restore: | |
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1 | |
# Privacy: SmartScreen Filter for Store Apps: Disable | |
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
* Install dependencies with: | |
* npm install request request-promise-native bottleneck | |
* | |
* Replace YOUR_TENANT_NAME, MGMT_TOKEN, and FILENAME | |
* The input file (FILENAME) should contain a list of user ids to delete, separated by newlines | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (user, context, cb) { | |
var request = require('[email protected]'); | |
var tenant_url = 'https://example.au.auth0.com'; // Change this to your Auth0 domain | |
request.post({ | |
url: tenant_url + '/oauth/token', | |
json: { 'client_id': context.webtask.secrets.client_id, 'client_secret': context.webtask.secrets.client_secret, 'audience':tenant_url+'/api/v2/', 'grant_type':'client_credentials'} | |
}, function(err, response, body) { | |
if (err) { |