catberry / catberry-oauth2-client Goto Github PK
View Code? Open in Web Editor NEWOAuth 2.0 Client Plugin for Catberry Framework
Home Page: https://catberry.github.io/
License: Other
OAuth 2.0 Client Plugin for Catberry Framework
Home Page: https://catberry.github.io/
License: Other
There is an application that requests user related data from the API. The access token is invalid and it tries to refresh token but it does not have a refresh token either and the endpoint redirects to the same initial page and process goes to a loop.
The main problem is that we don't have an access to refresh token from JavaScript in a browser because it has the HttpOnly
flag.
So, we have to invent something.
Now users can't access headers in a response but it's very important to have it, for instance for using ETag or other headers.
If refresh_token or access_token contain characters other than numbers and letters, this can lead to infinite loop applications.
An example of a token: mYGnZR5RfI0XvpJoEyqzii+SFPW3hoObEoKn/xVQWz0=
generator: crypto.randomBytes(32).toString('base64') //nodejs
The data token may not be correctly parsed from cookie here
catberry-oauth2-client/lib/helpers/cookieHelper.js
Lines 45 to 55 in c07ef64
getFromRequest: function(request) {
if (!request.headers || typeof(request.headers.cookie) !== 'string') {
return {};
}
var result = {};
request.headers.cookie
.split(';')
.forEach(function(cookieString) {
cookieString = cookieString.trim();
var separatorIndex = cookieString.indexOf('=');
result[cookieString.substr(0, separatorIndex)] = cookieString.substr(separatorIndex + 1);
});
return result;
}
If you correct the problem with cookies, then there is a problem with sending. For example, the query refresh_token:
{
"refresh_token": "mYGnZR5RfI0XvpJoEyqzii+SFPW3hoObEoKn/xVQWz0=",
"grant_type": "refresh_token"
}
// on server req.body will contain
{
"refresh_token": "mYGnZR5RfI0XvpJoEyqzii SFPW3hoObEoKn/xVQWz0=", // plus changed to space
"grant_type": "refresh_token"
}
Привет!
"grantType": "password"
, ходит в oauth-бэкенд каждую минуту?Спасибо!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.