Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const koa = require("koa");
- const app = koa();
- const route = require("koa-route");
- const passport = require("koa-passport");
- const session = require("koa-session");
- app.keys = ['this is a secret'];
- var OpenIDStrategy = require('passport-openid').Strategy;
- var SteamStrategy = new OpenIDStrategy({
- providerURL: 'https://steamcommunity.com/openid',
- stateless: true,
- returnURL: 'http://localhost:8888/returnSteamLogin',
- realm: 'http://localhost:8888',
- },
- function(identifier, done) {
- process.nextTick(() => {
- var user = {
- identifier: identifier,
- steamId: identifier.match(/\d+$/)[0]
- };
- return done(null, user);
- });
- });
- passport.serializeUser(function(user, done) {
- done(null, user.steamId);
- });
- passport.deserializeUser(function(identifier, done) {
- done(null, {
- steamId: identifier
- });
- });
- passport.use(SteamStrategy);
- app.use(session(app));
- app.use(passport.initialize());
- app.use(passport.session());
- app.use(route.get("/signInThroughSteam", passport.authenticate("openid")));
- app.use(route.get("/returnSteamLogin", passport.authenticate("openid"), function*() {
- //I know cannot access the return URL because I get an error
- }));
- app.listen(8888);
Add Comment
Please, Sign In to add comment