Skip to content

Instantly share code, notes, and snippets.

@Alex-Wauters
Alex-Wauters / gist:bd7f7a781c1f5e95849690a7f9fa653a
Created October 24, 2019 12:05
Dockerfile for computer vision scripts (parking vision case)
FROM tensorflow/tensorflow:1.13.1-py3
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
@Alex-Wauters
Alex-Wauters / index.ts
Created April 14, 2019 16:11
Firebase-Azure AD: Update function for IdP keys
/**
* Retrieve IDP signature keys.
*/
async function updateIdpKeys(): Promise<Array<MSOpenIdKey>> {
const data = await rp({ uri: 'https://login.microsoftonline.com/common/discovery/v2.0/keys', json: true });
if (data && data.keys && isArray(data.keys) && data.keys.length > 0) {
data.keys.forEach(async (k: MSOpenIdKey) => {
await db.collection('IdpKeys').doc(k.kid).set(k);
});
keys = data.keys; // Store in container. Will be re-used when container is re-used
@Alex-Wauters
Alex-Wauters / index.ts
Created April 14, 2019 15:47
Firebase: Auth with Azure AD
exports.validateAuth = functions.https.onRequest(async (req, res) => {
if (req.query && req.query.error) {
console.error(`Authentication request error from Azure AD: ${req.query.error_description}. Full details: ${JSON.stringify(req.query)}`);
res.status(400).send(`Oh oh, something went wrong. Please contact support with the following message: Invalid authentication request: ${req.query.error_description}`);
return;
}
if (req.body && req.body.id_token) {
try {
const token = req.body.id_token;
// Abbreviated version from https://github.com/Alex-Wauters/firebase-auth-azure-ad/blob/master/main.js
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
console.log('User is logged in');
startApp();
} else {
const url = window.location.href;
if (url.indexOf('jwt=') > -1) { // The minted firebase token from Auth function
const token = url.substr( url.indexOf('jwt=') + 4);
firebase.auth().signInWithCustomToken(token)