Kratos sessions have a location property. However ...
# general
d
Kratos sessions have a location property. However looking at the source code this only works based on Cloudflare’s location headers. Is there any way this can be set if you aren’t proxying through Cloudflare (requiring Cloudflare for it to work seems a bit limiting)? Is there a webhook I can hook into so I can use, for example, maxmind’s database, to insert the location? Or some other approach? Cheers
further - If you have kratos behind Cloudfront, you can use their location headers
s
I think we just went with cloudflare headers as a "standard" to start with not sure if there are that many providers out there, so if we should just accept the headers from any well-known provider alternatively, we could require you to rewrite the headers, or make the header name configurable wdyt?
d
yeah good point. I think the approach is right - Kratos accepts the header from something upstream. I don’t know what Google Cloud Platform has, but you’ve got Cloudflare and Cloudfront that add their own headers. If you are using nginx as a reverse proxy you can use the geoip module, but you can forward headers to kratos however you want. From developer experience I think kratos supporting the couple of popular services out of the box would be nice. For custom, I think either Ory saying “You need to set this header for location to be recorded”, or “Configure the location header in config.yml” are about equal
s
I agree, as we already support cloudflare, I see no reason why we should not support other common providers. Open for contributions 😉
d
on that note - is there documentation about the general structure/design of Kratos’s source code? I’ve snooped around in the code a bunch but I don’t have heaps of experience working with Go
s
hm no not really, there are also parts that are in need of refactoring (as always everywhere) if you search for the headers, you should find the strings and where they are used