Coder Social home page Coder Social logo

catberry-oauth2-client's Issues

We don't know when we can to refresh Password Access Token

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.

Wrong behavior when access_token/refresh_token has unusual symbols

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

request.headers.cookie
.split(';')
.forEach(function (cookiePair) {
cookiePair = cookiePair.trim();
var parts = cookiePair.split('=');
if (parts.length === 1) {
result[parts[0]] = true;
} else if (parts.length === 2) {
result[parts[0]] = parts[1];
}
});

This problem is resolved modified code:

  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"
}

Refreshing data each minute, Destroying auth data.

Привет!

  1. Это норма, что клиент, авторизованный через "grantType": "password", ходит в oauth-бэкенд каждую минуту? Нормально, что oauth-клиент трижды ходит в oauth-сервер по истечении времени жизни токена? Трижды, видимо, потому, что хранилище с авторизацией привязано к 3м компонентам.
    Пример
  2. И второй вопрос: возможно ли затереть куки авторизации, что указаны в конфиге клиента, через сам клиент? Предусмотрены ли соответсвующие endpoints? Хотя, кажется, что разавторизация должна проходить через oauth-сервер, чтобы загасить ненужные токены...

Спасибо!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.