Skip to content

Commit

Permalink
Merge pull request #12 from IN-CORE/release-1.3.0
Browse files Browse the repository at this point in the history
created release 1.3.0
  • Loading branch information
ywkim312 authored Dec 14, 2021
2 parents 0dde762 + ab7e787 commit 884c2b3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ helm/incore/templates/secrets.yaml

# ip database
IP2LOCATION-LITE-DB5.BIN

# env file
*.env
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

From version 1.2.0 the file IP2LOCATION-LITE-DB5.BIN is no longer part of the docker image and will need to be downloaded (after registration) from [ip2location](https://lite.ip2location.com/database/ip-country?lang=en_US) and be placed in /srv/incore_auth.

# [1.3.0] - 2021-21-08
## Added
- IP2Location's file location as variable

## Changed
- Removed adding X-Userinfo from response headers

# [1.2.1] - 2021-10-29

## Fixed
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ENV FLASK_APP="app.py" \
KEYCLOAK_AUDIENCE="" \
INFLUXDB_V2_URL="" \
INFLUXDB_V2_ORG="" \
INFLUXDB_V2_TOKEN=""
INFLUXDB_V2_TOKEN="" \
INFLUXDB_V2_FILE_LOCATION="data/IP2LOCATION-LITE-DB5.BIN"

#CMD ["python", "-m", "flask", "run", "--host", "0.0.0.0"]
CMD ["gunicorn", "app:app", "--config", "/srv/incore_auth/gunicorn.config.py"]
Expand Down
17 changes: 8 additions & 9 deletions incore_auth/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from jose import jwt
from jose.exceptions import JWTError, ExpiredSignatureError, JWTClaimsError
from urllib.parse import unquote_plus
from dotenv import load_dotenv

# Load .env file
load_dotenv()
CONTRIBUTION_DB_NAME = os.getenv('INFLUXDB_V2_FILE_LOCATION', 'data/IP2LOCATION-LITE-DB5.BIN')

config = json.load(open("config.json"))
app = Flask(__name__)
Expand All @@ -22,7 +27,7 @@

# setup database for geolocation
try:
geolocation = IP2Location.IP2Location("IP2LOCATION-LITE-DB5.BIN")
geolocation = IP2Location.IP2Location(CONTRIBUTION_DB_NAME)
except:
app.logger.exception("No IP2Location database found.")
geolocation = None
Expand Down Expand Up @@ -276,16 +281,10 @@ def verify_token():
elif request.cookies.get('Authorization') is not None:
response.headers['Authorization'] = unquote_plus(request.cookies['Authorization'])

# TODO this need checking, does this allow me to impersonate anybody?
if request.headers.get('X-UserInfo') is not None:
response.headers['X-UserInfo'] = request.headers.get('x-UserInfo')
elif request.cookies.get('x-UserInfo') is not None:
response.headers['X-UserInfo'] = request.headers.get('x-UserInfo')

if request.headers.get('X-UserGroup') is not None:
response.headers['X-UserGroup'] = request.headers.get('x-UserGroup')
elif request.cookies.get('x-UserInfo') is not None:
response.headers['X-UserGroup'] = request.headers.get('x-UserGroup')
elif request.cookies.get('X-UserGroup') is not None:
response.headers['X-UserGroup'] = request.cookies['X-UserGroup']

return response

Expand Down
1 change: 1 addition & 0 deletions incore_auth/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ python-jose==3.1.0
influxdb-client==1.14.0
IP2Location==8.5.1
geohash2==1.1
python-dotenv==0.10.3

0 comments on commit 884c2b3

Please sign in to comment.