-
Hello! I have a two-part question regarding the usage of Kratos with mobile applications. In my use case, there will be various kinds of client applications, including browser-based applications and mobile apps. What are the best practices when it comes to authentication with mobile apps? I'm thinking of having either persistent authentication (so that users log in only the first time they open the app) or long sessions, say 7 or 30 days (longer than browser clients). The obvious approach would be to store the Kratos session tokens in iOS Keychain. However, that's where my second question comes in -- is it possible to have variable session lifetimes based on some condition/request parameter/etc.? I believe that is not the case, which means that if I wanted to have 7 day session on mobile apps, I'd also have them in browser clients (which could maybe work if I implement e.g. idle timeouts for browser clients). Another approach could be to manage mobile app sessions outside of Kratos. To sum up:
Looking at the login flow, I'm not sure where we could even add a session lifetime parameter in a way that would not depend on user input 🤔. My best guess would be to allow session lifetime configuration via hooks and make the decision based on the user agent header... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think I just found a relevant thread: #1603 But I'm still not clear what the best practice would be when it comes to mobile apps. In that thread the following two suggestions were made:
Regarding 1: While using HTTPS is a no-brainer, certificate pinning seems to be discouraged: https://www.digicert.com/blog/certificate-pinning-what-is-certificate-pinning While I understand that a mobile app would not necessarily need to rely on the deprecated HPKP headers, and it's possible to just roll out a new app version if a certificate is revoked, it would still be disruptive to users. Or perhaps I misunderstood what was meant by certificate pinning? Regarding 2: That could work. My only problem with this approach is that it's discouraged by OWASP:
The "authentication token" suggested by OWASP sounds a lot like the Kratos session token. But if we don't want to keep Kratos sessions open for very long periods of time, then it would have to be some other session-like token managed outside of Kratos that grants access to our system. Alternatively, the "authentication token" could be yet another authentication method that could be used instead of a password to open a Kratos session. |
Beta Was this translation helpful? Give feedback.
-
Hey @kszafran |
Beta Was this translation helpful? Give feedback.
I think I just found a relevant thread: #1603 But I'm still not clear what the best practice would be when it comes to mobile apps. In that thread the following two suggestions were made:
Regarding 1: While using HTTPS is a no-brainer, certificate pinning seems to be discouraged: https://www.digicert.com/blog/certificate-pinning-what-is-certificate-pinning While I understand that a mobile app would not necessarily need to rely on the deprecated HPKP headers, and it's possible to just roll out a new app version if a certificate is revoked, it would still be disruptive to …