-
Notifications
You must be signed in to change notification settings - Fork 67
API keys, local PR edition #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
260 commits
Select commit
Hold shift + click to select a range
c7ca927
very basic admin interface
dmytrotsko d066a90
list all known roles
dmytrotsko 8b09387
remove log statement
dmytrotsko e940f8b
fixup tests
dmytrotsko 8bb2789
add record flag to user
dmytrotsko 3161d2e
basic record based on flag logging
dmytrotsko 9ab8978
rename column to tracking
dmytrotsko 54dc83c
add webhook endpoint for google forms and simplify table
dmytrotsko 62122cf
tests for simplified api_user
dmytrotsko 32096ac
prepare for sending mails with mailgun
dmytrotsko 45414bc
disable security check for test setup
dmytrotsko 60f7cd6
fix tests
dmytrotsko dac3fcb
add registered flag
dmytrotsko d880795
request a simple api key form with recaptcha check
dmytrotsko e76cde4
implement rate limiting
dmytrotsko f1f008e
registered flag not saved
dmytrotsko 98315c6
mark all tests no rate limit
dmytrotsko f897e28
add link to registration form within api key form
dmytrotsko b345f76
elevate sqlalchemy log level to ERROR for test purpose
dmytrotsko 5ce96bd
add structlog to requirements
dmytrotsko f851d5b
add structured logging module
dmytrotsko 38abd83
implement api key scrubbing logs and getter functions for User class
dmytrotsko d65acb8
minor commenting change
dmytrotsko 5aee08f
change logging to kward format and add a get function for API key
dmytrotsko 7378e8d
move mask_apikey function out of User class
dmytrotsko 02a535b
minor change in variable name
dmytrotsko c18a122
Fixed test
dmytrotsko da947fd
added missing import
dmytrotsko 4732467
Fixed _is_public_route method. Added URL_PREFIX to list of routes
dmytrotsko ae1e6a1
Merge pull request #2 from dmytrotsko/fix_admin_endpoint_access
dmytrotsko 16a154c
Added email column to User table
dmytrotsko 4b5fa65
Merge branch 'api_key' of github.com:dmytrotsko/delphi-epidata into a…
dmytrotsko a8011fd
Fixed tests
dmytrotsko 6775384
Added Dockerfile for Redis
dmytrotsko 7e11435
Made email optional
dmytrotsko 74fd290
Added email address validaiton
dmytrotsko 8d496ba
Fixed API key creation via /create_key endpoint
dmytrotsko 3bc7095
Fixed /register endpoint after google script refactoring
dmytrotsko e39c82a
Fixed registration
dmytrotsko be80550
Reverted some changes in _config.py
dmytrotsko 8f21122
Reverted changes in .env.example
dmytrotsko 71bb186
Code refactoring
dmytrotsko aea77eb
Removed unused variables
dmytrotsko b7a6078
Code cleaning
dmytrotsko 635be31
Removed unused variables
dmytrotsko 93b056e
Removed default redis configuration file (it is not needed for now)
dmytrotsko df11183
Moved BASE_URL and auth to setUP, formatted code
dmytrotsko b63faa3
Moved BASE_URL and auth to setUP(), formatted code
dmytrotsko 9ed758b
Revert "Moved BASE_URL and auth to setUP(), formatted code"
dmytrotsko 02083a0
Formatted code & removed unused imports.
dmytrotsko 99f75a6
Created staticmethod _make_rqeuest() and reused it in test_caching() …
dmytrotsko f94ec4d
Returned BASE_URL and auth back, because if we use default BASE_URL f…
dmytrotsko 0480172
Completely removed patch_flask_config() function as it is useless. Th…
dmytrotsko 3586bcf
Removed duplicated _logger.py file (this is exact copy of src/acquisi…
dmytrotsko 1ee16f7
Fixed test
dmytrotsko 7ce411b
Removed unused method
dmytrotsko 68240ca
Added missing changes in Dockerfiles for copying logger
dmytrotsko d350347
Fixed misspelled filename
dmytrotsko 4bca6b4
Added missing variable in CSVPrinter
dmytrotsko 3cf15da
Formatted code
dmytrotsko ad00db5
Removed tests for admin endpoint for now
dmytrotsko 4285b87
Moved config variables from _security to _config. Removed duplicated …
dmytrotsko ec67149
Added missing changes
dmytrotsko 7a364d9
Replaced db.execute delete and update with built-it sqlalchemy functi…
dmytrotsko e4ae70c
Removed email field. Edited google form link to prefill tracking cons…
dmytrotsko c21689d
Removed api_user ddl
dmytrotsko 1ebff22
Changed user roles to use m2m table instead of string in api_user table
dmytrotsko c49c1f8
Added new variable for api key expiration date
dmytrotsko c54412c
Updated admin endpoint. Removed email from user details and added cre…
dmytrotsko 6c50703
Updated integration tests
dmytrotsko 3e34e3c
Updated endpoints to register user role on endpoint load
dmytrotsko 8fbae7d
Removed user_role FK in api_user table.
dmytrotsko 95507c2
Updated according to new structure
dmytrotsko 597eeb4
Removed API_KEY_EXPIRE_AFTER variable
dmytrotsko 08bd2b6
Removed creation_date, expiration_date and last_api_access_date from …
dmytrotsko c436b0a
Added roles registraion on endpoints load
dmytrotsko 199d434
Removed role registration statement
dmytrotsko 4422a5e
Fixed integration tests. Actually reverted latest changes as api_user…
dmytrotsko 806d6e4
Added new ddls
dmytrotsko 82a0e25
Merge branch 'dev' into api_key
dmytrotsko 58f715d
Fixed wrong import
dmytrotsko 73efe70
Fixed issue after resolving conflicts
dmytrotsko d291f61
Moved admin endpoint to another file into endpoints folder
dmytrotsko efe545f
Removed from _security.py all unnecessary functions
dmytrotsko 7433cf2
Changed roles registration process. Now we have only necessary roles.…
dmytrotsko c1947c3
Added IF NOT EXISTS to table creation statement
dmytrotsko 466adfb
Added missing import
dmytrotsko 16c4dec
Moved admin models to the separate file. Now we have only 1 User clas…
dmytrotsko 007be57
Added declarative_base and session objects to the _db.py file. To hav…
dmytrotsko a2de0c7
Updated tests to use statement in order to clean api_user table afte…
dmytrotsko 835d602
Reverted formatting
dmytrotsko 0913051
Reverted formatting
dmytrotsko 0c5f12a
Removed copying of _logger.py
dmytrotsko 0e9c7c8
Fixed auth props
dmytrotsko e212abe
Added missing requirements
dmytrotsko 56c8cbb
Added authentication params
dmytrotsko d3ec9a6
Removed unused imports
dmytrotsko db9d87b
Added new columns to api_user table
dmytrotsko 4c6d84a
Added placeholder to handle api key last usage update
dmytrotsko 2f2398a
Added Redis host variable
dmytrotsko c75f0ea
Uncommented @after_reqeust function to update last API key usage in R…
dmytrotsko 96b4363
Build image from api-keys branch
korlaxxalrok 0d81699
Updates TODO with issue
korlaxxalrok 8b41263
Added Redis to ci.yaml. Added several more env variables for delphi_w…
dmytrotsko 7a890b4
Merge branch 'api-keys' into api_key_v2
krivard 717a189
Merge pull request #1061 from dmytrotsko/api_key_v2
krivard f3e331f
Added Redis to the Makefile
dmytrotsko 719e52a
Changed ratelimit handling
dmytrotsko b8ac78c
Added default admin password, changed rate limit
dmytrotsko 6164285
Merge pull request #1142 from dmytrotsko/api_key_v2
dmytrotsko 57ff3ad
Updated ci.yaml
dmytrotsko fcd7794
Merge pull request #1143 from dmytrotsko/api_key_v2
dmytrotsko b3cbba5
Changed wrong redis host name
dmytrotsko 38c8448
Merge pull request #1144 from dmytrotsko/api_key_v2
dmytrotsko 8abf476
Added -d to redis container run command
dmytrotsko 2fe9797
Merge pull request #1145 from dmytrotsko/api_key_v2
dmytrotsko 2eb2d5d
Removed tailing colon
dmytrotsko 39033f4
Merge pull request #1146 from dmytrotsko/api_key_v2
dmytrotsko 2ff2616
Fixed get_multiples_count method
dmytrotsko 87823ab
Merge pull request #1147 from dmytrotsko/api_key_v2
dmytrotsko 2712c98
Temporary changed port
dmytrotsko c7f8a72
Merge pull request #1148 from dmytrotsko/api_key_v2
dmytrotsko 1b1df1d
Added check container status step + check delphi_web_epidata logs. Mu…
dmytrotsko 6e98968
Merge pull request #1149 from dmytrotsko/api_key_v2
dmytrotsko 67594b9
Removed --rm flag from delphi_web_epidata run command
dmytrotsko 2767bfb
Merge pull request #1150 from dmytrotsko/api_key_v2
dmytrotsko d4cfe43
Added check db logs step to ci.yaml
dmytrotsko 70a893e
Added delphi_redis to clean up step
dmytrotsko 3ac7da9
Reverted test changes
dmytrotsko 8cac85e
Moved docker run delphi_web_epidata below wait command.
dmytrotsko 0809371
Added name to run delphi_web_epidata step
dmytrotsko d8d10b0
Fixed issue with parsing allowed singals, removed unnecessary if/else…
dmytrotsko 64700d2
Added Redis auth options (set default password)
dmytrotsko 89a121e
adding dashboard signals module, plus requirements cleanup
melange396 5d19c51
updated _security.py:check_signals_allowlist() to use new DashboardSi…
melange396 28ac426
debugging w/ headers
melange396 048bdeb
better ip address logging and accounting
melange396 717edf9
Added admin folder to setup.cfg
dmytrotsko b8665bb
Upgraded Flask-Limiter version
dmytrotsko 13c1a86
Moved Flask-Limiter code to a separate file. Made limit to be host ba…
dmytrotsko e0996c2
Little refactoring, replaced MissingAPIKey exception by Unauthorized
dmytrotsko c16ddfc
Fixed limits for allowed signals
dmytrotsko eadad38
Merge branch 'api-keys' into dashboard_signals_sync
dmytrotsko 4bda66f
Merge pull request #1155 from cmu-delphi/dashboard_signals_sync
dmytrotsko f212adc
Added necessary changes
dmytrotsko 894fca6
Removed redundant user variable
dmytrotsko faa50c7
Update dev/local/Makefile wrt redis log file
melange396 47dc13e
reset dev/docker/python/Dockerfile
melange396 5fb9541
remove unused import in src/server/main.py
melange396 ebfeccd
alpha-order argument keys in get_multiples_count()
melange396 2464416
Removed API Key registration form
dmytrotsko 106908b
Removed recaptcha secrets from _config.py
dmytrotsko 55500b0
Added 'stop container if running' and option to redis entry
dmytrotsko c8b82db
Moved Flask-Limiter belov Flask to keep everyting sorted properly
dmytrotsko d2e39fd
Added missing newline
dmytrotsko 117b500
Added proper Epidata.auth handling for aiohttp ClientSession
dmytrotsko 8398bcc
Added missing request arg for require_all()
dmytrotsko f2bf4b7
Merged api-keys related ddls into 1 file, added constraints
dmytrotsko b6b53f6
Removed tracking and registered fields
dmytrotsko 8c671de
Removed usage of removed fields (tracking, registered). Added logging.
dmytrotsko 864dc1e
Adjusted flask-limiter with comms
dmytrotsko 95ce40d
Fixed tests
dmytrotsko b4e8030
Added templates folder
dmytrotsko 34c453f
Removed _db.py and moved all needed code to the _common.py
dmytrotsko 9538b8f
Exempted public routes from update_key_last_time_used function
dmytrotsko 786ba3e
Removed redundant tracking, registered mentions. Added email field to…
dmytrotsko cf233ec
Imported engine from _common.py instead of _db.py which was removed
dmytrotsko d70afb9
Removed leftovers of the old code
dmytrotsko 84f53af
Add auth support to delphi-epidata.R
krivard 9663f9d
Bring auth in delphi-epidata.py in line with current policy
krivard d449611
Embetter json decoding error message
krivard 111921e
Make user agent comply with spec; explain inactive R client endpoint …
krivard 17a3707
Merge pull request #1113 from cmu-delphi/krivard/apikeys-clients
krivard 6647e5f
Removed api_analytics table
dmytrotsko 267adf6
Added 'window' param handling in multiples. Removed hostname from lim…
dmytrotsko 46b0ee1
Added TODO to remove api keys warning messages
dmytrotsko c77837a
Added issue handling when API Key is provided but doesn't exist in da…
dmytrotsko 2c3ad7b
Fix
dmytrotsko 71fbf73
Changed limiter
dmytrotsko 02c242d
made api key rollout phase determination more consistent
melange396 8e775a0
add comment about enable_admin() method
melange396 85c7f1d
api_user table: UNSIGNED ids, removed description comments, renamed l…
melange396 14753d6
move api_key argument logging, invalid api key check, and last key us…
melange396 d502a2d
missed import for _is_public_route
melange396 833d6fb
removed TESTING_MODE and fixed unused imports
melange396 4fa390c
refactored into _db.py to remove circular import dependencies
melange396 6153f55
import for werkzeug Unauthorized exception
melange396 fc04599
removed recaptcha references
melange396 e75d613
moved missing import from _common to _db
melange396 f3833a1
distinguish config-sourced 'user roles' from db-based
melange396 a56ed19
logging additions, including experimental stuff
melange396 3501ab3
logging level change
melange396 a79c253
user object debugging during the api request/response flow
melange396 45b7f2d
fix logging case when there is no 'User'
melange396 b0cf9a7
Muted non-existing api key check
dmytrotsko c50e6a7
Formatting, added AUTH
dmytrotsko 133507a
Added 'old' endpoints auth logic
dmytrotsko 64eb673
Added email/api key duplicate check
dmytrotsko 7f57790
remove un-slashed app route
melange396 ff558a5
change url (route) prefix to be empty instead of a bare slash
melange396 86ee097
API Keys: API Documentation (#1158)
krivard 844f87f
Merge branch 'api-keys' of github.com:cmu-delphi/delphi-epidata into …
dmytrotsko e98c653
Unmuted api_key validation
dmytrotsko 025feca
Removed AUTH, added TEMPORARY_API_KEY and REGISTRATION_FORM_LINK
dmytrotsko 0c7d71e
Added requests_left() function to check user's remaining requests and…
dmytrotsko be0ca26
Removed old authentication, updated warning messages
dmytrotsko 868d728
Added limit exceed, multiple exceed, temporary key messages to the pr…
dmytrotsko 6b61aab
Fixed fluview endpoint authentication
dmytrotsko 851eb10
Fluview endpoint hotfix
dmytrotsko 964afd6
Added ratelimit headers to the response
dmytrotsko 81e0eb9
Adjusted limiter warning messages(Messages text taken from PR#1163). …
dmytrotsko c4e17b3
Update _security.py -- checks for all 4 phases
melange396 72cf10a
solidified rate limit filter behavior
melange396 4069412
Fixed user update. Removed api_key check on phase 1
dmytrotsko ee7afdb
Added handling for data_source&signal pairs
dmytrotsko 9f3d166
Fixed order of warnings
dmytrotsko c9734db
Fixed printer message
dmytrotsko 069cbbd
logging changes, including rows returned and api user db CrUD operations
melange396 4d39e96
Printer messages hotfix
dmytrotsko b1e0a0e
Fixed printer warnings
dmytrotsko 6cb9b47
Hotfix
dmytrotsko d29f9f4
_printer hotfix
dmytrotsko c0491bd
Fix _printer
dmytrotsko c4b1a01
reduced usages of flask.g, improved usages of _get_current_user() / c…
melange396 f91cee9
update api-keys config variables with now-announced values
melange396 cee1f39
took roles out of config (its in db now), simplified role checking in…
melange396 09c7b94
logging cleanup
melange396 fcc1f4b
force named arguments
melange396 262b391
update api-keys registration and removal links
melange396 bc3aeb3
added local redirects for gForms for registration and user deletion, …
melange396 1e35a09
fix typo in import statement
melange396 581c4d3
update api-key error messages to use local redirect to registration form
melange396 0bda3a8
fix 'multiples' detection so it recognizes date ranges as well
melange396 a01d894
fix 'multiples' detection, cant do instance checks w/ subscripted gen…
melange396 806b6b2
fix 'multiples' detection, check for list instead of Sequence)
melange396 51b0ac4
Text check for rollout (#1171)
krivard 4fb920f
Fixed expired session by using new session for each User operation
dmytrotsko a62e40f
merging `dev` brach changes into `api-keys`
melange396 0bf9635
Fix environment variable and 429 output method
krivard fc21650
Propagate API key rollout env variable namechange to .env template
krivard 4cb2fbc
updated docs to local forwards for google forms links
melange396 3b7a457
adding key request form script
melange396 94cea20
fix user_id logging (logged user w/ email before, which was removed c…
melange396 6f6e813
fixed scope for db_user
melange396 2a7c26d
orm/user debugging
melange396 56caf92
grrr stupid typo
melange396 b80a225
more user/role debugging
melange396 0624c72
Update usage text in src/server/admin/api_key_form_script.js
melange396 cc08722
cleaning up...
melange396 80514c1
changing sqlalchemy logging to match levels in dev
melange396 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| /delphi-epidata | ||
| /.mypy_cache | ||
| **/.mypy_cache | ||
| /.github | ||
| /docs | ||
| __pycache__ | ||
| /node_modules | ||
| **/__pycache__ | ||
| **/.pytest_cache | ||
| **/node_modules |
This file contains hidden or 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,18 +1,6 @@ | ||
| FLASK_DEBUG=True | ||
| SQLALCHEMY_DATABASE_URI=sqlite:///test.db | ||
| FLASK_SECRET=abc | ||
| SECRET_TWITTER=abc | ||
| SECRET_GHT=abc | ||
| SECRET_FLUVIEW=abc | ||
| SECRET_CDC=abc | ||
| SECRET_SENSORS=abc | ||
| SECRET_SENSOR_TWTR=abc | ||
| SECRET_SENSOR_GFT=abc | ||
| SECRET_SENSOR_GHT=abc | ||
| SECRET_SENSOR_GHTJ=abc | ||
| SECRET_SENSOR_CDC=abc | ||
| SECRET_SENSOR_QUID=abc | ||
| SECRET_SENSOR_WIKI=abc | ||
| SECRET_QUIDEL=abc | ||
| SECRET_NOROSTAT=abc | ||
| SECRET_AFHSB=abc | ||
| #API_KEY_REQUIRED_STARTING_AT=2021-07-30 | ||
| API_KEY_ADMIN_PASSWORD=abc | ||
| API_KEY_REGISTER_WEBHOOK_TOKEN=abc |
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| FROM redis | ||
|
|
||
| ENV REDIS_PASSWORD=$REDIS_PASSWORD | ||
|
|
||
| CMD ["sh", "-c", "exec redis-server --requirepass \"$REDIS_PASSWORD\""] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ purposes: | |
| * to identify excessive or abnormal usage patterns which may harm our system | ||
|
|
||
| The logs are only available to members of our operations team, and are expunged | ||
| at or before they reach five years in age. | ||
| at or before they reach five years in age. | ||
|
|
||
| If you provide us with your email address, we will only use it to contact you in | ||
| the following scenarios: | ||
|
|
@@ -47,9 +47,9 @@ security practices to help us keep your information secure. We only retrieve | |
| this mapping to resolve cases of excessive or abnormal usage. We automatically | ||
| disassociate an email address from its API key when the API key has not been | ||
| used for six months, or upon user request. You can request that your | ||
| email address be removed from our records by filling out a | ||
| [deletion request](https://forms.gle/GucFmZHTMgEFjH197). | ||
| email address be removed from our records by filling out a | ||
| [deletion request](https://api.delphi.cmu.edu/epidata/admin/removal_request). | ||
|
|
||
| For more information, see | ||
| For more information, see | ||
| [Carnegie Mellon’s privacy notice](https://www.cmu.edu/legal/privacy-notice.html). | ||
| Further questions can be directed to [email protected]. | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.