diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e6c6cc6f650159531ee88311a55e699150d53e3..bcaa8addf1692106f27e52d944dd5467c67fabe7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ stages: - build - - build-testimages + - build-test-images - application-test - integration-test @@ -73,7 +73,7 @@ behave-integration: - --dangerous-force-http - --dangerous-allow-insecure-redirect-urls - http://oauth:5000/callback - - name: open.greenhost.net:4567/openappstack/user-panel:integration + - name: open.greenhost.net:4567/openappstack/user-panel:master alias: backend - name: ${CI_REGISTRY_IMAGE}/login_logout:${CI_COMMIT_REF_NAME} alias: oauth @@ -83,11 +83,11 @@ behave-integration: # in the order that the services are started which is the order of # the services listed in the job configuration DATABASE_HOST: "172.17.0.2" # 172.17.0.2 -> postgres - URLS_LOGIN: "http://172.17.0.3:5000/" # 172.17.0.3 -> login + URLS_LOGIN: "http://172.17.0.3:5000/login" # 172.17.0.3 -> login URLS_LOGOUT: "http://172.17.0.3:5000/logout" LOGOUT_URL: "http://172.17.0.3:5000/logout" URLS_POST_LOGOUT_REDIRECT: "http://172.17.0.3:5000/" - URLS_CONSENT: "http://172.17.0.4:5001/" # 172.17.0.4 -> consent + URLS_CONSENT: "http://172.17.0.4:5001/consent" # 172.17.0.4 -> consent URLS_SELF_ISSUER: "http://172.17.0.5:4444/" # 172.17.0.5 -> hydra HYDRA_ADMIN_URL: "http://172.17.0.5:4445" ACCESS_TOKEN_URL: "http://172.17.0.5:4444/oauth2/token" diff --git a/login_provider/Dockerfile b/login_provider/Dockerfile index a499151af4a69542d70259271d199e7e7596fa72..c671dd715c1d64a7ee2bf29f35b1881cffdbec30 100644 --- a/login_provider/Dockerfile +++ b/login_provider/Dockerfile @@ -11,6 +11,8 @@ EXPOSE 5000 ENV FLASK_ENV production ENV FLASK_RUN_HOST 0.0.0.0 -ENV HYDRA_ADMIN_URL http://localhost:4445 +ENV FLASK_RUN_PORT 5000 +ENV HYDRA_ADMIN_URL http://localhost:444 +ENV GRAPHQL_URL http://localhost:5002/graphql CMD [ "flask", "run" ] diff --git a/login_provider/README.md b/login_provider/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f04d92ea635ef4234e52a2cb4ac2aaca69a624b5 --- /dev/null +++ b/login_provider/README.md @@ -0,0 +1,22 @@ +# Configuration + +To enable the `debug` mode, set the environment variable `FLASK_ENV` to `development`. + +``` +export FLASK_ENV=development +# or +docker login-provider:latest build . && docker run -e FLASK_ENV=development login-provider +``` + +You can do the same with the following variables. + + * **FLASK_SECRET_KEY** A secret key that will be used for securely signing the session cookie. + * **FLASK_RUN_HOST** IP Address that the server will open a socket on. + *Default*: 0.0.0.0 + * **FLASK_RUN_PORT** Port of the socket that the server will listen on. + *Default*: 5000 + * **GRAPHQL_URL** URL to the server that runs the graphql backend API + *Default*: http://localhost:5002/graphql + * **HYDRA_ADMIN_URL** URl to the Hydra admin server + *Default*: http://localhost:4445 + diff --git a/login_provider/app.py b/login_provider/app.py index 4f9d51b4c82a7afe03fbdafb623bb4275c755c79..d18ea6587a7a8f180109274841f37da39224d1b4 100644 --- a/login_provider/app.py +++ b/login_provider/app.py @@ -7,7 +7,7 @@ from forms import LoginForm import logging HYDRA_ADMIN_URL = environ['HYDRA_ADMIN_URL'] -hydra = HydraAdmin(HYDRA_ADMIN_URL) +HYDRA = HydraAdmin(HYDRA_ADMIN_URL) app = Flask(__name__) app.config['SECRET_KEY'] = urandom(16) @@ -16,7 +16,7 @@ app.logger.setLevel(logging.INFO) @app.route('/login', methods=['GET', 'POST']) def login(): - """Provides login form and handles Login attempt + """Provides login form and handles login attempt Args: login_form: contains login data submitted by a user (POST) diff --git a/login_provider/db.py b/login_provider/db.py index e55b4efc0f25939a873e36b5c3a63a7e0f99e632..69d03aed745580953a084b562682d2209c7af0c1 100644 --- a/login_provider/db.py +++ b/login_provider/db.py @@ -7,6 +7,7 @@ from json import loads GRAPHQL_URL = environ['GRAPHQL_URL'] graphql_client = GraphQLClient(GRAPHQL_URL) + class User(UserMixin): def __init__(self, username): self.id = username @@ -20,7 +21,7 @@ class User(UserMixin): getUser(username: "{0}"){{ email, active - }}}}'''.format(self.username).strip() + }}}}'''.format(self.username) result = loads(graphql_client.execute(querystring)) if "data" in result and result["data"]["getUser"] is not None: self.active = result["data"]["getUser"]["active"] @@ -44,7 +45,7 @@ class User(UserMixin): verifyPassword( username: "{0}", password: "{1}") - }}'''.format(self.username, password).strip() + }}'''.fromat(self.username, password) result = loads(graphql_client.execute(querystring)) verified = False if "data" in result: