Skip to content

Commit

Permalink
#193 chore: moved the social keys and secrets to a k8 secret
Browse files Browse the repository at this point in the history
  • Loading branch information
zsinnema committed May 14, 2021
1 parent bc2fa8e commit ddddeb5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
18 changes: 11 additions & 7 deletions scidash/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,27 @@
# see https://python-social-auth.readthedocs.io/en/latest/backends/index.html
# for configation of social backends

def get_secret(secret):
sec_path = os.getenv('SECRETS_PATH','/etc/secrets')
with open(os.path.join(sec_path, secret)) as fh:
return fh.read()

# GOOGLE
# https://python-social-auth.readthedocs.io/en/latest/backends/google.html
# see https://developers.google.com/identity/protocols/oauth2?csw=1#Registering
# to get google client id (key) and secret
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '732706977649-oou1hmc5q4mbrsida2bvu0mplmsebok0.apps.googleusercontent.com'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'WbtBzkxLVODaSi9PcPHS2DuL'
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = get_secret('SOCIAL_AUTH_GOOGLE_OAUTH2_KEY')
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = get_secret('SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET')

# TWITTER
# https://python-social-auth.readthedocs.io/en/latest/backends/twitter.html
SOCIAL_AUTH_TWITTER_KEY = 'YLbWDorRWSsO1FQo5kanraUzt'
SOCIAL_AUTH_TWITTER_SECRET = '2D8ICyjXOMssEdfaw0v8Qtyb2vEGpFUYTjLdIZ1YiMJE0TR0rx'
# twitter bearer token: AAAAAAAAAAAAAAAAAAAAAPJuPgEAAAAAhP2wPOYLMrjP0RNRzfFGj%2BUgJrE%3DlEjIikC9mLUfDpQsVMyPuAK4f5k4TNHQHLXVGqmkeDVEzbPkv2
SOCIAL_AUTH_TWITTER_KEY = get_secret('SOCIAL_AUTH_TWITTER_KEY')
SOCIAL_AUTH_TWITTER_SECRET = get_secret('SOCIAL_AUTH_TWITTER_SECRET')

# GITHUB
# https://python-social-auth.readthedocs.io/en/latest/backends/github.html
SOCIAL_AUTH_GITHUB_KEY = '6e17b37f51445888e940'
SOCIAL_AUTH_GITHUB_SECRET = 'b920fd48bb6a057225989692bb5eacb84032bab5'
SOCIAL_AUTH_GITHUB_KEY = get_secret('SOCIAL_AUTH_GITHUB_KEY')
SOCIAL_AUTH_GITHUB_SECRET = get_secret('SOCIAL_AUTH_GITHUB_SECRET')

AUTHENTICATION_BACKENDS = (
'social_core.backends.open_id.OpenIdAuth',
Expand Down
9 changes: 8 additions & 1 deletion service/deployment/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
version: '2'
version: '3'

services:
scidash-redis:
image: redis
ports:
- 6379:6379
expose:
- 6379
scidash-postgres:
image: metacell/scidash_db:latest
container_name: scidash_db
ports:
- 5432:5432
expose:
- 5432
volumes:
Expand All @@ -17,6 +21,8 @@ services:
container_name: scidash_virgo
volumes:
- geppettoTmp-volume:/opt/virgo/geppettoTmp
ports:
- 8080:8080
expose:
- 8080
mem_reservation: 5120m
Expand All @@ -33,6 +39,7 @@ services:
- SYS_ADMIN
volumes:
- geppettoTmp-volume:/opt/virgo/geppettoTmp
- ./secrets:/etc/secrets
ports:
- 8000:8000
depends_on:
Expand Down
1 change: 1 addition & 0 deletions service/docker/Dockerfile-scidash
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ RUN cp ./service/dotenv/scidash_env .env

USER root
RUN echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/userns.conf
RUN mkdir -p /etc/secrets

USER developer
CMD ./service/scripts/run.sh
25 changes: 22 additions & 3 deletions service/k8s/scidash.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
apiVersion: v1
kind: Secret
metadata:
name: scidash
type: Opaque
stringData:
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY: key
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET: secret
SOCIAL_AUTH_TWITTER_KEY: key
SOCIAL_AUTH_TWITTER_SECRET: secret
SOCIAL_AUTH_GITHUB_KEY: key
SOCIAL_AUTH_GITHUB_SECRET: secret
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: scidash-geppettotmp
Expand Down Expand Up @@ -30,18 +43,21 @@ spec:
spec:
containers:
- name: scidash
image: us.gcr.io/metacellllc/scidash:{{CF_BUILD_ID}}
image: metacell/scidash:latest
imagePullPolicy: IfNotPresent
env:
- name: CF_BUILD_ID
value: "{{CF_BUILD_ID}}"
value: latest
- name: ENVIRONMENT
value: "{{ENVIRONMENT}}"
value: Development
ports:
- containerPort: 8000
volumeMounts:
- name: scidash-geppettotmp
mountPath: /opt/virgo/geppettoTmp
- name: secrets
mountPath: "/etc/secrets"
readOnly: true
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -56,6 +72,9 @@ spec:
- name: scidash-geppettotmp
persistentVolumeClaim:
claimName: scidash-geppettotmp
- name: secrets
secret:
secretName: scidash
---
apiVersion: v1
kind: Service
Expand Down

0 comments on commit ddddeb5

Please sign in to comment.