question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Oauth token expiration handling

See original GitHub issue

Description

Hi, it’d be great to have out-of-the box oauth token expiration handling.

After token expiration luigi could ask if token should be renewed. Otherwise user should be redirected to the logout page set in the oauth configuration. Please notice that currently it may act weird if there is set the same redirect_uri and logoutUrl because of the auto-login behavior

oAuth2ImplicitGrant: {
                    authorizeUrl: 'http://example.com/oauth/authorize',
                    logoutUrl: 'http://localhost:4200',
                    oAuthData: {
                        client_id: 'my.client',
                        redirect_uri: 'http://localhost:4200',
                        response_type: 'token',
                    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
maxmarkuscommented, Oct 11, 2018

@sebarys LuigiClient should not be capable of doing that.

But you should be already be able to do that. Luigi configuration allows to execute a function after logout and login. I have recognized this is not documented yet.

auth: {
  events: {
    onLogout: () => {
      console.log('onLogout');
    },
    onAuthSuccessful: data => {
      console.log('onAuthSuccessful', data);
    }

With OpenID Connect we have tested single logout in combination with google auth successfully. logoutUrl had the URL to the OpenID Connect logout endpoint and query parameters for redirecting back to window.location.origin right after logout. So manually executing something with onLogout should not be necessary.

0reactions
y-kkamilcommented, Oct 30, 2018

A number of remarks regarding this task:

  • For now, if authorisation is set to something different than OpenID Connect and/or silent token refresh is disabled, user will be redirected to the logout page without any warning - not good if he has some unsaved work. There is a follow-up for that - #179

  • New tokens are issued and silently passed to luigi-client. This way, getToken() function always responds with fresh token. However, it might be also beneficial to send an event of a new type that informs client apps of token update.

  • I couldn’t find a way to check for 3rd party cookies other than the script provided in third-party-cookies. This method requires user of Luigi core to deploy scripts on a different domain than his main app. Also, it only warns about disabled third-party cookies in console. Maybe we should add some other way? Side note: we’re not in control of the logout page, however, if the user has been logged out (possibly, we cannot be sure) because of disabled cookies support, Luigi will add query params (?reason=tokenExpired&thirdPartyCookies=disabled). This way, application developer can add more meaningful message according to his needs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access Token Lifetime - OAuth 2.0 Simplified
The access tokens may last anywhere from the current application session to a couple weeks. When the access token expires, the application will ......
Read more >
How to identify if the OAuth token has expired? - Stack Overflow
Token Refresh Handling: Method 1 · convert expires_in to an expire time (epoch, RFC-3339/ISO-8601 datetime, etc.) · store the expire time · on...
Read more >
Antipattern: Set a long expiration time for OAuth tokens
Since the refresh tokens expire only after 200 days, they persist in the data store (Cassandra) for a long time leading to continuous...
Read more >
OAuth 2.0 Refresh Token Best Practices - Fusebit
Refresh tokens expire after six months of not being used. Another example is LinkedIn API, where by default, access tokens are valid for...
Read more >
What Are Refresh Tokens and How to Use Them Securely
What Is a Refresh Token? ... As mentioned, for security purposes, access tokens may be valid for a short amount of time. Once...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found