-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream validation and activity logging (#25)
- Loading branch information
ikethecoder
authored
Mar 9, 2021
1 parent
26e0e93
commit ad79320
Showing
15 changed files
with
443 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# SSL Termination | ||
|
||
If you would like to verify the SSL endpoint, you can run the following two commands and compare the fingerprint and serial no. | ||
|
||
``` | ||
export A_HOST=httpbin-regression.api.gov.bc.ca | ||
openssl s_client -showcerts -verify 5 -connect 142.34.194.118:443 -servername ${A_HOST} < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; print}' > gw.crt | ||
openssl x509 -in gw.crt -fingerprint -serial -dates -noout | ||
``` | ||
|
||
## *.api.gov.bc.ca | ||
|
||
| Issue Date | Expires | Deployed | SHA1 Fingerprint | Serial No. | | ||
|-------------|-------------|-------------|-------------------------------------------------------------|----------------------------------| | ||
| Oct 6 2020 | Oct 16 2021 | Oct 6 2020 | 20:7D:15:9D:42:BE:CC:BC:FD:EF:DF:13:77:C7:25:A3:A4:72:45:05 | 7876EB597E14F728C8455504177D3BC9 | | ||
| Feb 16 2021 | Oct 16 2021 | Feb 25 2021 | 4D:EA:CE:C4:0A:73:67:D3:B4:03:F6:63:C4:E1:67:2C:47:9D:EA:82 | 3B5849D8A670251A3C20EA7859BDF996 | | ||
|
||
|
||
You can run the above as one line: | ||
|
||
``` | ||
A_HOST=httpbin-regression.api.gov.bc.ca; openssl s_client -showcerts -verify 5 -connect ${A_HOST}:443 -servername ${A_HOST} < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; print}' | openssl x509 -fingerprint -serial -dates -noout | ||
``` | ||
|
||
|
||
**Individual File Verification** | ||
|
||
``` | ||
openssl x509 -in data-api-wildcard-2020.crt -fingerprint -serial -dates -noout | ||
openssl x509 -in data-api-wildcard-2021.crt -fingerprint -serial -dates -noout | ||
``` | ||
|
||
**Cert/Key Verification** | ||
|
||
``` | ||
openssl x509 -noout -modulus -in data-api-wildcard.crt | openssl md5 | ||
openssl rsa -noout -modulus -in data-api-wildcard.key | openssl md5 | ||
``` |
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,50 @@ | ||
from flask import current_app as app | ||
import sys | ||
import requests | ||
import traceback | ||
import urllib.parse | ||
|
||
# | ||
# 'type', 'name', 'action', 'message', 'refId', 'namespace' | ||
|
||
|
||
def record_namespace_event (uuid, action, result, namespace, message = ""): | ||
record_activity ({ | ||
'id': uuid, | ||
'type': 'GatewayNamespace', | ||
'action': action, | ||
'result': result, | ||
'name': 'N/A', | ||
'message': message, | ||
'refId': '', | ||
'namespace': namespace | ||
}) | ||
|
||
def record_gateway_event (uuid, action, result, namespace, message = ""): | ||
record_activity ({ | ||
'id': uuid, | ||
'type': 'GatewayConfig', | ||
'action': action, | ||
'result': result, | ||
'name': 'N/A', | ||
'message': message, | ||
'refId': '', | ||
'namespace': namespace | ||
}) | ||
|
||
def record_activity (activity): | ||
log = app.logger | ||
portal_url = app.config['portal']['url'] | ||
|
||
log.debug("record_activity %s : %s %s" % (portal_url, activity['id'], activity['result'])) | ||
|
||
if portal_url != "": | ||
headers = { | ||
"Content-Type": "application/json" | ||
} | ||
try: | ||
r = requests.put("%s/feed/Activity" % portal_url, headers=headers, json=activity, timeout=5) | ||
log.info("Request Record Activity %s : %d" % (portal_url, r.status_code)) | ||
except Exception as ex: | ||
log.error("Error recording activity %s : %s" % (portal_url, str(ex))) | ||
traceback.print_exc(file=sys.stdout) |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
ply==3.10 | ||
cryptography==3.1.1 | ||
authlib==0.14.3 | ||
authlib==0.15.3 | ||
swagger-ui-py==0.3.0 | ||
Jinja2==2.11.2 | ||
PyYAML==5.3.1 | ||
|
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
Oops, something went wrong.