Added steam auth using encrypted application tickets
Not tested working though yet
This commit is contained in:
26613
package-lock.json
generated
26613
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,7 @@
|
||||
"redis": "2.8.0",
|
||||
"request": "2.85.0",
|
||||
"semver": "5.5.0",
|
||||
"steam-appticket": "1.0.1",
|
||||
"tv4": "1.3.0",
|
||||
"uuid": "^3.1.0",
|
||||
"winston": "2.4.1",
|
||||
|
||||
@@ -16,6 +16,7 @@ const vkontakte = require("./vkontakte");
|
||||
const qq = require("./qq");
|
||||
const wechat = require("./wechat");
|
||||
const weibo = require("./weibo");
|
||||
const steam = require("./steam");
|
||||
|
||||
const anonymous = {
|
||||
validateAuthData: () => {
|
||||
@@ -43,7 +44,8 @@ const providers = {
|
||||
vkontakte,
|
||||
qq,
|
||||
wechat,
|
||||
weibo
|
||||
weibo,
|
||||
steam
|
||||
}
|
||||
function authDataValidator(adapter, appIds, options) {
|
||||
return function(authData) {
|
||||
|
||||
36
src/Adapters/Auth/steam.js
Normal file
36
src/Adapters/Auth/steam.js
Normal file
@@ -0,0 +1,36 @@
|
||||
var Parse = require('parse/node').Parse;
|
||||
const AppTicket = require('steam-appticket');
|
||||
|
||||
// todo move these to a config file.
|
||||
const decryptionKey = '3e3e2a3cbd54dc6c7cb5e51520dfa819dd7f9c12d062d54a1f8c14ddd231377f';
|
||||
const appId = '3414340';
|
||||
|
||||
// Returns a promise that fulfills iff this application ticket is valid
|
||||
function validateAuthData(authData) {
|
||||
var encrypted_ticket = Buffer.from(authData.app_ticket, 'hex');
|
||||
var ticket = AppTicket.parseEncryptedAppTicket(encrypted_ticket, decryptionKey)
|
||||
if (ticket === null) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'Steam auth is invalid for this user.');
|
||||
}
|
||||
var user_id = authData.id;
|
||||
if (user_id != ticket.steamID.accountid) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'The provided application ticket does not match the given user id'
|
||||
);
|
||||
}
|
||||
if (appId !== ticket.appID && demoAppId != ticket.appID) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'The provided application ticket does not match the Kami 2 or Kami 2 Demo application ids'
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// steam auth bundles the app id in the auth data so don't validate seperately
|
||||
function validateAppId() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
Reference in New Issue
Block a user