File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " shipchain-common"
3- version = " 1.0.24 "
3+ version = " 1.0.25 "
44description = " A PyPI package containing shared code for ShipChain's Python/Django projects."
55
66license = " Apache-2.0"
Original file line number Diff line number Diff line change @@ -43,19 +43,20 @@ def get_jwt_from_request(request):
4343 return None
4444
4545
46- def is_internal_call (request ):
47- return ('X_NGINX_SOURCE' in request .META and request .META ['X_NGINX_SOURCE' ] == 'internal'
48- and request .META ['X_SSL_CLIENT_VERIFY' ] == 'SUCCESS' )
46+ def is_internal_call (request , service_name = None ):
47+ is_internal = ('X_NGINX_SOURCE' in request .META and request .META ['X_NGINX_SOURCE' ] == 'internal'
48+ and request .META ['X_SSL_CLIENT_VERIFY' ] == 'SUCCESS' )
49+ if service_name and is_internal :
50+ certificate_cn = parse_dn (request .META ['X_SSL_CLIENT_DN' ])['CN' ]
51+ is_internal = certificate_cn == f'{ service_name } .{ settings .ENVIRONMENT .lower ()} -internal'
52+ return is_internal
4953
5054
5155class InternalRequest (BasePermission ):
5256 def has_permission (self , request , view ):
5357 if settings .ENVIRONMENT in ('LOCAL' , 'INT' ):
5458 return True
55- if is_internal_call (request ):
56- certificate_cn = parse_dn (request .META ['X_SSL_CLIENT_DN' ])['CN' ]
57- return certificate_cn == f'{ self .SERVICE_NAME } .{ settings .ENVIRONMENT .lower ()} -internal'
58- return False
59+ return is_internal_call (request , self .SERVICE_NAME )
5960
6061
6162class EngineRequest (InternalRequest ):
You can’t perform that action at this time.
0 commit comments