techservicesillinois / secdev-quarantinenetwork

Source code for the Quarantine Network API and self-service portal
Other
2 stars 0 forks source link

Token should be cached and a new token created only when the cached one has expired #18

Open zdc217 opened 4 years ago

zdc217 commented 4 years ago

Per @ddriddle: For this code to be production quality you are going to need to cache the token, and only get a new token when the old token expires...this should be fixed soon.

zdc217 commented 4 years ago

Can cache with a global var.

Example here https://github.com/techservicesillinois/box-team-folders/blob/master/teamfolders/app/teamfolders.py

zdc217 commented 4 years ago

Per @ddriddle: Here is another example of caching specific to lambda:

# Best practice recommends declaring client as a global variable:
# https://aws.amazon.com/blogs/networking-and-content-delivery/lambdaedge-design-best-practices/
resource: 'DynamoDBServiceResource' = boto3.resource(
    'dynamodb',
    endpoint_url=os.environ.get('DYNAMODB_ENDPOINT_URL'),
)

https://github.com/techservicesillinois/terraform-aws-cloudfront-lambda-basic-auth/blob/master/src/lambda/auth.py

edthedev commented 4 years ago

QNet work has been on hold due to COVID response and related back-to-school priority efforts.