Skip to content

Instantly share code, notes, and snippets.

View rdegges's full-sized avatar

Randall Degges rdegges

View GitHub Profile
@rdegges
rdegges / server.js
Created September 19, 2016 18:00
express-stormpath-s3 file upload
app.get('/', stormpath.loginRequired, (req, res, next) => {
req.user.uploadFile('./some-file.txt', err => {
if (err) return next(err);
req.user.getCustomData((err, data) => {
if (err) return next(err);
res.send('file uploaded as ' + data.s3['package.json'].href);
});
});
@rdegges
rdegges / server.js
Last active September 19, 2016 17:47
express-stormpath-s3 initialization
'use strict';
const express = require('express');
const stormpath = require('express-stormpath');
const stormpathS3 = require('express-stormpath-s3');
let app = express();
// Middleware here
app.use(stormpath.init(app, {
@rdegges
rdegges / import.py
Last active June 23, 2016 21:22
Stormpath Account Import Script (from a csv file)
"""
import.py
~~~~~~~~~
A small script that reads in user accounts from a CSV file, and imports them
into Stormpath with a random password.
This script requires a few things.
First off, it requires the following environment variables to be set:
@rdegges
rdegges / auth.py
Created April 14, 2016 23:54
Stormpath Password Grant Authentication Example
"""
Stormpath OAuth2 Password Grant Authentication Example
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This example script shows you how to use the Stormpath Python library to
authenticate a user via email and password, getting back an access and
refresh token.
"""
@rdegges
rdegges / auth.py
Created April 14, 2016 23:54
Stormpath Password Grant Authentication Example
"""
Stormpath OAuth2 Password Grant Authentication Example
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This example script shows you how to use the Stormpath Python library to
authenticate a user via email and password, getting back an access and
refresh token.
"""
@rdegges
rdegges / example.py
Created January 29, 2016 20:01
Flask-Stormpath API Authentication Example
from flask import Flask, request, jsonify
from flask.ext.stormpath import StormpathManager
from stormpath.api_auth import BasicRequestAuthenticator
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['STORMPATH_API_KEY_ID'] = 'xxx'
app.config['STORMPATH_API_KEY_SECRET'] = 'yyy'
app.config['STORMPATH_APPLICATION'] = 'blah'
@rdegges
rdegges / build-sphinx.sh
Last active January 4, 2016 21:51
Sphinx build step for Stormpath projects.
# This script will build all Sphinx project documentation if, and only if,
# an environment variable named `BUILD_DOCS` is present.
PWD=`pwd`
# First off, we'll find a list of *all* directories which contain a `conf.py`
# file. This is the configuration file that Sphinx ships with, so by looking
# for this file we can find (for certain) any Sphinx documentation directories
# that are inside of this project, even if they're nested in some deep hierarchy.
#
# NOTE: For OSX you need to modify the sed command to use the -E flag instead of
@rdegges
rdegges / install-sphinx.sh
Last active January 4, 2016 19:33
Install Sphinx build step for Stormpath projects.
# This script will install Sphinx for building project documentation if,
# and only if, an environment variable named `BUILD_DOCS` is present.
test -z "$BUILD_DOCS" || pip --quiet install --user sphinx
@rdegges
rdegges / stormpath-flask-signals-example
Created December 7, 2015 19:40
Stormpath Flask example application demonstrating how to subscribe to resource creation signals.
from flask import Flask
from flask.ext.stormpath import StormpathManager
from pydispatch import dispatcher
from stormpath.resources.base import SIGNAL_RESOURCE_CREATED
app = Flask(__name__)
app.config['SECRET_KEY'] = 'xxx'
app.config['STORMPATH_API_KEY_ID'] = 'xxx'
app.config['STORMPATH_API_KEY_SECRET'] = 'xxx'
@rdegges
rdegges / stormpath-express-auto-login-example
Created December 7, 2015 19:01
Stormpath express autologin after register example.
'use strict';
var express = require('express');
var stormpath = require('express-stormpath');
var app = express();
app.use(stormpath.init(app, {
client: {
apiKey: {