-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to login to google using the browser
- Loading branch information
Showing
7 changed files
with
159 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This HTTP server for capturing the SAMLResponse that is redirected to 127.0.0.1 | ||
""" | ||
|
||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
import logging | ||
|
||
from aws_google_auth import util | ||
|
||
class LoginServer(HTTPServer): | ||
post_data = {} | ||
|
||
|
||
class LoginServerHandler(BaseHTTPRequestHandler): | ||
def _set_response(self): | ||
self.send_response(200) | ||
self.send_header('content-type', 'text/html') | ||
self.end_headers() | ||
self.wfile.write(""" | ||
<html> | ||
<head><title>Success</title></head> | ||
<body> | ||
Check your console | ||
<script>window.close()</script> | ||
</body> | ||
</html> | ||
""".encode("utf-8")) | ||
|
||
def do_POST(self): | ||
self.server.post_data = util.Util.parse_post(self) | ||
logging.debug("POST request,\nPath: %s\nHeaders:\n%s\n\nBody:\n%s\n", | ||
str(self.path), str(self.headers), self.server.post_data) | ||
|
||
self._set_response() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This HTTP server can be run on a server, and redirects the SAMLResponse to 127.0.0.1 so the command can capture it | ||
""" | ||
|
||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
import logging | ||
|
||
class RedirectServerHandler(BaseHTTPRequestHandler): | ||
def do_POST(self): | ||
self.send_response(307) | ||
self.send_header('location', 'http://127.0.0.1:4589/') | ||
self.end_headers() | ||
|
||
def start_redirect_server(port): | ||
logging.basicConfig(level=logging.INFO) | ||
server_address = ('', port) | ||
httpd = HTTPServer(server_address, RedirectServerHandler) | ||
logging.info('Starting http redirect server on: %s', port) | ||
try: | ||
httpd.serve_forever() | ||
except KeyboardInterrupt: | ||
pass | ||
httpd.server_close() | ||
logging.info('Stopping http redirect server') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters