Commit 0b4468ee authored by Evgeniy Zaitsev's avatar Evgeniy Zaitsev
Browse files

v0.0.21

parent a2755d56
'use strict'; 'use strict';
const sha1 = require('sha1');
const urlJoin = require('url-join'); const urlJoin = require('url-join');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
...@@ -22,14 +23,17 @@ function * checkSessionToken(next) { ...@@ -22,14 +23,17 @@ function * checkSessionToken(next) {
} }
function * fetchUser(sessionToken) { function * fetchUser(sessionToken) {
const url = urlJoin( const queryString = `?service_id=${this.config.service.id}`;
this.state.instance.auth_endpoint, 'p', this.state.project.id, 'sessions', const path = urlJoin('p', this.state.project.id, 'sessions', sessionToken);
`${sessionToken}?service_id=${this.config.service.id}` const url = urlJoin(this.state.instance.auth_endpoint, path + queryString);
);
const salt = sha1(Date.now() + 'salt' + Date.now());
const signeableContent = path + queryString;
const signature = this.config.accessToken + signeableContent + salt;
this.logger.log(__filename, 'fetch user url:', url); this.logger.log(__filename, 'fetch user url:', url);
yield fetch(url) yield fetch(url, {headers: {'X-LViS-Salt': salt, 'X-LViS-Signature': signature}})
.then(res => res.json()) .then(res => res.json())
.then(user => user && Object.assign(user, {sessionToken: sessionToken})); .then(user => user && Object.assign(user, {sessionToken: sessionToken}));
} }
......
{ {
"name": "service-sdk", "name": "service-sdk",
"version": "0.0.20", "version": "0.0.21",
"private": true, "private": true,
"description": "Service SDK for LViS", "description": "Service SDK for LViS",
"keywords": [], "keywords": [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment