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

Support more secure ways to declare the APIKEY #88

Open
BurnzZ opened this issue Jul 28, 2020 · 1 comment
Open

Support more secure ways to declare the APIKEY #88

BurnzZ opened this issue Jul 28, 2020 · 1 comment

Comments

@BurnzZ
Copy link
Member

BurnzZ commented Jul 28, 2020

BACKGROUND:

As of version 1.6.0, there are two (2) ways of adding the API KEYS:

  1. via the settings.py:
CRAWLERA_APIKEY = 'apikey'
  1. via spider attribute:
class SampleSpider(scrapy.Spider):
    crawlera_apikey = 'apikey'

When using Scrapy Cloud, we could also declare it via:

  1. via Spider/Project settings

image

  1. via Scrapy Cloud Crawlera add-on

image

PROBLEM

What actually happens in reality is that the API KEYS are being written inside the code and committed in the repo.

The best practice would be to avoid any sensitive keys to be coupled alongside the code. #3 and #4 above already fixes this problem as we have the option to only declare the keys inside Scrapy Cloud.

However, this becomes a problem when trying to run the spider locally during development as the keys might not be there.

OBJECTIVES

This issue aims to be a discussion ground on exploring better ways to handle it.

For starters, here are a couple of ways to approach it:

  • A. Set and retrieve the keys via environment variables.

  • B. Set and retrieve the keys via local file that is uncommited to the repo. - Examples would be similar to how SSH keys are stored in ~/.ssh and AWS Keys in ~/.aws.

Either way, it should support different API KEYs per spider.

@Gallaecio
Copy link
Contributor

Option A is already doable through: https://docs.scrapy.org/en/latest/topics/settings.html#command-line-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants