This commit is contained in:
John Sebastian Peterson 2026-05-24 20:27:33 +08:00 committed by GitHub
commit b6af2c1e9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View file

@ -1,20 +1,20 @@
#!/usr/bin/python
import sys
import os
import httplib
import http.client
f = '/tmp/openvpn_sso_user'
with open (f, "r") as myfile:
session_key = myfile.read().replace('\n', '')
conn = httplib.HTTPConnection("10.8.0.1:8080")
conn = http.client.HTTPConnection("10.8.0.1:8080")
conn.request("GET", "/" + session_key)
r1 = conn.getresponse()
if r1.status == 200:
body = r1.read().rstrip()
print body
print(body)
elif r1.status == 404:
print "Authentication failed"
print("Authentication failed")
else:
print r1.status, r1.reason
print(r1.status, r1.reason)

View file

@ -1,5 +1,5 @@
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from http.server import BaseHTTPRequestHandler, HTTPServer
import os
class ExampleHTTPRequestHandler(BaseHTTPRequestHandler):
@ -7,7 +7,7 @@ class ExampleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
session_key = os.path.basename(self.path)
file = '/tmp/openvpn_sso_' + session_key
print 'session file: ' + file
print('session file: ' + file)
try:
f = open(file)
#send code 200 response
@ -17,8 +17,8 @@ class ExampleHTTPRequestHandler(BaseHTTPRequestHandler):
self.end_headers()
#send file content to client
user = f.read().rstrip()
print 'session user: ' + user
print 'session key: ' + session_key
print('session user: ' + user)
print('session key: ' + session_key)
self.wfile.write('<html><body><h1>Greetings ' + user \
+ '. You are authorized' \
'</h1>' \