Comments (16)
At the moment we are enhancing a Platform with PWA attributes, Offline access to be precise. We are using Angular 6 with keycloak-angular. So far everything is fine (Thanks you so much for keycloak-angular :D )
The problem we are having is trying to came up with an strategy for offline access. Keycloak official documentation explains offline access in this URL: https://www.keycloak.org/docs/3.2/server_admin/topics/sessions/offline.html but we do not understand how to achieve offline access using keycloak-angular.
It could really help us if you can just give us some help or advice to enable offline access using keycloak-angular
We are willing to either help with the implementation or documentation, we just need someone to point us the right way to go.
from keycloak-angular.
@juansmolano, thanks for sharing your thoughts and needs. The keycloak do have support for offline access, however, as far as I know, keycloak-js doesn't. So consequently, keycloak-angular doesn't have it too.
I also think this is a must feature, supporting both PWA and Ionic, so we could move forward this discussion and feature.
from keycloak-angular.
My workaround:
- Increase the
SSO Session Timeout
to numbers that are usual for offline tokens - Use
standard
flow (I need the refresh token) - Override the KeycloakService to handle offline scenarios more gracefully
import { KeycloakService } from 'keycloak-angular';
export class OfflineKeycloakService extends KeycloakService {
async updateToken(minValidity: number = 5) {
try {
return await super.updateToken (minValidity);
} catch (err) {
// this means that there was an issue with
// the network or the server, but no logout occurred
if ((<any>this)._instance.refreshToken) {
return false;
}
// if the token got removed, it means that there
// was a 400 of the server
throw err;
}
}
}
It's a hack, it's limited, it's less secure...but maybe it helps somebody.
from keycloak-angular.
Hi,
Anything new about this? I'm creating a PWA app that uses keycloak-angular and needs offline access.
from keycloak-angular.
@aelkz, you are right, this is something we really could move on.
In progressive web apps, are you suggesting to describe offline access?
from keycloak-angular.
@aelkz could you add more information about which features we need to doc for PWA? Tks!
from keycloak-angular.
Have a look at this interesting post:
https://stackoverflow.com/questions/35270343/keycloak-javascript-adapter-request-offline-token
The init method doesn't accept the scope option, but the login method does.
from keycloak-angular.
Are there any new Documentations about using keycloak-angular with PWA or Cordova apps, with or without offline access token?
from keycloak-angular.
There are no updates on documentation to use Keycloak Angular in an offline app. There is some discussion going on in #232 about offline tokens.
It would of course be great if we can get documentation for this in place so if you have any experience using Keycloak offline please do share.
from keycloak-angular.
Closing this in favour of #272
from keycloak-angular.
Just FYI, one can pass in your token, id token and refresh tokens into the init
command, so storing them upon login in localStorage should work well.
const keycloakToken = localStorage.keycloakToken
const keycloakIdToken = localStorage.keycloakIdToken
return keycloak
.init({
onLoad: 'login-required',
checkLoginIframe: false,
flow: 'hybrid',
scope: 'openid offline_access',
token: keycloakToken,
idToken: keycloakIdToken
})
.success((authenticated) => {
console.log(keycloak)
localStorage.keycloakToken = keycloak.token
localStorage.keycloakIdToken = keycloak.idToken
localStorage.keycloakRefreshToken = keycloak.refreshToken
})
.error(function() {
alert('failed to initialize')
})
from keycloak-angular.
hi all,
Did someone find a solution as how to make keycloak-angular work with PWA? Or does the post by WerrnerRaath is a valid solution?
from keycloak-angular.
Any news?
from keycloak-angular.
Hi,
Anything new about this? I'm creating a PWA app that uses keycloak-angular and needs offline access.
@Rezorl did you found any solution?
from keycloak-angular.
Yes, but I don't know if this is the right solution. However, everything works as it should.
Link to source code: https://github.com/Rezorl/angular-keycloak-pwa
from keycloak-angular.
Yes, but I don't know if this is the right solution. However, everything works as it should. Link to source code: https://github.com/Rezorl/angular-keycloak-pwa
Seem this only work when my device have no internet. Can we detective whether keycloak or server is online or offline ?
then we go offline or not ?
from keycloak-angular.
Related Issues (20)
- Login method locale is not changing the user locale when the user logs in
- angular crashes with check-sso
- Support KC 24.x.x HOT 6
- Catch sign out event or redirect to ssop event
- keycloak-angular - next version improvements HOT 1
- Bug in package.json version 15.2.0 HOT 3
- Keycloak setup for Single SPA angular Project
- HttpClient Interceptor not working HOT 2
- Configure updateToken minValidity in HTTP Interceptor
- Standalone bootstrap: withEnabledBlockingInitialNavigation() causes isLoggedIn() to return false in AuthGuard HOT 2
- Add setup instructions for standalone bootstrap
- Logout the user if he is idle
- Support Angular v18 HOT 2
- Token refresh fails with 400 invalid_grant Token is not active HOT 2
- If Keycloak Auth Domain is down, then Angular 16 keycloak will receive white-page and fail compilation at AppModule level
- Refresh Token is unused HOT 2
- ERROR Error: An error happened during access validation. Details:TypeError: Cannot read properties of undefined (reading 'resourceAccess') HOT 3
- Support Keycloak 25.x.x HOT 1
- Subscription to keycloak Events$ outside Keycloak initialization function do not work
- User logs out after page refresh HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keycloak-angular.