Skip to content

Instantly share code, notes, and snippets.

View thameera's full-sized avatar

Thameera Senanayaka thameera

View GitHub Profile
@thameera
thameera / change-secret.md
Last active September 3, 2016 05:26
How to change Auth0 global client secret

You can revoke the global client secret yourself as follows:

  1. Go to your Account Settings -> Advanced tab and copy the Global Client ID value.
  2. Go to the Management API v2 Explorer
  3. Click on Clients -> Update a client in the left sidebar.
  4. In the center panel, select the scopes update:clients and update:client_keys.
  5. In the id textbox, paste the global client ID that you copied in step 1.
  6. Enter the new global client secret in the body textarea, like this:
@thameera
thameera / linkedin.html
Created May 30, 2017 03:21
Auth0.js 7.6 popup mode - linkedin
<!DOCTYPE html>
<html>
<body>
<script src="//cdn.auth0.com/w2/auth0-7.6.1.min.js"></script>
<button type="button" onclick="login()">Log in</button>
<script type="text/javascript">
@thameera
thameera / zendesk-trigger-compiler.js
Last active June 27, 2017 08:52
wt compiler for zendesk+auth0 extend integration demo
'use strict';
module.exports = (options, cb) => {
console.log('a');
options.nodejsCompiler(options.script, (e, Func) => {
console.log('b');
if (e) return cb(e);
console.log('c');
let instance = new Func();
@thameera
thameera / post-reg-hook.js
Last active August 4, 2020 07:29
Post-user registration hook to add user_id to app_metadata
module.exports = function (user, context, cb) {
var request = require('request@2.56.0');
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) {
@thameera
thameera / delete.js
Last active November 15, 2023 11:58
Bulk delete Auth0 users
#!/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
*/
@thameera
thameera / req.md
Last active February 5, 2018 17:08
Create/update Auth0 pre-registration hook
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",
@thameera
thameera / Windows10-Setup.ps1
Last active July 21, 2018 13:21 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# 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
@thameera
thameera / wp-special-link-rule.js
Last active September 13, 2018 09:14
Create and link DB users for social logins
@thameera
thameera / ad_user_group_rule.js
Created January 26, 2019 02:49
Filter AD users based on their groups
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.'));
}
@thameera
thameera / calcFSThumbprints.js
Last active June 9, 2021 00:45
Calculate thumbprints from an ADFS metadata file
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')