Skip to content
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

add api_key auth against hubgrep_indexer #8

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ FLASK_DEBUG=True

HUBGREP_CRAWLERS_USER_AGENT_SUFFIX="@ https://hubgrep.io/about"
HUBGREP_INDEXER_URL=
HUBGREP_INDEXER_API_KEY=
3 changes: 3 additions & 0 deletions crawlers/cli_blueprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def get_requests_session():
total=3, backoff_factor=10, status_forcelist=[429, 500, 502, 503, 504]
)
session.mount("https://", HTTPAdapter(max_retries=retries))
indexer_api_key = current_app.config.get("INDEXER_API_KEY", None)
if indexer_api_key:
session.headers.update({"Authorization": f"Basic {indexer_api_key}"})
return session


Expand Down
1 change: 1 addition & 0 deletions crawlers/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Config:
class _EnvironmentConfig(Config):
CRAWLER_USER_AGENT = f'HobGrebbit v{Config.VERSION} {os.environ.get("HUBGREP_CRAWLERS_USER_AGENT_SUFFIX")}'
INDEXER_URL = os.environ.get("HUBGREP_INDEXER_URL")
INDEXER_API_KEY = os.environ.get("HUBGREP_INDEXER_API_KEY")


class ProductionConfig(_EnvironmentConfig):
Expand Down