mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 21:18:16 -06:00
Fix authentication() returning None value
This commit is contained in:
parent
14fbebfc24
commit
7d2ea49c01
@ -12,7 +12,9 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
|||||||
model = Token
|
model = Token
|
||||||
|
|
||||||
def authenticate(self, request):
|
def authenticate(self, request):
|
||||||
token_user, token = super().authenticate(request)
|
authenticationresult = super().authenticate(request)
|
||||||
|
if authenticationresult:
|
||||||
|
token_user, token = authenticationresult
|
||||||
|
|
||||||
# Verify source IP is allowed
|
# Verify source IP is allowed
|
||||||
if token.allowed_ips:
|
if token.allowed_ips:
|
||||||
@ -28,6 +30,8 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
|||||||
raise exceptions.AuthenticationFailed(f"Source IP {clientip} is not allowed to use this token.")
|
raise exceptions.AuthenticationFailed(f"Source IP {clientip} is not allowed to use this token.")
|
||||||
|
|
||||||
return token_user, token
|
return token_user, token
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def authenticate_credentials(self, key):
|
def authenticate_credentials(self, key):
|
||||||
model = self.get_model()
|
model = self.get_model()
|
||||||
|
@ -62,8 +62,9 @@ class TokenAdmin(admin.ModelAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def list_allowed_ips(self, obj):
|
def list_allowed_ips(self, obj):
|
||||||
|
if obj.allowed_ips:
|
||||||
return obj.allowed_ips
|
return obj.allowed_ips
|
||||||
list_allowed_ips.empty_value_display = 'Any'
|
return 'Any'
|
||||||
list_allowed_ips.short_description = "Allowed IPs"
|
list_allowed_ips.short_description = "Allowed IPs"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user