fix geoip usage

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2024-01-02 22:59:23 +01:00
parent e425eaee1f
commit c90d35b113
No known key found for this signature in database
3 changed files with 18 additions and 25 deletions

View File

@ -177,6 +177,14 @@ class MobileTransaction(ExpiringModel):
user: User = self.device.user
client_ip = ClientIPMiddleware.get_client_ip(request)
geo = None
if GEOIP_CONTEXT_PROCESSOR.configured():
city = GEOIP_CONTEXT_PROCESSOR.city(client_ip)
if city:
geo = AuthenticationRequest.Attributes.Geo(
lat=city.location.latitude,
long=city.location.longitude,
)
auth_request = AuthenticationRequest(
device_token=self.device.firebase_token,
tx_id=str(self.tx_id),
@ -192,17 +200,10 @@ class MobileTransaction(ExpiringModel):
}
),
client_ip=client_ip,
geo=AuthenticationRequest.Attributes.Geo(),
geo=geo,
extra=context,
),
)
if GEOIP_CONTEXT_PROCESSOR.configured():
geo = GEOIP_CONTEXT_PROCESSOR.city(client_ip)
if geo:
auth_request.attributes.geo = AuthenticationRequest.Attributes.Geo(
lat=geo.location.latitude,
long=geo.location.longitude,
)
client = get_client(self.device.stage.cgw_endpoint)
try:
response = client.SendRequest(auth_request)

View File

@ -35356,16 +35356,16 @@ components:
confirmed:
type: boolean
readOnly: true
last_checkin:
state:
allOf:
- $ref: '#/components/schemas/MobileDeviceInfo'
readOnly: true
required:
- confirmed
- last_checkin
- meta_model_name
- name
- pk
- state
- type
- verbose_name
- verbose_name_plural
@ -35417,9 +35417,7 @@ components:
type: string
app_version:
type: string
others:
type: object
additionalProperties: {}
others: {}
required:
- app_version
- hostname
@ -35445,9 +35443,7 @@ components:
app_version:
type: string
minLength: 1
others:
type: object
additionalProperties: {}
others: {}
required:
- app_version
- hostname

View File

@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: authentik
version: 2023.10.4
version: 2023.10.5
description: Making authentication simple.
contact:
email: hello@goauthentik.io
@ -487,16 +487,16 @@ components:
confirmed:
type: boolean
readOnly: true
last_checkin:
state:
allOf:
- $ref: '#/components/schemas/MobileDeviceInfo'
readOnly: true
required:
- confirmed
- last_checkin
- meta_model_name
- name
- pk
- state
- type
- verbose_name
- verbose_name_plural
@ -540,9 +540,7 @@ components:
type: string
app_version:
type: string
others:
type: object
additionalProperties: {}
others: {}
required:
- app_version
- hostname
@ -568,9 +566,7 @@ components:
app_version:
type: string
minLength: 1
others:
type: object
additionalProperties: {}
others: {}
required:
- app_version
- hostname