Hi everyone, we are using oathkeeper and kratos. I...
# talk-oathkeeper
p
Hi everyone, we are using oathkeeper and kratos. I am wondering whether there is a way we can have anonymous session using kratos? We want to serve different content based on whether user is logged in vs user is not logged in at same endpoint. The
cookie_session
authenticator allows us to verify a logged in user but how do we serve content to a non logged in user?
m
So you have two kinds of content: • content for registered • content for not-registered Could you serve the non-registered content as default and when they have a session as indicated by cookie_session you replace it with the registered content?
p
I see. How do we specify oathkeeper rules to let the request go through? right now, when I specify
cookie_session
as authenticator, it would return an error.
m
You could also create a temporary profile, for example in the users cookie. And when they register you pre-populate the form with the data you already have. But that is probably a different usecase 🤔
p
creating a temporary user for each anonymous session doesn't seem worth it to me. I was hoping that there should be a better way.
m
Definitely! That is only if you want to prepopulate the signup form. Could you share your oathkeeper config maybe? I have this in mine for cookie_session:
Copy code
authenticators:
    cookie_session:
        enabled: true
        config:
            check_session_url: <http://kratos:4433/sessions/whoami>
            preserve_path: true
            extra_from: "@this"
            subject_from: "identity.id"
            only:
              - ory_kratos_session
p
this is what I am using for now
m
Best would be if you could share a reproducible repo of course, can also be private.
p
I am just using the quick start guide and modifying to support this use case.
👍 1
I am thinking that with this rule, if
ory_kratos_session
cookie is not set, the oathkeeper will try the next rule. In that rule, I could set a header and use that in my backend to identify anonymous users
Does that sound like an idea that'd work?
m
Yea, that sounds like a great idea! Let me know how it goes 🙏
p
Thank you so much for a quick reply
t
This seems to be a common request(ish) to essentially “force login” anonymous users. I’d like this sort of functional as well