lab7
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import pathlib
|
||||
import secrets
|
||||
import json
|
||||
|
||||
p = pathlib.Path('.env')
|
||||
env = dict(x.split('=',1) for x in p.read_text().splitlines() if '=' in x and not x.startswith('#'))
|
||||
|
||||
for role in ('API', 'WORKER'):
|
||||
env.setdefault('S3_'+role+'_PASSWORD', secrets.token_hex(24))
|
||||
|
||||
p.write_text(''.join(f'{k}={v}\n' for k,v in env.items()))
|
||||
|
||||
config = {
|
||||
'identities': [
|
||||
{
|
||||
'name': 'operator',
|
||||
'credentials': [{'accessKey':'lab','secretKey':env['S3_SECRET_ACCESS_KEY']}],
|
||||
'actions': ['Admin','Read','Write','List']
|
||||
},
|
||||
{
|
||||
'name': 'api',
|
||||
'credentials': [{'accessKey':'messenger_api','secretKey':env['S3_API_PASSWORD']}],
|
||||
'actions': ['Read:messenger-attachments','Write:messenger-attachments','List:messenger-attachments']
|
||||
},
|
||||
{
|
||||
'name': 'worker',
|
||||
'credentials': [{'accessKey':'messenger_worker','secretKey':env['S3_WORKER_PASSWORD']}],
|
||||
'actions': ['Read:messenger-attachments','Write:messenger-attachments','List:messenger-attachments']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
pathlib.Path('secrets/s3.json').write_text(json.dumps(config))
|
||||
print('PASS: S3 identities configured')
|
||||
Reference in New Issue
Block a user