File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ def lookup(self, token):
102
102
import json
103
103
104
104
key = jwt .JWK ()
105
-
105
+
106
106
try :
107
107
with open (self .source , 'rb' ) as key_file :
108
108
key_data = key_file .read ()
@@ -158,3 +158,31 @@ def lookup(self, token):
158
158
(host , port ) = combo ["host" ].split (':' )
159
159
port = port .encode ('ascii' ,'ignore' )
160
160
return [ host , port ]
161
+
162
+
163
+ class UnixDomainSocketDirectory (BasePlugin ):
164
+ def __init__ (self , * args , ** kwargs ):
165
+ super (UnixDomainSocketDirectory , self ).__init__ (* args , ** kwargs )
166
+ self ._dir_path = os .path .abspath (self .source )
167
+
168
+ def lookup (self , token ):
169
+ try :
170
+ import stat
171
+
172
+ if not os .path .isdir (self ._dir_path ):
173
+ return None
174
+
175
+ uds_path = os .path .abspath (os .path .join (self ._dir_path , token ))
176
+ if not uds_path .startswith (self ._dir_path ):
177
+ return None
178
+
179
+ if not os .path .exists (uds_path ):
180
+ return None
181
+
182
+ if not stat .S_ISSOCK (os .stat (uds_path ).st_mode ):
183
+ return None
184
+
185
+ return [ 'unix_socket' , uds_path ]
186
+ except Exception as e :
187
+ print ("Error finding unix domain socket: %s" % str (e ), file = sys .stderr )
188
+ return None
You can’t perform that action at this time.
0 commit comments