Skip to content

Commit

Permalink
Support separate CAA and EAA access keys
Browse files Browse the repository at this point in the history
The CAA and EAA actually use different IA credentials to manage their
collections.

This splits the current configuration options into per-project ones.
  • Loading branch information
mwiencek committed May 23, 2024
1 parent 78c5ee2 commit 7f40b56
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
6 changes: 4 additions & 2 deletions config.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ dbname=musicbrainz_db

[s3]
url=https://{bucket}.s3.us.archive.org/{file}
access=
secret=
caa_access=
caa_secret=
eaa_access=
eaa_secret=

[sentry]
dsn=
6 changes: 4 additions & 2 deletions config.tests.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ dbname=musicbrainz_test_artwork_indexer

[s3]
url=http://{bucket}.s3.example.com/{file}
access=user
secret=pass
caa_access=caa_user
caa_secret=caa_pass
eaa_access=eaa_user
eaa_secret=eaa_pass
6 changes: 4 additions & 2 deletions docker/config.ini.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ dbname={{ keyOrDefault (print $key_prefix "postgres_database") "musicbrainz_db"

[s3]
url={{ keyOrDefault (print $key_prefix "s3_url") "https://{bucket}.s3.us.archive.org/{file}" }}
access={{ keyOrDefault (print $key_prefix "s3_access_key") "" }}
secret={{ keyOrDefault (print $key_prefix "s3_secret_key") "" }}
caa_access={{ keyOrDefault (print $key_prefix "caa_s3_access_key") "" }}
caa_secret={{ keyOrDefault (print $key_prefix "caa_s3_secret_key") "" }}
eaa_access={{ keyOrDefault (print $key_prefix "eaa_s3_access_key") "" }}
eaa_secret={{ keyOrDefault (print $key_prefix "eaa_s3_secret_key") "" }}
4 changes: 4 additions & 0 deletions generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ def entity_type(self):
def ia_collection(self):
return '{project['ia_collection']}'
@property
def project_abbr(self):
return '{project['abbr']}'
@property
def ws_inc_params(self):
return '{project['ws_inc_params']}'
Expand Down
8 changes: 8 additions & 0 deletions handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def entity_type(self):
def ia_collection(self):
return 'coverartarchive'

@property
def project_abbr(self):
return 'caa'

@property
def ws_inc_params(self):
return 'artists'
Expand All @@ -44,6 +48,10 @@ def entity_type(self):
def ia_collection(self):
return 'eventartarchive'

@property
def project_abbr(self):
return 'eaa'

@property
def ws_inc_params(self):
return 'artist-rels+place-rels'
Expand Down
9 changes: 7 additions & 2 deletions handlers_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ def gid_name(self):
def ia_collection(self):
raise NotImplementedError

@property
def project_abbr(self):
raise NotImplementedError

def build_authorization_header(self):
abbr = self.project_abbr
s3_conf = self.config['s3']
return {
'authorization': 'LOW %s:%s' % (
s3_conf['access'],
s3_conf['secret'],
s3_conf[abbr + '_access'],
s3_conf[abbr + '_secret'],
),
}

Expand Down

0 comments on commit 7f40b56

Please sign in to comment.