From: asteroide Date: Wed, 17 May 2017 08:09:16 +0000 (+0200) Subject: Add CORS to Keystone X-Git-Tag: opnfv-5.1.RC1~85 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F34881%2F1;p=moon.git Add CORS to Keystone Change-Id: Ie705bf519d880fa3a20ce61ca75f501f2fa93a62 --- diff --git a/moonv4/templates/docker/keystone/Dockerfile b/moonv4/templates/docker/keystone/Dockerfile index b8ba8212..a0be0fa2 100644 --- a/moonv4/templates/docker/keystone/Dockerfile +++ b/moonv4/templates/docker/keystone/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:latest ENV ADMIN_TOKEN=p4ssw0rd ENV ADMIN_PASSWORD=p4ssw0rd -ENV DB_CONNECTION=mysql+pymysql +ENV DB_CONNECTION="mysql+pymysql" ENV DB_DRIVER=sql ENV DB_HOST=localhost ENV DB_DATABASE=keystonedb @@ -12,6 +12,7 @@ ENV DB_PASSWORD=p4ssw0rd ENV DB_USER_ROOT=root ENV DB_PASSWORD_ROOT=p4sswOrd1 ENV RABBIT_NODE=server +ENV INTERFACE_HOST="http://localhost:3001" RUN apt-get update && apt-get install apache2 rabbitmq-server keystone python-openstackclient libapache2-mod-wsgi mysql-client -y diff --git a/moonv4/templates/docker/keystone/run.sh b/moonv4/templates/docker/keystone/run.sh index 7c9a1a43..1442807b 100644 --- a/moonv4/templates/docker/keystone/run.sh +++ b/moonv4/templates/docker/keystone/run.sh @@ -6,11 +6,21 @@ echo DB_HOST=$DB_HOST echo DB_DATABASE=$DB_DATABASE echo RABBIT_NODE=$RABBIT_NODE echo RABBIT_NODE=$[RABBIT_NODE] +echo INTERFACE_HOST=$INTERFACE_HOST sed "s/#admin_token = /admin_token=$ADMIN_TOKEN/g" -i /etc/keystone/keystone.conf sed "s/connection = sqlite:\/\/\/\/var\/lib\/keystone\/keystone.db/connection = $DB_CONNECTION:\/\/$DB_USER:$DB_PASSWORD@$DB_HOST\/$DB_DATABASE/g" -i /etc/keystone/keystone.conf sed "s/#driver = sql/driver = $DB_DRIVER/g" -i /etc/keystone/keystone.conf +cat << EOF | tee -a /etc/keystone/keystone.conf +[cors] +allowed_origin = $INTERFACE_HOST +max_age = 3600 +allow_methods = GET,POST,PUT,DELETE +allow_headers = Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma,X-Custom-Header +expose_headers = Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma,X-Custom-Header +EOF + mysql -h $DB_HOST -u$DB_USER_ROOT -p$DB_PASSWORD_ROOT <