File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
1
[tool .poetry ]
2
2
name = " shipchain-common"
3
- version = " 1.0.24 "
3
+ version = " 1.0.25 "
4
4
description = " A PyPI package containing shared code for ShipChain's Python/Django projects."
5
5
6
6
license = " Apache-2.0"
Original file line number Diff line number Diff line change @@ -43,19 +43,20 @@ def get_jwt_from_request(request):
43
43
return None
44
44
45
45
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
49
53
50
54
51
55
class InternalRequest (BasePermission ):
52
56
def has_permission (self , request , view ):
53
57
if settings .ENVIRONMENT in ('LOCAL' , 'INT' ):
54
58
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 )
59
60
60
61
61
62
class EngineRequest (InternalRequest ):
You can’t perform that action at this time.
0 commit comments