-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 17443 Add auth to colin api * Fix lint errors * Revert legal api updates
- Loading branch information
Showing
19 changed files
with
258 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
"application": [ | ||
"colin-api", | ||
"test-oracle", | ||
"sentry" | ||
"sentry", | ||
"jwt", | ||
"launchdarkly" | ||
] | ||
} | ||
] |
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,5 @@ | ||
{ | ||
"flagValues": { | ||
"disable-colin-api-auth": true | ||
} | ||
} |
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,31 +1,35 @@ | ||
Flask-Moment==0.10.0 | ||
|
||
Flask-Moment==0.11.0 | ||
Flask-Script==2.0.6 | ||
Flask==1.1.2 | ||
Jinja2==2.11.2 | ||
Jinja2==2.11.3 | ||
MarkupSafe==1.1.1 | ||
Werkzeug==1.0.1 | ||
aniso8601==8.1.0 | ||
attrs==20.3.0 | ||
aniso8601==9.0.1 | ||
blinker==1.4 | ||
certifi==2020.12.5 | ||
click==7.1.2 | ||
click==8.1.3 | ||
cx-Oracle==8.1.0 | ||
debugpy | ||
ecdsa==0.14.1 | ||
flask-jwt-oidc==0.1.5 | ||
flask-jwt-oidc==0.3.0 | ||
flask-restx==0.3.0 | ||
gunicorn==20.0.4 | ||
gunicorn==20.1.0 | ||
itsdangerous==1.1.0 | ||
jsonschema==3.2.0 | ||
jsonschema==4.19.0 | ||
launchdarkly-server-sdk==7.1.0 | ||
psycopg2-binary==2.8.6 | ||
pyasn1==0.4.8 | ||
pycountry==20.7.3 | ||
pyrsistent==0.17.3 | ||
python-dotenv==0.15.0 | ||
python-dotenv==0.17.1 | ||
python-jose==3.2.0 | ||
pytz==2020.4 | ||
rsa==4.6 | ||
pytz==2021.1 | ||
requests==2.25.1 | ||
rsa==4.7.2 | ||
SQLAlchemy==1.4.44 | ||
sentry-sdk==1.20.0 | ||
six==1.15.0 | ||
urllib3==1.26.11 | ||
git+https://github.com/bcgov/lear.git#egg=legal_api&subdirectory=legal-api | ||
git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas |
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,64 @@ | ||
# Copyright © 2023 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Core error handlers and custom exceptions. | ||
Following best practices from: | ||
http://flask.pocoo.org/docs/1.0/errorhandling/ | ||
http://flask.pocoo.org/docs/1.0/patterns/apierrors/ | ||
""" | ||
|
||
import logging | ||
import sys | ||
|
||
from flask import jsonify | ||
from werkzeug.exceptions import HTTPException | ||
from werkzeug.routing import RoutingException | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def init_app(app): | ||
"""Initialize the error handlers for the Flask app instance.""" | ||
app.register_error_handler(HTTPException, handle_http_error) | ||
app.register_error_handler(Exception, handle_uncaught_error) | ||
|
||
|
||
def handle_http_error(error): | ||
"""Handle HTTPExceptions. | ||
Include the error description and corresponding status code, known to be | ||
available on the werkzeug HTTPExceptions. | ||
""" | ||
# As werkzeug's routing exceptions also inherit from HTTPException, | ||
# check for those and allow them to return with redirect responses. | ||
if isinstance(error, RoutingException): | ||
return error | ||
|
||
response = jsonify({'message': error.description}) | ||
response.status_code = error.code | ||
return response | ||
|
||
|
||
def handle_uncaught_error(error: Exception): # pylint: disable=unused-argument | ||
"""Handle any uncaught exceptions. | ||
Since the handler suppresses the actual exception, log it explicitly to | ||
ensure it's logged and recorded in Sentry. | ||
""" | ||
logger.error('Uncaught exception', exc_info=sys.exc_info()) | ||
response = jsonify({'message': 'Internal server errors'}) | ||
response.status_code = 500 | ||
return 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
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
Oops, something went wrong.