├── .github ├── Dockerfile_OC ├── Dockerfile_nginx_OC ├── apimanager.conf ├── dependabot.yml ├── gunicorn.conf.py ├── local_settings_container.py └── workflows │ ├── build_container_image.yml │ ├── build_container_image_non_develop_branches.yml │ └── run_trivy.yml ├── .gitignore ├── CONTRIBUTING.MD ├── Dockerfile ├── Dockerfile_nginx ├── LICENSE ├── NOTICE ├── README.md ├── apimanager.service ├── apimanager ├── accountlist │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── accountlist │ │ │ ├── css │ │ │ └── accountlist.css │ │ │ └── js │ │ │ └── accountlist.js │ ├── templates │ │ └── accountlist │ │ │ └── accountlist.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── accounts │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── accounts │ │ │ ├── css │ │ │ └── accounts.css │ │ │ └── js │ │ │ └── accounts.js │ ├── templates │ │ └── accounts │ │ │ └── index.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── apicollectionlist │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── apicollectionlist │ │ │ ├── css │ │ │ └── apicollectionlist.css │ │ │ └── js │ │ │ └── apicollectionlist.js │ ├── templates │ │ └── apicollectionlist │ │ │ └── apicollectionlist.html │ ├── urls.py │ └── views.py ├── apicollections │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── apicollections │ │ │ └── js │ │ │ └── apicollections.js │ ├── templates │ │ └── apicollections │ │ │ ├── detail.html │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── apimanager │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── atmlist │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── atmlist │ │ │ ├── css │ │ │ └── atmlist.css │ │ │ └── js │ │ │ └── atmlist.js │ ├── templates │ │ └── atmlist │ │ │ └── atmlist.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── atms │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── atms │ │ │ ├── css │ │ │ └── atms.css │ │ │ └── js │ │ │ └── atms.js │ ├── templates │ │ └── atms │ │ │ ├── index.html │ │ │ └── update.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── banklist │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── models.py │ ├── static │ │ └── banklist │ │ │ ├── css │ │ │ └── banklist.css │ │ │ └── js │ │ │ └── banklist.js │ ├── templates │ │ └── banklist │ │ │ └── banklist.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── banks │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── banks │ │ │ ├── css │ │ │ └── banks.css │ │ │ └── js │ │ │ └── banks.js │ ├── templates │ │ └── banks │ │ │ ├── index.html │ │ │ └── update.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── base │ ├── __init__.py │ ├── apps.py │ ├── context_processors.py │ ├── filters.py │ ├── static │ │ ├── css │ │ │ ├── base.css │ │ │ ├── bootstrap.min.css │ │ │ ├── jquery-ui.css │ │ │ ├── jsoneditor.min.css │ │ │ ├── obpjsoneditor.css │ │ │ └── override.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── img │ │ │ ├── favicon.ico │ │ │ ├── jsoneditor-icons.svg │ │ │ └── tablesorter │ │ │ │ ├── asc.gif │ │ │ │ ├── bg.gif │ │ │ │ └── desc.gif │ │ └── js │ │ │ ├── Chart.min.js │ │ │ ├── base.js │ │ │ ├── bootstrap.min.js │ │ │ ├── inactivity-timer.js │ │ │ ├── inactivity.js │ │ │ ├── jquery-ui.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.tablesorter.min.js │ │ │ └── jsoneditor.min.js │ ├── templates │ │ ├── base.html │ │ └── home.html │ ├── utils.py │ └── views.py ├── branches │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── branches │ │ │ ├── css │ │ │ └── branches.css │ │ │ └── js │ │ │ └── branches.js │ ├── templates │ │ └── branches │ │ │ ├── index.html │ │ │ └── update.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── config │ ├── __init__.py │ ├── apps.py │ ├── static │ │ └── config │ │ │ ├── css │ │ │ └── config.css │ │ │ └── js │ │ │ └── config.js │ ├── templates │ │ └── config │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── connectormethod │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── connectormethod │ │ │ └── js │ │ │ └── connectormethod.js │ ├── templates │ │ └── connectormethod │ │ │ ├── detail.html │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── consumers │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── consumers │ │ │ ├── css │ │ │ └── consumers.css │ │ │ └── js │ │ │ └── consumers.js │ ├── templates │ │ └── consumers │ │ │ ├── detail.html │ │ │ ├── includes │ │ │ ├── filter_apptype.html │ │ │ ├── filter_enabled.html │ │ │ ├── filter_pagination.html │ │ │ └── filter_time.html │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── customerlist │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── customerlist │ │ │ ├── css │ │ │ └── customerlist.css │ │ │ └── js │ │ │ └── customerlist.js │ ├── templates │ │ └── customerlist │ │ │ └── customerlist.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── customers │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── customers │ │ │ ├── css │ │ │ └── customers.css │ │ │ └── js │ │ │ └── customers.js │ ├── templates │ │ └── customers │ │ │ └── create.html │ ├── urls.py │ └── views.py ├── dynamicendpoints │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── dynamicendpoints │ │ │ └── js │ │ │ └── dynamicendpoints.js │ ├── templates │ │ └── dynamicendpoints │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── entitlementrequests │ ├── __init__.py │ ├── apps.py │ ├── static │ │ └── entitlementrequests │ │ │ ├── css │ │ │ └── entitlementrequests.css │ │ │ └── js │ │ │ └── entitlementrequests.js │ ├── templates │ │ └── entitlementrequests │ │ │ ├── includes │ │ │ └── filter_time.html │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── locale │ ├── all │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ ├── de │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ ├── deepl_translation_function.py │ ├── es │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ ├── fi │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ ├── fr │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ ├── generatePo.py │ └── hi │ │ └── LC_MESSAGES │ │ ├── django.mo │ │ └── django.po ├── manage.py ├── methodrouting │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── methodrouting │ │ │ └── js │ │ │ └── methodrouting.js │ ├── templates │ │ └── methodrouting │ │ │ └── index.html │ ├── urls.py │ └── views.py ├── metrics │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── metrics │ │ │ ├── css │ │ │ └── metrics.css │ │ │ └── js │ │ │ ├── Chart.min.js │ │ │ ├── include_system_calls.js │ │ │ ├── lastEndpointMetric.js │ │ │ ├── metrics.js │ │ │ └── spinner.js │ ├── templates │ │ └── metrics │ │ │ ├── api.html │ │ │ ├── api_summary_partial_function.html │ │ │ ├── connector.html │ │ │ ├── custom_summary.html │ │ │ ├── daily_summary.html │ │ │ ├── hourly_summary.html │ │ │ ├── monthly_summary.html │ │ │ ├── quarterly_summary.html │ │ │ ├── weekly_summary.html │ │ │ └── yearly_summary.html │ ├── urls.py │ └── views.py ├── obp │ ├── __init__.py │ ├── api.py │ ├── apps.py │ ├── authenticator.py │ ├── directlogin.py │ ├── forms.py │ ├── gatewaylogin.py │ ├── oauth.py │ ├── templates │ │ └── obp │ │ │ ├── directlogin.html │ │ │ └── gatewaylogin.html │ ├── urls.py │ └── views.py ├── productlist │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── productlist │ │ │ ├── css │ │ │ └── productlist.css │ │ │ └── js │ │ │ └── productlist.js │ ├── templates │ │ └── productlist │ │ │ └── productlist.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── products │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── static │ │ └── products │ │ │ ├── css │ │ │ └── products.css │ │ │ └── js │ │ │ └── products.js │ ├── templates │ │ └── products │ │ │ ├── index.html │ │ │ └── update.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── systemviews │ ├── __init__.py │ ├── apps.py │ ├── models.py │ ├── static │ │ └── systemviews │ │ │ ├── css │ │ │ └── systemviews.css │ │ │ └── js │ │ │ └── systemviews.js │ ├── templates │ │ └── systemviews │ │ │ └── index.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── users │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ │ └── users │ │ │ ├── css │ │ │ └── users.css │ │ │ └── js │ │ │ └── users.js │ ├── templates │ │ └── users │ │ │ ├── detail.html │ │ │ ├── includes │ │ │ ├── filter_email.html │ │ │ ├── filter_locked.html │ │ │ ├── filter_pagination.html │ │ │ ├── filter_role.html │ │ │ └── filter_username.html │ │ │ ├── index.html │ │ │ └── invitation.html │ ├── urls.py │ └── views.py └── webui │ ├── __init__.py │ ├── apps.py │ ├── forms.py │ ├── static │ └── webui │ │ ├── css │ │ └── webui.css │ │ └── js │ │ └── webui.js │ ├── templates │ └── webui │ │ └── index.html │ ├── urls.py │ └── views.py ├── gunicorn.conf.py ├── nginx.apimanager.conf ├── requirements.txt └── supervisor.apimanager.conf /.github/Dockerfile_OC: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi9/python-39:latest 2 | USER root 3 | RUN dnf update -y 4 | RUN dnf install python3-psycopg2 -y 5 | ADD . /app 6 | COPY ./.github/local_settings_container.py /app/apimanager/apimanager/local_settings.py 7 | COPY ./.github/gunicorn.conf.py /app/gunicorn.conf.py 8 | RUN pip install -r /app/requirements.txt 9 | WORKDIR /app 10 | RUN ./apimanager/manage.py migrate 11 | RUN chgrp -R 0 /app && chmod -R g+rwX /app 12 | USER 501 13 | WORKDIR /app/apimanager 14 | EXPOSE 8000 15 | CMD ["gunicorn", "--bind", ":8000", "--config", "../gunicorn.conf.py", "apimanager.wsgi"] -------------------------------------------------------------------------------- /.github/Dockerfile_nginx_OC: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi9/python-39:latest AS builder 2 | USER 0 3 | RUN dnf update -y 4 | RUN dnf install python3-psycopg2 -y 5 | ADD . /app 6 | RUN cp /app/.github/local_settings_container.py /app/apimanager/apimanager/local_settings.py 7 | RUN pip install -r /app/requirements.txt 8 | RUN chown 501 / 9 | RUN chown -R 501 /app 10 | RUN chgrp -R 0 /app && chmod -R g+rwX /app 11 | USER 1001 12 | WORKDIR /app 13 | RUN python ./apimanager/manage.py collectstatic --noinput 14 | 15 | FROM registry.access.redhat.com/ubi9/nginx-120 16 | USER 0 17 | RUN dnf update -y 18 | ADD .github/apimanager.conf "${NGINX_DEFAULT_CONF_PATH}" 19 | COPY --from=builder /app/apimanager/static /opt/app-root/src 20 | RUN chgrp -R 0 /opt/app-root/src/ && chmod -R g+rwX /opt/app-root/src/ 21 | USER 1001 22 | CMD nginx -g "daemon off;" 23 | 24 | 25 | -------------------------------------------------------------------------------- /.github/apimanager.conf: -------------------------------------------------------------------------------- 1 | server_name apimanager; 2 | 3 | location / { 4 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 5 | # enable this if and only if you use HTTPS 6 | # proxy_set_header X-Forwarded-Proto https; 7 | proxy_set_header Host $http_host; 8 | proxy_redirect off; 9 | proxy_pass http://127.0.0.1:8000; 10 | } 11 | 12 | location /en/static { 13 | alias /opt/app-root/src; 14 | } 15 | location /es/static { 16 | alias /opt/app-root/src; 17 | } 18 | location /static { 19 | alias /opt/app-root/src; 20 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | 2 | version: 2 3 | updates: 4 | 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "weekly" 9 | 10 | - package-ecosystem: "pip" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | ignore: 15 | - dependency-name: "Django" 16 | versions: [ "5.x" ] -------------------------------------------------------------------------------- /.github/gunicorn.conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import multiprocessing 3 | import os 4 | 5 | 6 | bind = '127.0.0.1:8000' 7 | accesslog = '-' 8 | errorlog = '-' 9 | loglevel = os.getenv('DEBUG_LEVEL', 'info') 10 | workers = multiprocessing.cpu_count() * 2 + 1 11 | -------------------------------------------------------------------------------- /.github/local_settings_container.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | if os.getenv('OAUTH_CONSUMER_KEY'): 4 | OAUTH_CONSUMER_KEY = os.getenv('OAUTH_CONSUMER_KEY') 5 | else: 6 | OAUTH_CONSUMER_KEY = "initial_migration_dummy_value" 7 | if os.getenv('OAUTH_CONSUMER_SECRET'): 8 | OAUTH_CONSUMER_SECRET = os.getenv('OAUTH_CONSUMER_SECRET') 9 | else: 10 | OAUTH_CONSUMER_SECRET = "initial_migration_dummy_value" 11 | if os.getenv('SECRET_KEY'): 12 | SECRET_KEY = os.getenv('SECRET_KEY') 13 | else: 14 | SECRET_KEY = "initial_migration_dummy_value" 15 | if os.getenv('API_HOST'): 16 | API_HOST = os.getenv('API_HOST') 17 | if os.getenv('API_PORTAL'): 18 | API_PORTAL = os.getenv('API_PORTAL') 19 | if os.getenv('CALLBACK_BASE_URL'): 20 | CALLBACK_BASE_URL = os.getenv('CALLBACK_BASE_URL') 21 | if os.getenv('ALLOWED_HOSTS'): 22 | ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split(',') 23 | if os.getenv('CSRF_TRUSTED_ORIGINS'): 24 | CSRF_TRUSTED_ORIGINS = os.getenv('CSRF_TRUSTED_ORIGINS').split(',') 25 | if os.getenv('CORS_ORIGIN_WHITELIST'): 26 | CORS_ORIGIN_WHITELIST = os.getenv('CORS_ORIGIN_WHITELIST').split(',') 27 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 28 | DATABASES = { 29 | 'default': { 30 | 'ENGINE': 'django.db.backends.sqlite3', 31 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 32 | } 33 | } 34 | STATIC_ROOT = os.path.join(BASE_DIR, 'static') 35 | -------------------------------------------------------------------------------- /.github/workflows/run_trivy.yml: -------------------------------------------------------------------------------- 1 | name: scan container image 2 | 3 | on: 4 | workflow_run: 5 | workflows: [build and publish container develop branch, build and publish container non develop branches] 6 | types: [completed] 7 | env: 8 | ## Sets environment variable 9 | DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }} 10 | DOCKER_HUB_REPOSITORY: api-manager 11 | 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | - id: trivy-db 21 | name: Check trivy db sha 22 | env: 23 | GH_TOKEN: ${{ github.token }} 24 | run: | 25 | endpoint='/orgs/aquasecurity/packages/container/trivy-db/versions' 26 | headers='Accept: application/vnd.github+json' 27 | jqFilter='.[] | select(.metadata.container.tags[] | contains("latest")) | .name | sub("sha256:";"")' 28 | sha=$(gh api -H "${headers}" "${endpoint}" | jq --raw-output "${jqFilter}") 29 | echo "Trivy DB sha256:${sha}" 30 | echo "::set-output name=sha::${sha}" 31 | - uses: actions/cache@v4 32 | with: 33 | path: .trivy 34 | key: ${{ runner.os }}-trivy-db-${{ steps.trivy-db.outputs.sha }} 35 | - name: Run Trivy vulnerability scanner 36 | uses: aquasecurity/trivy-action@master 37 | with: 38 | image-ref: 'docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }}' 39 | format: 'template' 40 | template: '@/contrib/sarif.tpl' 41 | output: 'trivy-results.sarif' 42 | severity: 'CRITICAL,HIGH' 43 | timeout: '30m' 44 | cache-dir: .trivy 45 | - name: Fix .trivy permissions 46 | run: sudo chown -R $(stat . -c %u:%g) .trivy 47 | - name: Upload Trivy scan results to GitHub Security tab 48 | uses: github/codeql-action/upload-sarif@v3 49 | with: 50 | sarif_file: 'trivy-results.sarif' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | __pycache__/ 3 | 4 | apimanager/apimanager/local_settings.py 5 | .idea 6 | API-Manager.iml 7 | apimanager/.DS_Store 8 | venv 9 | .env -------------------------------------------------------------------------------- /CONTRIBUTING.MD: -------------------------------------------------------------------------------- 1 | To get started, sign the Contributor License Agreement. 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10 2 | COPY . /app 3 | COPY .github/local_settings_container.py /app/apimanager/apimanager/local_settings.py 4 | COPY .github/gunicorn.conf.py /app/gunicorn.conf.py 5 | RUN pip install -r /app/requirements.txt 6 | WORKDIR /app 7 | RUN ./apimanager/manage.py migrate 8 | WORKDIR /app/apimanager 9 | EXPOSE 8000 10 | CMD ["gunicorn", "--bind", ":8000", "--config", "../gunicorn.conf.py", "apimanager.wsgi"] -------------------------------------------------------------------------------- /Dockerfile_nginx: -------------------------------------------------------------------------------- 1 | FROM python:3.10 AS builder 2 | COPY . /app 3 | RUN cp /app/.github/local_settings_container.py /app/apimanager/apimanager/local_settings.py 4 | RUN pip install -r /app/requirements.txt 5 | WORKDIR /app 6 | RUN python ./apimanager/manage.py collectstatic --noinput 7 | FROM nginxinc/nginx-unprivileged:stable 8 | COPY nginx.apimanager.conf /etc/nginx/conf.d/apimanager.conf 9 | COPY --from=builder /app/apimanager/static /usr/share/nginx/html 10 | CMD nginx -g "daemon off;" -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Open Bank Project API Manager 2 | Copyright (C) 2011-2025, TESOBE GmbH 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | 17 | Email: contact@tesobe.com 18 | TESOBE GmbH 19 | Osloerstrasse 16/17 20 | Berlin 13359, Germany 21 | 22 | This product includes software developed at 23 | TESOBE (http://www.tesobe.com/) 24 | by 25 | Sebastian Henschel sebastian AT tesobe DOT com 26 | -------------------------------------------------------------------------------- /apimanager.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=API Manager 3 | 4 | [Service] 5 | Type=simple 6 | User=deploy 7 | Group=deploy 8 | SyslogIdentifier=API-Manager 9 | Restart=always 10 | WorkingDirectory=/var/www/apimanager/API-Manager/apimanager 11 | ExecStart=/var/www/apimanager/venv/bin/gunicorn -t 3000 --user deploy --group deploy --config /var/www/apimanager/API-Manager/gunicorn.conf.py apimanager.wsgi 12 | 13 | # set -t to higher value to avoid timeouts with KPI Dashboard / API Metrics etc. 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /apimanager/accountlist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/accountlist/__init__.py -------------------------------------------------------------------------------- /apimanager/accountlist/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/accountlist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountConfig(AppConfig): 5 | name = 'accountlist' 6 | -------------------------------------------------------------------------------- /apimanager/accountlist/forms.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/accountlist/forms.py -------------------------------------------------------------------------------- /apimanager/accountlist/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/accountlist/static/accountlist/css/accountlist.css: -------------------------------------------------------------------------------- 1 | #accounts_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/accountlist/static/accountlist/js/accountlist.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/accountlist/static/accountlist/js/accountlist.js -------------------------------------------------------------------------------- /apimanager/accountlist/templates/accountlist/accountlist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "Account List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "Account List" %}

5 |
6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for account in accounts_list %} 18 | {% url 'account_update' account.id account.bank_id as url_account_update %} 19 | 20 | 21 | 22 | 23 | 24 | 25 | {% endfor %} 26 | 27 | 28 |
{% trans "Account Id" %}{% trans "Bank Id" %}{% trans "Label" %}{% trans "Product Code" %}
{{ account.id }}{{ account.bank_id }}{{ account.label }}{{ account.product_code }}
29 |
30 |
31 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 32 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/accountlist/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/accountlist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Account list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import AccountListView, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | AccountListView.as_view(), 12 | name='account-list'), 13 | re_path(r'^export_csv$', 14 | ExportCsvView.as_view(), 15 | name='export-csv-account') 16 | ] 17 | -------------------------------------------------------------------------------- /apimanager/accountlist/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | # -*- coding: utf-8 -*- 5 | """ 6 | Views of Account List app 7 | """ 8 | import datetime 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.http import HttpResponse 14 | from django.views.generic import FormView,TemplateView, View 15 | from accounts.views import IndexAccountsView 16 | from obp.api import API, APIError 17 | from base.views import get_banks 18 | import csv 19 | 20 | class AccountListView(IndexAccountsView, LoginRequiredMixin, FormView ): 21 | template_name = "accountlist/accountlist.html" 22 | success_url = '/accounts/list' 23 | 24 | def get_accountlist(self, context): 25 | api = API(self.request.session.get('obp')) 26 | try: 27 | self.bankids = get_banks(self.request) 28 | accounts_list = [] 29 | for bank_id in self.bankids: 30 | urlpath = '/management/banks/{}/fast-firehose/accounts'.format(bank_id) 31 | result = api.get(urlpath) 32 | if 'accounts' in result: 33 | accounts_list.extend(result['accounts']) 34 | except APIError as err: 35 | messages.error(self.request, err) 36 | return [] 37 | except Exception as inst: 38 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 39 | return [] 40 | return accounts_list 41 | def get_context_data(self, **kwargs): 42 | context = super(IndexAccountsView, self).get_context_data(**kwargs) 43 | accounts_list = self.get_accountlist(context) 44 | context.update({ 45 | 'accounts_list': accounts_list, 46 | 'bankids': get_banks(self.request) 47 | }) 48 | return context 49 | class ExportCsvView(LoginRequiredMixin, View): 50 | """View to export the user to csv""" 51 | 52 | def get(self, request, *args, **kwargs): 53 | api = API(self.request.session.get('obp')) 54 | try: 55 | self.bankids = get_banks(self.request) 56 | accounts_list = [] 57 | for bank_id in self.bankids: 58 | urlpath = 'banks/{}/accounts'.format(bank_id) 59 | result = api.get(urlpath) 60 | if 'accounts' in result: 61 | accounts_list.extend(result['accounts']) 62 | except APIError as err: 63 | messages.error(self.request, err) 64 | except Exception as inst: 65 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 66 | response = HttpResponse(content_type = 'text/csv') 67 | response['Content-Disposition'] = 'attachment;filename= Account'+ str(datetime.datetime.now())+'.csv' 68 | writer = csv.writer(response) 69 | writer.writerow(["id","label","bank_id","account_type","scheme","address","id", "short_name", "description", "is_public"]) 70 | for user in accounts_list: 71 | writer.writerow([user['id'],user['label'], user['bank_id'], user["account_type"], user["scheme"], user["address"], user["views"]['id'], 72 | user["views"]['short_name'], user["views"]['description'], user["views"]['is_public']]) 73 | return response 74 | 75 | 76 | -------------------------------------------------------------------------------- /apimanager/accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/accounts/__init__.py -------------------------------------------------------------------------------- /apimanager/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /apimanager/accounts/forms.py: -------------------------------------------------------------------------------- 1 | """ 2 | Forms of Accounts app 3 | """ 4 | 5 | from django import forms 6 | from django.utils.translation import gettext_lazy as _ 7 | 8 | import random 9 | 10 | 11 | class CreateAccountForm(forms.Form): 12 | 13 | user_id = forms.CharField( 14 | label=_('User Id'), 15 | widget=forms.TextInput( 16 | attrs={ 17 | 'class': 'form-control', 18 | } 19 | ), 20 | required=True 21 | ) 22 | bank_id = forms.ChoiceField( 23 | label=_('Bank Id'), 24 | widget=forms.Select( 25 | attrs={ 26 | 'class': 'form-control', 27 | } 28 | ), 29 | choices=[], 30 | ) 31 | 32 | label = forms.CharField( 33 | label=_('Label'), 34 | widget=forms.TextInput( 35 | attrs={ 36 | 'placeholder': _('Select The Label'), 37 | 'class': 'form-control', 38 | } 39 | ), 40 | required=False 41 | ) 42 | 43 | product_code = forms.CharField( 44 | label=_('Product Code'), 45 | widget=forms.TextInput( 46 | attrs={ 47 | 'placeholder': "1234BW", 48 | 'class': 'form-control', 49 | } 50 | ), 51 | required=False 52 | ) 53 | 54 | balance_currency = forms.CharField( 55 | label=_('Currency'), 56 | widget=forms.TextInput( 57 | attrs={ 58 | 'placeholder': "EUR", 59 | 'class': 'form-control', 60 | } 61 | ), 62 | required=True, 63 | ) 64 | 65 | balance_amount = forms.FloatField( 66 | label=_('Amount'), 67 | widget=forms.TextInput( 68 | attrs={ 69 | 'placeholder': "0", 70 | 'class': 'form-control', 71 | } 72 | ), 73 | required=False, 74 | ) 75 | 76 | branch_id = forms.CharField( 77 | label=_('Branch Id'), 78 | widget=forms.TextInput( 79 | attrs={ 80 | 'placeholder': 'DERBY6', 81 | 'class': 'form-control', 82 | } 83 | ), 84 | required=False, 85 | ) 86 | 87 | account_routings_scheme = forms.CharField( 88 | label=_('Account Routing Scheme'), 89 | widget=forms.TextInput( 90 | attrs={ 91 | 'placeholder': _('IBAN'), 92 | 'class': 'form-control', 93 | } 94 | ), 95 | required=False, 96 | ) 97 | 98 | account_routings_address = forms.CharField( 99 | label=_('Account Routing Address'), 100 | widget=forms.TextInput( 101 | attrs={ 102 | 'placeholder': _('DE2100100100006820101'), 103 | 'class': 'form-control', 104 | } 105 | ), 106 | required=False, 107 | ) 108 | 109 | 110 | def __init__(self, *args, **kwargs): 111 | kwargs.setdefault('label_suffix', '') 112 | super(CreateAccountForm, self).__init__(*args, **kwargs) 113 | -------------------------------------------------------------------------------- /apimanager/accounts/static/accounts/css/accounts.css: -------------------------------------------------------------------------------- 1 | #accounts div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100%; 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/accounts/static/accounts/js/accounts.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/accounts/static/accounts/js/accounts.js -------------------------------------------------------------------------------- /apimanager/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/accounts/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Account app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import IndexAccountsView 8 | 9 | urlpatterns = [ 10 | re_path(r'^create', 11 | IndexAccountsView.as_view(), 12 | name='accounts-create'), 13 | 14 | ] 15 | -------------------------------------------------------------------------------- /apimanager/accounts/views.py: -------------------------------------------------------------------------------- 1 | 2 | from django.shortcuts import render 3 | 4 | # Create your views here. 5 | # -*- coding: utf-8 -*- 6 | """ 7 | Views of Accounts app 8 | """ 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.views.generic import FormView 14 | from obp.api import API, APIError 15 | from .forms import CreateAccountForm 16 | from django.utils.translation import gettext_lazy as _ 17 | 18 | class IndexAccountsView(LoginRequiredMixin, FormView): 19 | 20 | """Index view for Accounts""" 21 | template_name = "accounts/index.html" 22 | form_class = CreateAccountForm 23 | success_url = reverse_lazy('accounts-create') 24 | 25 | def dispatch(self, request, *args, **kwargs): 26 | self.api = API(request.session.get('obp')) 27 | return super(IndexAccountsView, self).dispatch(request, *args, **kwargs) 28 | 29 | def get_form(self, *args, **kwargs): 30 | form = super(IndexAccountsView, self).get_form(*args, **kwargs) 31 | # Cannot add api in constructor: super complains about unknown kwarg 32 | form.api = self.api 33 | fields = form.fields 34 | try: 35 | fields['bank_id'].choices = self.api.get_bank_id_choices() 36 | except APIError as err: 37 | messages.error(self.request, err) 38 | except Exception as err: 39 | messages.error(self.request, err) 40 | return form 41 | 42 | def form_valid(self, form): 43 | try: 44 | data = form.cleaned_data 45 | #urlpath = '/banks/{}/accounts/{}'.format(data['bank_id'], data['account_id']) 46 | urlpath = '/banks/{}/accounts'.format(data['bank_id']) 47 | payload ={ 48 | "user_id": data["user_id"], 49 | "label": data["label"], 50 | "product_code": data["product_code"], 51 | "branch_id": data["branch_id"], 52 | "balance": { 53 | "currency": data["balance_currency"] if data["balance_currency"] is not None else "EUR", 54 | "amount": data["balance_amount"] if data["balance_amount"] is not None else 0 55 | }, 56 | "account_routings": [{ 57 | "scheme": data["account_routings_scheme"] if data["account_routings_scheme"] !="" else "scheme", 58 | "address": data["account_routings_address"] if data["account_routings_address"]!="" else "address" 59 | }], 60 | } 61 | result = self.api.post(urlpath, payload=payload) 62 | except APIError as err: 63 | messages.error(self.request, "Unknown Error") 64 | return super(IndexAccountsView, self).form_invalid(form) 65 | except Exception as err: 66 | messages.error(self.request, err, "Unknown Error") 67 | return super(IndexAccountsView, self).form_invalid(form) 68 | if 'code' in result and result['code']>=400: 69 | messages.error(self.request, result['message']) 70 | return super(IndexAccountsView, self).form_valid(form) 71 | msg = 'Account has been created successfully!' 72 | messages.success(self.request, msg) 73 | return super(IndexAccountsView, self).form_valid(form) 74 | -------------------------------------------------------------------------------- /apimanager/apicollectionlist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/apicollectionlist/__init__.py -------------------------------------------------------------------------------- /apimanager/apicollectionlist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ApiCollectionListConfig(AppConfig): 5 | name = 'apicollectionlist' 6 | -------------------------------------------------------------------------------- /apimanager/apicollectionlist/forms.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/apicollectionlist/forms.py -------------------------------------------------------------------------------- /apimanager/apicollectionlist/static/apicollectionlist/css/apicollectionlist.css: -------------------------------------------------------------------------------- 1 | #apicollectionlist div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/apicollectionlist/static/apicollectionlist/js/apicollectionlist.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/apicollectionlist/static/apicollectionlist/js/apicollectionlist.js -------------------------------------------------------------------------------- /apimanager/apicollectionlist/templates/apicollectionlist/apicollectionlist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "Customer List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans " All API Collections" %}

5 |
6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for apicollection in apicollections_list %} 18 | 19 | {% url 'my-api-collection-detail' apicollection.api_collection_id as url_collection_detail %} 20 | 21 | 22 | 25 | 26 | 27 | 38 | 39 | 40 | {% endfor %} 41 | 42 |
{% trans "API Collection" %}{% trans "User Name" %}{% trans "API Collection Name" %}{% trans "More info" %}
{% if apicollection.api_collection_id %} 23 | Try It 24 | {% endif %}{{ apicollection.username }}{{ apicollection.api_collection_name }} 28 |
29 |
    30 |
  • {% trans "Is Sharable" %}: 31 |
      32 |
    • {{apicollection.is_sharable}}
    • 33 |
    34 |
  • 35 |
36 |
37 |
{% trans "Detail" %}
43 |
44 |
45 | {% endblock %} 46 | {% block extrajs %} 47 | 48 | {% endblock extrajs %} {% block extracss %} 49 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/apicollectionlist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Api Collection list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import ApiCollectionListView, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | ApiCollectionListView.as_view(), 12 | name='apicollection-list'), 13 | re_path(r'^export_csv$', 14 | ExportCsvView.as_view(), 15 | name='export-csv-apicollection') 16 | ] 17 | -------------------------------------------------------------------------------- /apimanager/apicollections/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/apicollections/__init__.py -------------------------------------------------------------------------------- /apimanager/apicollections/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | class ApiCollectionsConfig(AppConfig): 9 | """Config for apicollections""" 10 | name = 'apicollections' 11 | -------------------------------------------------------------------------------- /apimanager/apicollections/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | 4 | class ApiCollectionsForm(forms.Form): 5 | api_collections_body = forms.CharField( 6 | label='API Collections Body', 7 | widget=forms.Textarea( 8 | attrs={ 9 | 'class': 'form-control', 10 | } 11 | ), 12 | required=False 13 | ) 14 | 15 | class ApiCollectionEndpointsForm(forms.Form): 16 | operation_id = forms.CharField( 17 | label='Operation Id', 18 | widget=forms.TextInput( 19 | attrs={ 20 | 'class': 'form-control', 21 | } 22 | ), 23 | required=True 24 | ) -------------------------------------------------------------------------------- /apimanager/apicollections/static/apicollections/js/apicollections.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('.runner button.forSave').click(function(e) { 3 | e.preventDefault(); 4 | let runner = $(this).parent().parent().parent(); 5 | let api_collection_name = $(runner).find('.api_collection_name').val(); 6 | let api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val(); 7 | let api_collection_description = $(runner).find('.api_collection_description').val(); 8 | $('.runner button.forUpdate').attr("disabled","disabled"); 9 | $('.runner button.forSave').attr("disabled","disabled"); 10 | $('.runner button.forDelete').attr("disabled","disabled"); 11 | $.post('save/apicollection', { 12 | 'api_collection_name': api_collection_name, 13 | 'api_collection_is_sharable': api_collection_is_sharable, 14 | 'api_collection_description': api_collection_description, 15 | }, function (response) { 16 | location.reload(); 17 | }); 18 | }); 19 | $('.runner button.forUpdate').click(function(e) { 20 | e.preventDefault(); 21 | let runner = $(this).parent().parent().parent(); 22 | let api_collection_id = $(runner).find('.api_collection_id').attr("value"); 23 | let api_collection_name = $(runner).find('.api_collection_name').val(); 24 | let api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val(); 25 | let api_collection_description = $(runner).find('.api_collection_description').val(); 26 | $('.runner button.forUpdate').attr("disabled","disabled"); 27 | $('.runner button.forSave').attr("disabled","disabled"); 28 | $('.runner button.forDelete').attr("disabled","disabled"); 29 | $.post('update/apicollection', { 30 | 'api_collection_id': api_collection_id, 31 | 'api_collection_name': api_collection_name, 32 | 'api_collection_is_sharable': api_collection_is_sharable, 33 | 'api_collection_description': api_collection_description, 34 | }, function (response) { 35 | location.reload(); 36 | }); 37 | }); 38 | 39 | $('.runner button.forDelete').click(function(e) { 40 | e.preventDefault(); 41 | let runner = $(this).parent().parent().parent(); 42 | let api_collection_id = $(runner).find('.api_collection_id').attr("value"); 43 | $('.runner button.forUpdate').attr("disabled","disabled"); 44 | $('.runner button.forSave').attr("disabled","disabled"); 45 | $('.runner button.forDelete').attr("disabled","disabled"); 46 | $.post('delete/apicollection', { 47 | 'api_collection_id': api_collection_id 48 | }, function (response) { 49 | location.reload(); 50 | }); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /apimanager/apicollections/templates/apicollections/detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | {% block content %} 4 |
5 |

Add Endpoint to API Collection

6 |
7 | {% csrf_token %} 8 |
9 |
10 |
11 | {{ form.operation_id.label_tag}} 12 | {{ form.operation_id }} 13 |
14 | 15 | 16 |
17 |
18 |
19 | 20 |

Endpoints

21 |
22 | 23 | 24 | 25 | 26 | 27 | {% for api_collection_endpoint in api_collection_endpoints %} 28 | 29 | 30 | 37 | 38 | {% endfor %} 39 | 40 |
Operation Ids
{{ api_collection_endpoint.operation_id }} 31 |
33 | {% csrf_token %} 34 | 35 |
36 |
41 |
42 |
43 | {% endblock %} 44 | -------------------------------------------------------------------------------- /apimanager/apicollections/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from apicollections.views import IndexView, apicollections_save, \ 9 | apicollections_delete, DetailView, DeleteCollectionEndpointView, apicollections_update 10 | 11 | urlpatterns = [ 12 | re_path(r'^$', 13 | IndexView.as_view(), 14 | name='apicollections-index'), 15 | re_path(r'save/apicollection', apicollections_save, 16 | name='apicollection-save'), 17 | re_path(r'update/apicollection', apicollections_update, 18 | name='apicollection-update'), 19 | re_path(r'delete/apicollection', apicollections_delete, 20 | name='apicollection-delete'), 21 | re_path(r'^my-api-collection-ids/(?P[\w\@\.\+-]+)$', 22 | DetailView.as_view(), 23 | name='my-api-collection-detail'), 24 | re_path(r'^delete/api-collections/(?P[\w-]+)/api-collection-endpoint/(?P[\w\@\.\+-]+)$', 25 | DeleteCollectionEndpointView.as_view(), 26 | name='delete-api-collection-endpoint'), 27 | ] 28 | -------------------------------------------------------------------------------- /apimanager/apimanager/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/apimanager/__init__.py -------------------------------------------------------------------------------- /apimanager/apimanager/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for apimanager 4 | """ 5 | 6 | from django.urls import re_path, include 7 | from django.conf.urls.i18n import i18n_patterns 8 | 9 | from base.views import HomeView 10 | from obp.views import ( 11 | OAuthInitiateView, OAuthAuthorizeView, 12 | DirectLoginView, 13 | GatewayLoginView, 14 | LogoutView, 15 | ) 16 | 17 | urlpatterns = [ 18 | #These pages URLs have no GUI 19 | re_path(r'^oauth/initiate$', 20 | OAuthInitiateView.as_view(), name='oauth-initiate'), 21 | re_path(r'^oauth/authorize$', 22 | OAuthAuthorizeView.as_view(), name='oauth-authorize'), 23 | re_path(r'^directlogin$', 24 | DirectLoginView.as_view(), name='directlogin'), 25 | re_path(r'^gatewaylogin$', 26 | GatewayLoginView.as_view(), name='gatewaylogin'), 27 | # Defining authentication URLs here and not including oauth.urls for 28 | # backward compatibility 29 | ] 30 | urlpatterns += i18n_patterns( 31 | #urlpatterns = ( 32 | re_path(r'^$', HomeView.as_view(), name="home"), 33 | re_path(r'^single-sign-on', 34 | OAuthInitiateView.as_view(), name='single-sign-on'), 35 | re_path(r'^logout$', LogoutView.as_view(), name='oauth-logout'), 36 | re_path(r'^systemviews/', include('systemviews.urls')), 37 | re_path(r'^accounts/', include('accounts.urls')), 38 | re_path(r'^account/list', include('accountlist.urls')), 39 | re_path(r'^consumers/', include('consumers.urls')), 40 | re_path(r'^entitlementrequests/', include('entitlementrequests.urls')), 41 | re_path(r'^users/', include('users.urls')), 42 | re_path(r'^branches/', include('branches.urls')), 43 | re_path(r'^atms/', include('atms.urls')), 44 | re_path(r'^atms/list', include('atmlist.urls')), 45 | re_path(r'^banks/', include('banks.urls')), 46 | re_path(r'^banks/list', include('banklist.urls')), 47 | re_path(r'^products/', include('products.urls')), 48 | re_path(r'^products/list', include('productlist.urls')), 49 | re_path(r'^customers/', include('customers.urls')), 50 | re_path(r'^customer/list', include('customerlist.urls')), 51 | re_path(r'^metrics/', include('metrics.urls')), 52 | re_path(r'^config/', include('config.urls')), 53 | re_path(r'^webui/', include('webui.urls')), 54 | re_path(r'^methodrouting/', include('methodrouting.urls')), 55 | re_path(r'^connectormethod/', include('connectormethod.urls')), 56 | re_path(r'^dynamicendpoints/', include('dynamicendpoints.urls')), 57 | re_path(r'^apicollections/', include('apicollections.urls')), 58 | re_path(r'^apicollections-list', include('apicollectionlist.urls')), 59 | ) 60 | #prefix_default_language=False, 61 | #)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -------------------------------------------------------------------------------- /apimanager/apimanager/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for apimanager project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apimanager.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /apimanager/atmlist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/atmlist/__init__.py -------------------------------------------------------------------------------- /apimanager/atmlist/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/atmlist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AtmsConfig(AppConfig): 5 | name = 'atmlist' 6 | -------------------------------------------------------------------------------- /apimanager/atmlist/forms.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/atmlist/forms.py -------------------------------------------------------------------------------- /apimanager/atmlist/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/atmlist/static/atmlist/css/atmlist.css: -------------------------------------------------------------------------------- 1 | #atms_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/atmlist/static/atmlist/js/atmlist.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/atmlist/templates/atmlist/atmlist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "ATM List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "ATM List" %}

5 |
6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for atm in atms_list %} 18 | 19 | {% url 'atms_update' atm.id atm.bank_id as url_atm_update %} 20 | 21 | 22 | 23 | 24 | 36 | 37 | 38 | {% endfor %} 39 | 40 | 41 |
{% trans "ATM Id" %}{% trans "Bank Id" %}{% trans "ATM Name" %}{% trans "More info" %}
{{ atm.id }}{{ atm.bank_id }}{{ atm.name }} 25 |
26 |
    27 |
  • {% trans "Address" %}: 28 |
      29 |
    • line1: {{atm.address.line_1}}
    • 30 |
    31 |
  • 32 | 33 |
34 |
35 |
{% trans "Detail" %}
42 |
43 |
44 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 45 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/atmlist/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/atmlist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for ATM list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import AtmListView, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | AtmListView.as_view(), 12 | name='atm-list'), 13 | re_path(r'^export_csv$', 14 | ExportCsvView.as_view(), 15 | name='export-csv') 16 | ] 17 | -------------------------------------------------------------------------------- /apimanager/atmlist/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | # -*- coding: utf-8 -*- 5 | """ 6 | Views of atms app 7 | """ 8 | import datetime 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.http import HttpResponse 14 | from django.views.generic import FormView,TemplateView, View 15 | from atms.views import IndexAtmsView 16 | from base.views import get_banks 17 | from obp.api import API, APIError 18 | import csv 19 | 20 | 21 | 22 | class AtmListView(IndexAtmsView, LoginRequiredMixin, FormView ): 23 | template_name = "atmlist/atmlist.html" 24 | success_url = '/atms/list' 25 | 26 | def get_atms(self,context): 27 | api = API(self.request.session.get('obp')) 28 | try: 29 | self.bankids = get_banks(self.request) 30 | atms_list = [] 31 | for bank_id in self.bankids: 32 | urlpath = '/banks/{}/atms'.format(bank_id) 33 | result = api.get(urlpath) 34 | #print(result) 35 | if 'atms' in result: 36 | atms_list.extend(result['atms']) 37 | except APIError as err: 38 | messages.error(self.request, err) 39 | return [] 40 | except Exception as inst: 41 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 42 | return [] 43 | 44 | return atms_list 45 | def get_context_data(self, **kwargs): 46 | context = super(IndexAtmsView, self).get_context_data(**kwargs) 47 | atms_list = self.get_atms(context) 48 | context.update({ 49 | 'atms_list': atms_list, 50 | 'bankids': get_banks(self.request) 51 | }) 52 | return context 53 | class ExportCsvView(LoginRequiredMixin, View): 54 | """View to export the user to csv""" 55 | 56 | def get(self, request, *args, **kwargs): 57 | api = API(self.request.session.get('obp')) 58 | try: 59 | self.bankids = get_banks(self.request) 60 | atms_list = [] 61 | for bank_id in self.bankids: 62 | urlpath = '/banks/{}/atms'.format(bank_id) 63 | result = api.get(urlpath) 64 | #print(result) 65 | if 'atms' in result: 66 | atms_list.extend(result['atms']) 67 | except APIError as err: 68 | messages.error(self.request, err) 69 | except Exception as inst: 70 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 71 | response = HttpResponse(content_type = 'text/csv') 72 | response['Content-Disposition'] = 'attachment;filename= Atms'+ str(datetime.datetime.now())+'.csv' 73 | writer = csv.writer(response) 74 | writer.writerow(["id","name","notes","line_1","line_2","line_3","city", "county", "state", "postcode","country_code", "longitude","latitude","more_info"]) 75 | for user in atms_list: 76 | writer.writerow([user['id'],user['name'], user['notes'], user["address"]['line_1'], user["address"]['line_2'], 77 | user["address"]['line_3'], user["address"]['city'], user["address"]['county'], user["address"]['state'], user["address"]['postcode'], user["address"]['country_code'], user["location"]['longitude'], user["location"]['latitude'], user['more_info']]) 78 | return response 79 | 80 | #print(atms_list) 81 | 82 | -------------------------------------------------------------------------------- /apimanager/atms/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/atms/__init__.py -------------------------------------------------------------------------------- /apimanager/atms/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/atms/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AtmsConfig(AppConfig): 5 | name = 'atms' 6 | -------------------------------------------------------------------------------- /apimanager/atms/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/atms/static/atms/css/atms.css: -------------------------------------------------------------------------------- 1 | #atms div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100%; 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/atms/static/atms/js/atms.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/atms/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/atms/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for metrics app 4 | """ 5 | 6 | from django.urls import re_path 7 | from atms.views import IndexAtmsView, UpdateAtmsView, atm_attribute_save, atm_attribute_delete, atm_attribute_update 8 | 9 | urlpatterns = [ 10 | re_path(r'^create', 11 | IndexAtmsView.as_view(), 12 | name='atms_create'), 13 | re_path(r'^update/(?P[ 0-9\w|\W\@\.\+-]+)/bank/(?P[0-9\w\@\.\+-]+)/$', 14 | UpdateAtmsView.as_view(), 15 | name='atms_update'), 16 | re_path(r'save/attribute', atm_attribute_save, 17 | name='atm_attribute_save'), 18 | re_path(r'delete/attribute', atm_attribute_delete, 19 | name='atm_attribute_delete'), 20 | re_path(r'updateattribute/attribute', atm_attribute_update, 21 | name='atm_attribute_update'), 22 | ] 23 | -------------------------------------------------------------------------------- /apimanager/banklist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/banklist/__init__.py -------------------------------------------------------------------------------- /apimanager/banklist/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/banklist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BanksConfig(AppConfig): 5 | name = 'banklist' 6 | -------------------------------------------------------------------------------- /apimanager/banklist/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/banklist/static/banklist/css/banklist.css: -------------------------------------------------------------------------------- 1 | #atms_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/banklist/static/banklist/js/banklist.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/banklist/templates/banklist/banklist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "Bank List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "Bank List" %}

5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% for bank in banks_list %} 15 | 16 | {% url 'banks_update' bank.id as url_bank_update %} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | {% endfor %} 26 | 27 | 28 |
{% trans "Bank Id" %}{% trans "Short Name" %}{% trans "Full Name" %}{% trans "Logo" %}
{{ bank.id }}{{ bank.short_name }}{{ bank.full_name }}{{ bank.logo }}{% trans "Detail" %}
29 |
30 |
31 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 32 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/banklist/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/banklist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Bank list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import BankListView #, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | BankListView.as_view(), 12 | name='bank-list'), 13 | 14 | ] 15 | """ 16 | url(r'^export_csv$', 17 | ExportCsvView.as_view(), 18 | name='export-bank-csv') """ 19 | -------------------------------------------------------------------------------- /apimanager/banklist/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | # -*- coding: utf-8 -*- 5 | """ 6 | Views of Bank List app 7 | """ 8 | import datetime 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.http import HttpResponse 14 | from django.views.generic import FormView,TemplateView, View 15 | from banks.views import IndexBanksView 16 | from obp.api import API, APIError 17 | 18 | 19 | class BankListView(IndexBanksView, LoginRequiredMixin, FormView ): 20 | template_name = "banklist/banklist.html" 21 | success_url = '/banks/list' 22 | 23 | def get_banks(self,context): 24 | api = API(self.request.session.get('obp')) 25 | try: 26 | urlpath = '/banks' 27 | result = api.get(urlpath) 28 | banks_list = [] 29 | if 'banks' in result: 30 | banks_list.extend(result["banks"]) 31 | except APIError as err: 32 | messages.error(self.request, err) 33 | return [] 34 | except Exception as inst: 35 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 36 | return [] 37 | 38 | return banks_list 39 | def get_context_data(self, **kwargs): 40 | context = super(BankListView, self).get_context_data(**kwargs) 41 | banks_list = self.get_banks(context) 42 | context.update({ 43 | 'banks_list': banks_list 44 | }) 45 | return context 46 | -------------------------------------------------------------------------------- /apimanager/banks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/banks/__init__.py -------------------------------------------------------------------------------- /apimanager/banks/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/banks/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BanksConfig(AppConfig): 5 | name = 'banks' 6 | -------------------------------------------------------------------------------- /apimanager/banks/forms.py: -------------------------------------------------------------------------------- 1 | """ 2 | Forms of Banks app 3 | """ 4 | 5 | from django import forms 6 | from django.utils.translation import gettext_lazy as _ 7 | 8 | import random 9 | 10 | 11 | class CreateBankForm(forms.Form): 12 | 13 | ATTRIBUTE_TYPE = ( 14 | ('', _('Any')), 15 | ('STRING', 'STRING'), 16 | ('INTEGER', 'INTEGER'), 17 | ('DOUBLE', 'DOUBLE'), 18 | ('DATE_WITH_DAY', 'DATE_WITH_DAY'), 19 | ) 20 | bank_id = forms.CharField( 21 | label=_('Bank Id'), 22 | widget=forms.TextInput( 23 | attrs={ 24 | 'placeholder': 'bank-id-{}'.format(random.randint(1,1000)), 25 | 'class': 'form-control', 26 | } 27 | ), 28 | initial='bank-id-{}'.format(random.randint(1,1000)), 29 | ) 30 | 31 | bank_code = forms.CharField( 32 | label=_('Bank Code'), 33 | widget=forms.TextInput( 34 | attrs={ 35 | 'placeholder': _('CGHZ'), 36 | 'class': 'form-control', 37 | } 38 | ), 39 | required=False 40 | ) 41 | 42 | full_name = forms.CharField( 43 | label=_('Full Name'), 44 | widget=forms.TextInput( 45 | attrs={ 46 | 'placeholder': "full name string", 47 | 'class': 'form-control', 48 | } 49 | ), 50 | required=False 51 | ) 52 | 53 | logo = forms.CharField( 54 | label=_('Logo URL'), 55 | widget=forms.TextInput( 56 | attrs={ 57 | 'placeholder': "logo url", 58 | 'class': 'form-control', 59 | } 60 | ), 61 | required=False, 62 | ) 63 | 64 | website = forms.CharField( 65 | label=_('Website'), 66 | widget=forms.TextInput( 67 | attrs={ 68 | 'placeholder': "www.openbankproject.com", 69 | 'class': 'form-control', 70 | } 71 | ), 72 | required=False, 73 | ) 74 | 75 | bank_routings_scheme = forms.CharField( 76 | label=_('Bank Routing Scheme'), 77 | widget=forms.TextInput( 78 | attrs={ 79 | 'placeholder': 'Scheme Value', 80 | 'class': 'form-control', 81 | } 82 | ), 83 | required=False, 84 | ) 85 | 86 | bank_routings_address = forms.CharField( 87 | label=_('Bank Routing Address'), 88 | widget=forms.TextInput( 89 | attrs={ 90 | 'placeholder': 'Bank Routing Address', 91 | 'class': 'form-control', 92 | } 93 | ), 94 | required=False, 95 | ) 96 | 97 | type_attribute = forms.ChoiceField( 98 | label=_('Type'), 99 | choices=ATTRIBUTE_TYPE, 100 | widget=forms.Select( 101 | attrs={ 102 | 'class': 'form-control bank_attribute_type', 103 | } 104 | ), 105 | required=False, 106 | ) 107 | 108 | def __init__(self, *args, **kwargs): 109 | kwargs.setdefault('label_suffix', '') 110 | super(CreateBankForm, self).__init__(*args, **kwargs) 111 | -------------------------------------------------------------------------------- /apimanager/banks/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/banks/static/banks/css/banks.css: -------------------------------------------------------------------------------- 1 | #banks div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100%; 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/banks/static/banks/js/banks.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/banks/static/banks/js/banks.js -------------------------------------------------------------------------------- /apimanager/banks/templates/banks/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} {% block page_title %}{{ block.super }} / Banks{% endblock page_title %} {% block content %} 2 |
3 |

{% trans "Bank Create" %}

4 | 5 |
6 | {% csrf_token %} {% if form.non_field_errors %} 7 |
{{ form.non_field_errors }}
8 | {% endif %} 9 |
10 |
11 | {% if form.bank_id.errors %} 12 |
{{ form.bank_id.errors }}
13 | {% endif %} 14 |
15 | {{ form.bank_id.label_tag }} {{ form.bank_id }} 16 |
17 |
18 |
19 | {% if form.bank_code.errors %} 20 |
{{ form.bank_code.errors }}
21 | {% endif %} 22 |
{{ form.bank_code.label_tag }} {{ form.bank_code }}
23 |
24 |
25 | {% if form.full_name.errors %} 26 |
{{ form.full_name.errors }}
27 | {% endif %} 28 |
29 | {{ form.full_name.label_tag }} {{ form.full_name }} 30 |
31 |
32 |
33 |
34 | 35 |
36 | {% if form.logo.errors %} 37 |
38 | {{ form.logo.errors }} 39 |
40 | {% endif %} 41 |
42 | {{ form.logo.label_tag }} {{ form.logo }} 43 |
44 |
45 |
46 | {% if form.website.errors %} 47 |
48 | {{ form.website.errors }} 49 |
50 | {% endif %} 51 |
52 | {{ form.website.label_tag }} {{ form.website }} 53 |
54 |
55 |
56 | {% if form.bank_routings_scheme.errors %} 57 |
58 | {{ form.bank_routings_scheme.errors }} 59 |
60 | {% endif %} 61 |
62 | {{ form.bank_routings_scheme.label_tag }} {{ form.bank_routings_scheme }} 63 |
64 |
65 |
66 |
67 | 68 |
69 | {% if form.bank_routings_address.errors %} 70 |
{{ form.bank_routings_address.errors }}
71 | {% endif %} 72 |
73 | {{ form.bank_routings_address.label_tag }} {{ form.bank_routings_address }} 74 |
75 |
76 |
77 | 78 |
79 |
80 | {% if form.address.errors %} 81 |
{{ form.address.errors }}
82 | {% endif %} 83 |
84 | {{ form.address.label_tag }} {{ form.address }} 85 |
86 |
87 |
88 |
89 | 96 |
97 |
98 |
99 | 100 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 101 | {% endblock extracss %} 102 | -------------------------------------------------------------------------------- /apimanager/banks/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/banks/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Bank app 4 | """ 5 | 6 | from django.urls import re_path 7 | from banks.views import IndexBanksView, UpdateBanksView, bank_attribute_save, bank_attribute_update, bank_attribute_delete 8 | 9 | urlpatterns = [ 10 | re_path(r'^create', 11 | IndexBanksView.as_view(), 12 | name='banks_create'), 13 | re_path(r'^update/bank/(?P[0-9\w\@\.\+-]+)/$', 14 | UpdateBanksView.as_view(), 15 | name='banks_update'), 16 | re_path(r'save/attribute', bank_attribute_save, 17 | name='bank_attribute_save'), 18 | re_path(r'updateattribute/attribute', bank_attribute_update, 19 | name='bank_attribute_update'), 20 | re_path(r'delete/attribute', bank_attribute_delete, 21 | name='bank_attribute_delete'), 22 | ] -------------------------------------------------------------------------------- /apimanager/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/__init__.py -------------------------------------------------------------------------------- /apimanager/base/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for base app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class BaseConfig(AppConfig): 10 | """Config for base""" 11 | name = 'base' 12 | -------------------------------------------------------------------------------- /apimanager/base/filters.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Base filters 4 | """ 5 | 6 | from datetime import datetime, timedelta 7 | 8 | from django.conf import settings 9 | 10 | 11 | class BaseFilter(object): 12 | """Base for custom filter classes""" 13 | filter_type = None 14 | 15 | def __init__(self, context, request_get): 16 | self.context = context 17 | self.request_get = request_get 18 | 19 | def _apply(self, data, filter_value): 20 | """ 21 | Actual application of filter 22 | Needs to be implemented by child class! 23 | """ 24 | raise AttributeError('Not implemented yet!') 25 | 26 | def apply(self, data): 27 | """ 28 | Apply filter to given data 29 | Also setup of context variables for templates 30 | """ 31 | filter_all = 'active_{}_all'.format(self.filter_type) 32 | self.context[filter_all] = True 33 | filter_active_value = 'active_{}'.format(self.filter_type) 34 | self.context[filter_active_value] = 'All' 35 | 36 | if self.filter_type not in self.request_get: 37 | return data 38 | 39 | filter_value = self.request_get[self.filter_type] 40 | if not filter_value or filter_value == 'All': 41 | return data 42 | 43 | self.context[filter_all] = False 44 | self.context[filter_active_value] = filter_value 45 | filter_active = 'active_{}_{}'.format(self.filter_type, filter_value) 46 | self.context[filter_active] = True 47 | return self._apply(data, filter_value) 48 | 49 | 50 | class FilterTime(BaseFilter): 51 | """Filter items by datetime""" 52 | filter_type = 'time' 53 | 54 | def __init__(self, context, request_get, time_fieldname): 55 | super().__init__(context, request_get) 56 | self.time_fieldname = time_fieldname 57 | 58 | def _apply(self, data, filter_value): 59 | if filter_value == 'minute': 60 | delta = timedelta(minutes=1) 61 | elif filter_value == 'hour': 62 | delta = timedelta(hours=1) 63 | elif filter_value == 'day': 64 | delta = timedelta(days=1) 65 | elif filter_value == 'week': 66 | delta = timedelta(days=7) 67 | elif filter_value == 'month': 68 | delta = timedelta(days=30) 69 | elif filter_value == 'year': 70 | delta = timedelta(days=365) 71 | else: 72 | return data 73 | 74 | now = datetime.utcnow() 75 | filtered = [] 76 | print("FILTERED") 77 | print(filtered) 78 | for item in data: 79 | item_date = datetime.strptime( 80 | item[self.time_fieldname], settings.API_DATE_FORMAT_WITH_SECONDS ) 81 | if now - item_date <= delta: 82 | filtered.append(item) 83 | return filtered 84 | -------------------------------------------------------------------------------- /apimanager/base/static/css/obpjsoneditor.css: -------------------------------------------------------------------------------- 1 | #config pre { 2 | overflow: auto; 3 | word-wrap: normal; 4 | white-space: pre; 5 | } 6 | #config .string { color: green; } 7 | #config .number { color: darkorange; } 8 | #config .boolean { color: blue; } 9 | #config .null { color: magenta; } 10 | #config .key { color: red; } 11 | 12 | /* custom bold styling for non-default JSON schema values */ 13 | .jsoneditor-is-not-default { 14 | font-weight: bold; 15 | } 16 | 17 | .jsoneditor_div{ 18 | display: none; 19 | height: 400px; 20 | } -------------------------------------------------------------------------------- /apimanager/base/static/css/override.css: -------------------------------------------------------------------------------- 1 | /*/* This is an example only. Please put any override.css to seperate server. 2 | Override Log on/out button */ 3 | 4 | 5 | /*.navbar-btn .btn-default {*/ 6 | /* font-family: UniversNextforDolphin-Regular;*/ 7 | /* font-size: 16px;*/ 8 | /* color: #FFFFFF;*/ 9 | /* text-align: center;*/ 10 | /* line-height: 24px;*/ 11 | /* background: #DB0011;*/ 12 | /* border-radius: 0;*/ 13 | /* border: 0;*/ 14 | /*}*/ 15 | /*.navbar-btn .btn-default:hover {*/ 16 | /* background: #AF000D;*/ 17 | /*}*/ 18 | /*.navbar-btn .btn-default:active {*/ 19 | /* background: #83000A;*/ 20 | /*}*/ 21 | 22 | /*.navbar-default {*/ 23 | /* background-color: #333333;*/ 24 | /* border: none;*/ 25 | /*}*/ 26 | /*.btn-primary {*/ 27 | /* background-color: #F3F3F3;*/ 28 | /* border: 1px solid #333333;*/ 29 | /* border-radius: 0;*/ 30 | /* outline: 0;*/ 31 | /* color: #000;*/ 32 | /*}*/ -------------------------------------------------------------------------------- /apimanager/base/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /apimanager/base/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /apimanager/base/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /apimanager/base/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /apimanager/base/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/img/favicon.ico -------------------------------------------------------------------------------- /apimanager/base/static/img/tablesorter/asc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/img/tablesorter/asc.gif -------------------------------------------------------------------------------- /apimanager/base/static/img/tablesorter/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/img/tablesorter/bg.gif -------------------------------------------------------------------------------- /apimanager/base/static/img/tablesorter/desc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/base/static/img/tablesorter/desc.gif -------------------------------------------------------------------------------- /apimanager/base/static/js/base.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | // Select a language from navbar which want to change. 3 | var currentURL = window.location.href; 4 | const element = document.getElementById('gb') 5 | element.addEventListener("click", () => { 6 | if (currentURL.includes("/es/")) { 7 | location.href = currentURL.split("/es/")[0] + "/en/" + currentURL.split("/es/")[1] 8 | } 9 | }); 10 | const element1 = document.getElementById('es') 11 | element1.addEventListener("click", () => { 12 | if (currentURL.includes("/en/")) { 13 | location.href = currentURL.split("/en/")[0] + "/es/" + currentURL.split("/en/")[1] 14 | } 15 | }); 16 | $('table.tablesorter').tablesorter(); 17 | $('#authentication-select').change(function() { 18 | $('.authentication-method').hide(); 19 | let method = $(this).val(); 20 | $(`#authenticate-${method}`).show(); 21 | }); 22 | }); 23 | 24 | // Redirect to API-Explorer, just click on Try Ii button in API-Collection and Dynamic Endpoint after success response. 25 | function redirect_api_explorer_url(api_explorer_url) { 26 | var currentURL = window.location.href.split("/"); 27 | if (currentURL[3] == "en") { 28 | location.href = api_explorer_url + "&locale=en_GB"; 29 | } 30 | else { 31 | location.href = api_explorer_url + "&locale=es_ES"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /apimanager/base/static/js/inactivity-timer.js: -------------------------------------------------------------------------------- 1 | function addSeconds(date, seconds) { 2 | let oldDate = date; 3 | let addSeconds = seconds; 4 | var newSeconds = oldDate + addSeconds; 5 | //console.log(addSeconds); 6 | date.setSeconds(date.getSeconds() + seconds); 7 | return date; 8 | } 9 | 10 | export function showCountdownTimer() { 11 | //TODO rather than display a timer the whole time in a span, make it only show when there are e.g. 30 seconds left. 12 | // Maybe a whole page alert that the user will be logged out soon. 13 | 14 | // Get current date and time 15 | var now = new Date().getTime(); 16 | let distance = countDownDate - now; 17 | // Output the result in an element with id="countdown-timer-span" 18 | let elementId = ("countdown-timer-span"); 19 | document.getElementById(elementId).innerHTML = Math.floor(distance / 1000) + "s"; 20 | 21 | // If the count down is over release resources 22 | if (distance < 0) { 23 | destroyCountdownTimer(); 24 | } 25 | } 26 | 27 | 28 | // Set the date we're counting down to 29 | let countDownDate = addSeconds(new Date(), 5); 30 | 31 | let showTimerInterval = null; 32 | 33 | export function destroyCountdownTimer() { 34 | clearInterval(showTimerInterval); 35 | } 36 | 37 | export function resetCountdownTimer(seconds) { 38 | destroyCountdownTimer(); // Destroy previous timer if any 39 | countDownDate = addSeconds(new Date(), seconds); // Set the date we're counting down to 40 | showTimerInterval = setInterval(showCountdownTimer, 1000); // Update the count down every 1 second 41 | } -------------------------------------------------------------------------------- /apimanager/base/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | {% block content %} 4 |
5 |

{% trans "Welcome to API Manager" %}

6 |
7 | {% if not user.is_authenticated %} 8 |

9 | {% trans "API Manager allows you to manage some aspects of the OBP instance at " %} {{ API_HOST }}. {% trans "You have to " %} {% trans "login" %} {% trans "or" %} {% trans "register" %} {% trans "an account before being able to proceed" %}.{% trans "Your access is limited by the Entitlements you have." %} 10 |

11 | {% else %} 12 |

13 | {% trans "API Manager allows you to manage some aspects of the OBP instance at " %} {{ API_HOST }}. 14 |

15 | {% endif %} 16 |
17 | {% if not user.is_authenticated %} 18 |
19 | 20 |
21 |
22 | 32 |
33 | 34 |
35 | 38 |
39 |
40 | {% csrf_token %} 41 |
42 | 43 | {{ directlogin_form.username }} 44 |
45 |
46 | 47 | {{ directlogin_form.password }} 48 |
49 | 50 |
51 |
52 |
53 |
54 | {% csrf_token %} 55 |
56 | 57 | {{ gatewaylogin_form.username }} 58 |
59 |
60 | 61 | {{ gatewaylogin_form.secret }} 62 |
63 | 64 |
65 | 66 |
67 |
68 |
69 |
70 | {% endif %} 71 | 72 |
73 | {% endblock %} 74 | -------------------------------------------------------------------------------- /apimanager/base/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Base utilities 4 | """ 5 | from django.contrib.humanize.templatetags.humanize import naturaltime 6 | from datetime import datetime, timedelta 7 | from apimanager.settings import API_DATE_FORMAT_WITH_MILLISECONDS, API_DATE_FORMAT_WITH_DAY, \ 8 | API_DATE_FORMAT_WITH_DAY_DATE_TIME 9 | from base import context_processors 10 | from django.contrib import messages 11 | import functools 12 | from obp.api import APIError, LOGGER 13 | from django.http import JsonResponse 14 | import traceback 15 | 16 | def json_serial(obj): 17 | """JSON serializer for objects not serializable by default json code""" 18 | 19 | if isinstance(obj, datetime): 20 | serial = naturaltime(obj) 21 | return serial 22 | raise TypeError('Type not serializable') 23 | 24 | def get_cache_key_for_current_call(request, urlpath): 25 | """we will generate the cache key by login username+urlpath 26 | url path may contain lots of special characters, here we use the hash method first. 27 | """ 28 | return context_processors.api_username(request).get('API_USERNAME') + str(hash(urlpath)) 29 | 30 | 31 | def error_once_only(request, err): 32 | """ 33 | Just add the error once 34 | :param request: 35 | :param err: 36 | :return: 37 | """ 38 | LOGGER.exception('error_once_only - Error Message: {}'.format(err)) 39 | storage = messages.get_messages(request) 40 | if str(err) not in [str(m.message) for m in storage]: 41 | messages.error(request, err) 42 | 43 | def exception_handle(fn): 44 | @functools.wraps(fn) 45 | def wrapper(request, *args, **kwargs): 46 | try: 47 | result = fn(request, *args, **kwargs) 48 | if isinstance(result,dict) and 'code' in result and result['code'] >= 400: 49 | error_once_only(request, result['message']) 50 | else: 51 | msg = 'Submitted!' 52 | messages.success(request, msg) 53 | except APIError as err: 54 | error_once_only(request, APIError(Exception("OBP-API server is not running or do not response properly. " 55 | "Please check OBP-API server. Details: " + str(err)))) 56 | except Exception as err: 57 | error_once_only(request, "Unknown Error. Details: " + str(err)) 58 | return JsonResponse({'state': True}) 59 | return wrapper 60 | 61 | def convert_form_date_to_obpapi_datetime_format(form_to_date_string): 62 | """ 63 | convert the String 2020-10-22 to 2020-10-22T00:00:00.000000Z 64 | """ 65 | return datetime.strptime(form_to_date_string, API_DATE_FORMAT_WITH_DAY_DATE_TIME).strftime(API_DATE_FORMAT_WITH_MILLISECONDS) 66 | 67 | def return_to_days_ago(date, days): 68 | """ 69 | eg: 70 | date 2020-10-22T00:00:00.000000Z 71 | days =1 72 | return 2020-10-21T00:00:00.000000Z 73 | """ 74 | return (datetime.strptime(date, API_DATE_FORMAT_WITH_MILLISECONDS) - timedelta(days)).strftime(API_DATE_FORMAT_WITH_MILLISECONDS) -------------------------------------------------------------------------------- /apimanager/base/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Views for base app 4 | """ 5 | from django.contrib import messages 6 | from django.conf import settings 7 | from django.views.generic import TemplateView, View 8 | from django.shortcuts import render 9 | from obp.forms import DirectLoginForm, GatewayLoginForm 10 | from obp.api import API, APIError 11 | 12 | def get_banks(request): 13 | api = API(request.session.get('obp')) 14 | try: 15 | urlpath = '/banks' 16 | result = api.get(urlpath) 17 | if 'banks' in result: 18 | return [bank['id'] for bank in sorted(result['banks'], key=lambda d: d['id'])] 19 | else: 20 | return [] 21 | except APIError as err: 22 | messages.error(request, err) 23 | return [] 24 | 25 | def get_api_versions(request): 26 | api = API(request.session.get('obp')) 27 | try: 28 | urlpath = '/api/versions' 29 | result = api.get(urlpath) 30 | if 'scanned_api_versions' in result: 31 | return [apiversion['API_VERSION'] for apiversion in sorted(result['scanned_api_versions'], key=lambda d: d['API_VERSION'])] 32 | else: 33 | return [] 34 | except APIError as err: 35 | messages.error(request, err) 36 | return [] 37 | 38 | class HomeView(TemplateView): 39 | """View for home page""" 40 | template_name = "home.html" 41 | 42 | def get_context_data(self, **kwargs): 43 | context = super(HomeView, self).get_context_data(**kwargs) 44 | context.update({ 45 | 'API_HOST': settings.API_HOST, 46 | 'logo_url': settings.LOGO_URL, 47 | 'override_css_url': settings.OVERRIDE_CSS_URL, 48 | 'directlogin_form': DirectLoginForm(), 49 | 'ALLOW_DIRECT_LOGIN':settings.ALLOW_DIRECT_LOGIN, 50 | 'gatewaylogin_form': GatewayLoginForm(), 51 | 'ALLOW_GATEWAY_LOGIN': settings.ALLOW_GATEWAY_LOGIN, 52 | 'SHOW_API_TESTER':settings.SHOW_API_TESTER, 53 | 'API_TESTER_URL':settings.API_TESTER_URL 54 | }) 55 | return context 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /apimanager/branches/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/branches/__init__.py -------------------------------------------------------------------------------- /apimanager/branches/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/branches/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BranchesConfig(AppConfig): 5 | name = 'branches' 6 | -------------------------------------------------------------------------------- /apimanager/branches/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/branches/static/branches/css/branches.css: -------------------------------------------------------------------------------- 1 | #branches_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/branches/static/branches/js/branches.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/branches/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/branches/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for metrics app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexBranchesView, UpdateBranchesView 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexBranchesView.as_view(), 13 | name='branches_list'), 14 | re_path(r'^update/(?P[0-9\w\@\.\+-]+)/bank/(?P[0-9\w\@\.\+-]+)/$', 15 | UpdateBranchesView.as_view(), 16 | name='branches_update') 17 | ] 18 | -------------------------------------------------------------------------------- /apimanager/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/config/__init__.py -------------------------------------------------------------------------------- /apimanager/config/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class ConfigConfig(AppConfig): 10 | """Config for config""" 11 | name = 'config' 12 | -------------------------------------------------------------------------------- /apimanager/config/static/config/css/config.css: -------------------------------------------------------------------------------- 1 | #config pre { 2 | overflow: auto; 3 | word-wrap: normal; 4 | white-space: pre; 5 | } 6 | #config .string { color: green; } 7 | #config .number { color: darkorange; } 8 | #config .boolean { color: blue; } 9 | #config .null { color: magenta; } 10 | #config .key { color: red; } 11 | -------------------------------------------------------------------------------- /apimanager/config/static/config/js/config.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | function syntaxHighlight(json) { 3 | if (typeof json != 'string') { 4 | json = JSON.stringify(json, undefined, 2); 5 | } 6 | json = json.replace(/&/g, '&').replace(//g, '>'); 7 | return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { 8 | let cls = 'number'; 9 | if (/^"/.test(match)) { 10 | if (/:$/.test(match)) { 11 | cls = 'key'; 12 | } else { 13 | cls = 'string'; 14 | } 15 | } else if (/true|false/.test(match)) { 16 | cls = 'boolean'; 17 | } else if (/null/.test(match)) { 18 | cls = 'null'; 19 | } 20 | return '' + match + ''; 21 | }); 22 | } 23 | 24 | $('#config-json').html((syntaxHighlight(ConfigJson))); 25 | }); 26 | -------------------------------------------------------------------------------- /apimanager/config/templates/config/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static i18n %} 3 | 4 | {% block page_title %}{{ block.super }} / Users{% endblock page_title %} 5 | 6 | {% block content %} 7 |
8 |

{% trans "Config" %}

9 | 10 |

{% trans "The configuration of the API" %}

11 | 12 |
13 | 	
14 |
15 | {% endblock %} 16 | 17 | {% block extrajs %} 18 | 19 | 22 | {% endblock extrajs %} 23 | 24 | 25 | {% block extracss %} 26 | 27 | {% endblock extracss %} 28 | -------------------------------------------------------------------------------- /apimanager/config/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexView 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='config-index'), 14 | ] 15 | -------------------------------------------------------------------------------- /apimanager/config/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Views of config app 4 | """ 5 | 6 | import json 7 | 8 | from django.contrib import messages 9 | from django.contrib.auth.mixins import LoginRequiredMixin 10 | from django.views.generic import TemplateView 11 | 12 | from obp.api import API, APIError 13 | 14 | 15 | class IndexView(LoginRequiredMixin, TemplateView): 16 | """Index view for config""" 17 | template_name = "config/index.html" 18 | 19 | def get_context_data(self, **kwargs): 20 | context = super(IndexView, self).get_context_data(**kwargs) 21 | api = API(self.request.session.get('obp')) 22 | try: 23 | urlpath = '/config' 24 | config = api.get(urlpath) 25 | except APIError as err: 26 | messages.error(self.request, err) 27 | config = {} 28 | except Exception as err: 29 | messages.error(self.request, err) 30 | config = {} 31 | 32 | context.update({ 33 | 'config_json': json.dumps(config, indent=4), 34 | }) 35 | return context 36 | -------------------------------------------------------------------------------- /apimanager/connectormethod/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/connectormethod/__init__.py -------------------------------------------------------------------------------- /apimanager/connectormethod/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | class ApiCollectionsConfig(AppConfig): 9 | """Config for connectormethod""" 10 | name = 'connectormethod' 11 | -------------------------------------------------------------------------------- /apimanager/connectormethod/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | 4 | class ConnectorMethodForm(forms.Form): 5 | connector_method_body = forms.CharField( 6 | label='Connector Method Body', 7 | widget=forms.Textarea( 8 | attrs={ 9 | 'class': 'form-control', 10 | } 11 | ), 12 | required=False 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /apimanager/connectormethod/static/connectormethod/js/connectormethod.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('.runner button.forSave').click(function(e) { 3 | e.preventDefault(); 4 | let runner = $(this).parent().parent().parent(); 5 | let connector_method_name = $(runner).find('.connector_method_name').val(); 6 | let connector_method_programming_lang = $(runner).find('.connector_method_programming_lang').val(); 7 | let connector_method_body = $(runner).find('.connector_method_body').val(); 8 | 9 | $('.runner button.forSave').attr("disabled", "disabled"); 10 | $('.runner button.forDelete').attr("disabled", "disabled"); 11 | $.post('save/connectormethod', { 12 | 'connector_method_name': connector_method_name, 13 | 'connector_method_programming_lang': connector_method_programming_lang, 14 | 'connector_method_body': connector_method_body, 15 | }, function(response) { 16 | location.reload(); 17 | }); 18 | }); 19 | 20 | $('.runner button.forUpdate').click(function(e) { 21 | e.preventDefault(); 22 | let runner = $(this).parent().parent().parent(); 23 | let connector_method_id = $(runner).find('.connector_method_id').html(); 24 | let connector_method_programming_lang_update = $(runner).find('.connector_method_programming_lang_update').val(); 25 | let connector_method_body_update = $(runner).find('.connector_method_body_update').val(); 26 | 27 | $('.runner button.forSave').attr("disabled", "disabled"); 28 | $('.runner button.forUpdate').attr("disabled", "disabled"); 29 | $.post('update/connectormethod', { 30 | 'connector_method_id': connector_method_id, 31 | 'connector_method_programming_lang_update': connector_method_programming_lang_update, 32 | 'connector_method_body_update': connector_method_body_update, 33 | }, function(response) { 34 | location.reload(); 35 | }); 36 | }); 37 | }); -------------------------------------------------------------------------------- /apimanager/connectormethod/templates/connectormethod/detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static i18n %} 3 | {% block page_title %}{{ block.super }} / Connector Methods{% endblock page_title %} 4 | 5 | {% block content %} 6 |

{% trans "Connector Methods" %}

7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | {% csrf_token %} 17 | {% for connectormethod in connectormethods %} 18 | {% url 'connector_detail' connectormethod.connector_method_id as url_connector_detail %} 19 |
20 |
21 | {% if connectormethod.connector_method_id %} 22 |
23 |
24 |
{{ connectormethod.programming_lang }}
25 |
26 |
27 |
28 |
{{connectormethod.method_body}}
29 |
30 | {% endif %} 31 | {% if forloop.counter0 > 0 %} 32 |
33 |
34 | 35 |
36 |
37 | {% endif %} 38 |
39 |
40 | {% endfor %} 41 |
42 | {% endblock %} 43 | {% block extrajs %} 44 | 45 | {% endblock extrajs %} 46 | -------------------------------------------------------------------------------- /apimanager/connectormethod/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from connectormethod.views import IndexView, connectormethod_save, connectormethod_update 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='connectormethod'), 14 | re_path(r'save/connectormethod', connectormethod_save, 15 | name='connectormethod-save'), 16 | re_path(r'^update/connectormethod', connectormethod_update, 17 | name='connectormethod-update') 18 | ] 19 | -------------------------------------------------------------------------------- /apimanager/connectormethod/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Views of config app 4 | """ 5 | 6 | import json 7 | from django.contrib import messages 8 | from django.contrib.auth.mixins import LoginRequiredMixin 9 | from django.http import HttpResponseRedirect, HttpResponse 10 | from django.views.generic import FormView 11 | from obp.api import API, APIError 12 | from django.urls import reverse, reverse_lazy 13 | from base.utils import exception_handle, error_once_only 14 | from .forms import ConnectorMethodForm 15 | from django.views.decorators.csrf import csrf_exempt 16 | 17 | 18 | class IndexView(LoginRequiredMixin, FormView): 19 | """Index view for config""" 20 | template_name = r"connectormethod/index.html" 21 | form_class = ConnectorMethodForm 22 | success_url = reverse_lazy('connectormethod-index') 23 | 24 | def get_context_data(self, **kwargs): 25 | context = super(IndexView, self).get_context_data(**kwargs) 26 | api = API(self.request.session.get('obp')) 27 | urlpath = '/management/connector-methods' 28 | connectormethod =[] 29 | try: 30 | response = api.get(urlpath) 31 | if 'code' in response and response['code'] >= 400: 32 | error_once_only(self.request, response['message']) 33 | else: 34 | connectormethod=response['connector_methods'] 35 | except APIError as err: 36 | messages.error(self.request, err) 37 | except Exception as err: 38 | error_once_only(self.request, err) 39 | else: 40 | default_connector_method_endpoint = { 41 | "connector_method_name": "Method Name", 42 | "programming_lang": "Scala", 43 | "Method Body":"Enter Your Method Body" 44 | } 45 | connectormethod.insert(0,json.dumps(default_connector_method_endpoint)) 46 | 47 | context.update({ 48 | 'connectormethods': connectormethod 49 | }) 50 | return context 51 | 52 | @exception_handle 53 | @csrf_exempt 54 | def connectormethod_save(request): 55 | api = API(request.session.get('obp')) 56 | urlpath = '/management/connector-methods' 57 | payload = { 58 | 'method_name': request.POST.get('connector_method_name').strip(), 59 | 'programming_lang': request.POST.get('connector_method_programming_lang'), 60 | 'method_body': request.POST.get('connector_method_body').strip() 61 | } 62 | result = api.post(urlpath, payload = payload) 63 | return result 64 | 65 | 66 | @exception_handle 67 | @csrf_exempt 68 | def connectormethod_update(request): 69 | connector_method_id = request.POST.get('connector_method_id').strip() 70 | urlpath = '/management/connector-methods/{}'.format(connector_method_id) 71 | api = API(request.session.get('obp')) 72 | payload = { 73 | 'programming_lang': request.POST.get('connector_method_programming_lang_update'), 74 | 'method_body': request.POST.get('connector_method_body_update').strip() 75 | } 76 | result = api.put(urlpath, payload=payload) 77 | return result 78 | -------------------------------------------------------------------------------- /apimanager/consumers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/consumers/__init__.py -------------------------------------------------------------------------------- /apimanager/consumers/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for consumers app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class AppsConfig(AppConfig): 10 | """Config for consumers""" 11 | name = 'consumers' 12 | -------------------------------------------------------------------------------- /apimanager/consumers/forms.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Forms of consumers app 4 | """ 5 | 6 | from django import forms 7 | 8 | class ApiConsumersForm(forms.Form): 9 | 10 | consumer_id = forms.CharField( 11 | widget=forms.HiddenInput(), 12 | required=True, 13 | ) 14 | 15 | per_minute_call_limit = forms.IntegerField( 16 | label='per_minute_call_limit', 17 | widget=forms.NumberInput( 18 | attrs={ 19 | 'class': 'form-control', 20 | } 21 | ), 22 | initial=-1, 23 | required=False, 24 | ) 25 | 26 | per_hour_call_limit = forms.IntegerField( 27 | label='per_hour_call_limit', 28 | widget=forms.NumberInput( 29 | attrs={ 30 | 'class': 'form-control', 31 | } 32 | ), 33 | initial=-1, 34 | required=False, 35 | ) 36 | per_day_call_limit = forms.IntegerField( 37 | label='per_day_call_limit', 38 | widget=forms.NumberInput( 39 | attrs={ 40 | 'class': 'form-control', 41 | } 42 | ), 43 | initial=-1, 44 | required=False, 45 | ) 46 | per_week_call_limit = forms.IntegerField( 47 | label='per_week_call_limit', 48 | widget=forms.NumberInput( 49 | attrs={ 50 | 'class': 'form-control', 51 | } 52 | ), 53 | initial=-1, 54 | required=False, 55 | ) 56 | 57 | per_month_call_limit = forms.IntegerField( 58 | label='per_month_call_limit', 59 | widget=forms.NumberInput( 60 | attrs={ 61 | 'class': 'form-control', 62 | } 63 | ), 64 | initial=-1, 65 | required=False, 66 | ) 67 | -------------------------------------------------------------------------------- /apimanager/consumers/static/consumers/css/consumers.css: -------------------------------------------------------------------------------- 1 | .consumers #consumer-list { 2 | margin-top: 20px; 3 | } 4 | 5 | #consumers .btn-group-vertical.filter-enabled, 6 | #consumers .btn-group-vertical.filter-apptype { 7 | margin-top: 10px; 8 | } 9 | 10 | #consumers-detail div { 11 | margin: 5px 0; 12 | } 13 | 14 | #consumers .filter a { 15 | font-size: 12px; 16 | } 17 | 18 | #consumers .actions .btn { 19 | margin-bottom: 2px; 20 | } 21 | -------------------------------------------------------------------------------- /apimanager/consumers/static/consumers/js/consumers.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | }); 3 | -------------------------------------------------------------------------------- /apimanager/consumers/templates/consumers/includes/filter_apptype.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% trans "Web" %} 3 | {% trans "Mobile" %} 4 | {% trans "All" %} 5 | -------------------------------------------------------------------------------- /apimanager/consumers/templates/consumers/includes/filter_enabled.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% trans "Enabled" %} 3 | {% trans "Disabled" %} 4 | {% trans "All" %} 5 | -------------------------------------------------------------------------------- /apimanager/consumers/templates/consumers/includes/filter_pagination.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 10 |
11 | 12 |
-------------------------------------------------------------------------------- /apimanager/consumers/templates/consumers/includes/filter_time.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% trans "Last Hour" %} 3 | {% trans "Last Day" %} 4 | {% trans "Last Week" %} 5 | {% trans "Last Month" %} 6 | {% trans "Last Year" %} 7 | {% trans "All" %} 8 | -------------------------------------------------------------------------------- /apimanager/consumers/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for consumers app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexView, DetailView, EnableView, DisableView 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='consumers-index'), 14 | re_path(r'^(?P[0-9a-z\-]+)$', 15 | DetailView.as_view(), 16 | name='consumers-detail'), 17 | re_path(r'^(?P[0-9a-z\-]+)/enable$', 18 | EnableView.as_view(), 19 | name='consumers-enable'), 20 | re_path(r'^(?P[0-9a-z\-]+)/disable$', 21 | DisableView.as_view(), 22 | name='consumers-disable'), 23 | ] 24 | -------------------------------------------------------------------------------- /apimanager/customerlist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/customerlist/__init__.py -------------------------------------------------------------------------------- /apimanager/customerlist/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/customerlist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CustomersConfig(AppConfig): 5 | name = 'customerlist' 6 | -------------------------------------------------------------------------------- /apimanager/customerlist/forms.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/customerlist/forms.py -------------------------------------------------------------------------------- /apimanager/customerlist/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/customerlist/static/customerlist/css/customerlist.css: -------------------------------------------------------------------------------- 1 | #customers_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/customerlist/static/customerlist/js/customerlist.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/customerlist/templates/customerlist/customerlist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "Customer List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "Customer List" %}

5 |
6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {% for customer in customers_list %} 19 | 20 | 21 | 22 | 23 | 24 | 35 | 36 | {% endfor %} 37 | 38 |
{% trans "Customer Id" %}{% trans "Bank Id" %}{% trans "Legal Name" %}{% trans "More info" %}
{{ customer.customer_id }}{{ customer.bank_id }}{{ customer.legal_name }} 25 |
26 |
    27 |
  • {% trans "Other Info" %}: 28 |
      29 |
    • line1: {{customer.email}}
    • 30 |
    31 |
  • 32 |
33 |
34 |
39 |
40 |
41 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 42 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/customerlist/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/customerlist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for customer list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import CustomerListView, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | CustomerListView.as_view(), 12 | name='customer-list'), 13 | re_path(r'^export_csv$', 14 | ExportCsvView.as_view(), 15 | name='export-csv-customer') 16 | ] 17 | -------------------------------------------------------------------------------- /apimanager/customerlist/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | # -*- coding: utf-8 -*- 5 | """ 6 | Views of customer list app 7 | """ 8 | import datetime 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.http import HttpResponse 14 | from django.views.generic import FormView,TemplateView, View 15 | from customers.views import CreateView 16 | from obp.api import API, APIError 17 | from base.views import get_banks 18 | import csv 19 | 20 | class CustomerListView(CreateView, LoginRequiredMixin, FormView ): 21 | template_name = "customerlist/customerlist.html" 22 | success_url = '/customers/list' 23 | 24 | def get_customers(self, context): 25 | api = API(self.request.session.get('obp')) 26 | try: 27 | self.bankids = get_banks(self.request) 28 | customers_list = [] 29 | urlpath = '/customers' 30 | result = api.get(urlpath) 31 | if 'customers' in result: 32 | customers_list.extend(result['customers']) 33 | except APIError as err: 34 | messages.error(self.request, err) 35 | return [] 36 | except Exception as inst: 37 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 38 | return [] 39 | 40 | return customers_list 41 | def get_context_data(self, **kwargs): 42 | context = super(CreateView, self).get_context_data(**kwargs) 43 | customers_list = self.get_customers(context) 44 | context.update({ 45 | 'customers_list': customers_list, 46 | 'bankids': get_banks(self.request) 47 | }) 48 | return context 49 | class ExportCsvView(LoginRequiredMixin, View): 50 | """View to export the user to csv""" 51 | 52 | def get(self, request, *args, **kwargs): 53 | api = API(self.request.session.get('obp')) 54 | try: 55 | self.bankids = get_banks(self.request) 56 | customers_list = [] 57 | for bank_id in self.bankids: 58 | urlpath = '/banks/{}/customers'.format(bank_id) 59 | result = api.get(urlpath) 60 | if 'customers' in result: 61 | customers_list.extend(result['customers']) 62 | except APIError as err: 63 | messages.error(self.request, err) 64 | except Exception as inst: 65 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 66 | response = HttpResponse(content_type = 'text/csv') 67 | response['Content-Disposition'] = 'attachment;filename= Customers'+ str(datetime.datetime.now())+'.csv' 68 | writer = csv.writer(response) 69 | writer.writerow(["bank_id","customer_id","customer_number","legal_name","mobile_phone_number","email","face_image", "url", "date", "date_of_birth","relationship_status", "dependants","dob_of_dependants","employment_status"]) 70 | for user in customers_list: 71 | writer.writerow([user['bank_id'],user['customer_id'], user['customer_number'], user["legal_name"], 72 | user["mobile_phone_number"], user["email"], user["face_image"]['url'], user["face_image"]['date'], user["date_of_birth"], user['relationship_status'], user["dependants"], user["dob_of_dependants"], user['employment_status']]) 73 | return response 74 | 75 | 76 | -------------------------------------------------------------------------------- /apimanager/customers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/customers/__init__.py -------------------------------------------------------------------------------- /apimanager/customers/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CustomersConfig(AppConfig): 5 | name = 'customers' 6 | -------------------------------------------------------------------------------- /apimanager/customers/static/customers/css/customers.css: -------------------------------------------------------------------------------- 1 | #customers { 2 | margin-bottom: 10px; 3 | } 4 | 5 | input#id_kyc_status { 6 | width: auto; 7 | margin: -4px 0; 8 | } 9 | 10 | .displaynone { 11 | display:none; 12 | } -------------------------------------------------------------------------------- /apimanager/customers/static/customers/js/customers.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | }); 3 | -------------------------------------------------------------------------------- /apimanager/customers/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for customers app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import CreateView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | CreateView.as_view(), 12 | name='customers-create'), 13 | ] 14 | -------------------------------------------------------------------------------- /apimanager/customers/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Views of customers app 4 | """ 5 | 6 | import datetime 7 | 8 | from django.conf import settings 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | from django.urls import reverse_lazy 12 | from django.views.generic import FormView 13 | 14 | from obp.api import API, APIError 15 | 16 | from .forms import CreateCustomerForm 17 | 18 | 19 | class CreateView(LoginRequiredMixin, FormView): 20 | """View to create a customer""" 21 | form_class = CreateCustomerForm 22 | template_name = 'customers/create.html' 23 | success_url = reverse_lazy('customers-create') 24 | 25 | def dispatch(self, request, *args, **kwargs): 26 | self.api = API(request.session.get('obp')) 27 | return super(CreateView, self).dispatch(request, *args, **kwargs) 28 | 29 | def get_form(self, *args, **kwargs): 30 | form = super(CreateView, self).get_form(*args, **kwargs) 31 | # Cannot add api in constructor: super complains about unknown kwarg 32 | form.api = self.api 33 | fields = form.fields 34 | try: 35 | fields['bank_id'].choices = self.api.get_bank_id_choices() 36 | except APIError as err: 37 | messages.error(self.request, err) 38 | except Exception as err: 39 | messages.error(self.request, err) 40 | fields['last_ok_date'].initial =\ 41 | datetime.datetime.now().strftime(settings.API_DATE_FORMAT_WITH_SECONDS ) 42 | return form 43 | 44 | def form_valid(self, form): 45 | date_of_birth_date = form.cleaned_data['date_of_birth_date'] 46 | date_of_birth_time = form.cleaned_data['date_of_birth_time'] 47 | final_date_of_birth = str(date_of_birth_date) + "T" + str(date_of_birth_time) + "Z" 48 | form.cleaned_data['date_of_birth'] = final_date_of_birth 49 | data = form.cleaned_data 50 | urlpath = '/banks/{}/customers'.format(data['bank_id']) 51 | payload = { 52 | 'user_id': data['user_id'], 53 | 'customer_number': data['customer_number'], 54 | 'legal_name': data['legal_name'], 55 | 'mobile_phone_number': data['mobile_phone_number'], 56 | 'email': data['email'], 57 | 'face_image': { 58 | 'url': data['face_image_url'], 59 | 'date': data['face_image_date'], 60 | }, 61 | 'date_of_birth': final_date_of_birth, 62 | 'relationship_status': data['relationship_status'], 63 | 'dependants': data['dependants'], 64 | 'dob_of_dependants': data['dob_of_dependants'], 65 | 'credit_rating': { 66 | 'rating': data['credit_rating_rating'], 67 | 'source': data['credit_rating_source'], 68 | }, 69 | 'credit_limit': { 70 | 'currency': data['credit_limit_currency'], 71 | 'amount': data['credit_limit_amount'], 72 | }, 73 | 'highest_education_attained': 74 | data['highest_education_attained'], 75 | 'employment_status': data['employment_status'], 76 | 'kyc_status': data['kyc_status'], 77 | 'last_ok_date': 78 | data['last_ok_date'].strftime(settings.API_DATE_FORMAT_WITH_SECONDS ), 79 | } 80 | try: 81 | result = self.api.post(urlpath, payload=payload) 82 | except APIError as err: 83 | messages.error(self.request, err) 84 | return super(CreateView, self).form_invalid(form) 85 | except Exception as err: 86 | messages.error(self.request, err) 87 | return super(CreateView, self).form_invalid(form) 88 | msg = 'Customer number {} for user_id {} has been created successfully!' .format( # noqa 89 | data['customer_number'], data['user_id']) 90 | messages.success(self.request, msg) 91 | return super(CreateView, self).form_valid(form) 92 | -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/dynamicendpoints/__init__.py -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | class DynamicEndpointsConfig(AppConfig): 9 | """Config for dynamicendpoints""" 10 | name = 'dynamicendpoints' 11 | -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | 4 | class DynamicEndpointsForm(forms.Form): 5 | dynamic_endpoints_body = forms.CharField( 6 | label='Dynamic Endpoints Body', 7 | widget=forms.Textarea( 8 | attrs={ 9 | 'class': 'form-control', 10 | } 11 | ), 12 | required=False 13 | ) -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/static/dynamicendpoints/js/dynamicendpoints.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | const schema = {}; 3 | const options = { 4 | mode: 'code', 5 | modes: ['code', 'text', 'tree', 'preview'] 6 | }; 7 | 8 | //each dynamic_endpoint will have each own json_editor, and will put data into it when click `parameter` box 9 | //and will use the data from click `save` button. 10 | let json_editors = [] 11 | $('.parameters').click(function() { 12 | let runner = $(this).parent().parent().parent(); 13 | let json_editor_id= $(runner).find('.jsoneditor_div')[0].id; 14 | let json_editor_number = json_editor_id.replace("jsoneditor",""); 15 | let container = $("#"+json_editor_id); 16 | let parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text()); 17 | let jsoneditor_div = $(runner).find('.jsoneditor_div'); 18 | //make sure only create one jsoneditor_div block 19 | if(!(jsoneditor_div.css("display") ==="block")){ 20 | json_editors[json_editor_number] = new JSONEditor(container[0], options, parameters); 21 | $(runner).find('textarea[name="parameters"]').prop( "disabled", true ); 22 | jsoneditor_div.css("display","block"); 23 | }else{ 24 | json_editors[json_editor_number] = json_editors[json_editor_number].set(parameters) 25 | $(runner).find('textarea[name="parameters"]').prop( "disabled", true ); 26 | } 27 | }); 28 | 29 | $('.runner button.forSave').click(function() { 30 | let runner = $(this).parent().parent().parent(); 31 | let jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id 32 | let json_editor_number = jsoneditor_id.replace("jsoneditor","") 33 | let parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get()); 34 | console.log("parameters_Json_editor:"+parameters_Json_editor) 35 | $('.runner button.forSave').attr("disabled","disabled"); 36 | $('.runner button.forDelete').attr("disabled","disabled"); 37 | $.post('dynamicendpoints/save/dynamicendpoint', { 38 | 'parameters_Json_editor': parameters_Json_editor, 39 | }, function (response) { 40 | location.reload(); 41 | }); 42 | runner.find('jsoneditor_div').css("display","none"); 43 | return false; 44 | }); 45 | 46 | $('.runner button.forDelete').click(function() { 47 | e.preventDefault(); 48 | let runner = $(this).parent().parent().parent(); 49 | let dynamic_endpoint_id = $(runner).find('.dynamic_endpoint_id').attr("value"); 50 | $('.runner button.forSave').attr("disabled","disabled"); 51 | $('.runner button.forDelete').attr("disabled","disabled"); 52 | $.post('dynamicendpoints/delete/dynamicendpoint', { 53 | 'dynamic_endpoint_id': dynamic_endpoint_id 54 | }, function (response) { 55 | location.reload(); 56 | }); 57 | return false; 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/templates/dynamicendpoints/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | {% load i18n %} 4 | {% block page_title %}{{ block.super }} / Dynamic Endpoints{% endblock page_title %} 5 | 6 | {% block content %} 7 |

{% trans "Dynamic Endpoints" %}

8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | {% csrf_token %} 18 | {% for dynamic_endpoint in dynamic_endpoints %} 19 |
20 |
21 |
22 |
23 | 24 | {% if dynamic_endpoint.dynamicendpoint_on_api_explorer_url %} 25 | Try It 26 | {% else %} 27 | {{dynamic_endpoint.dynamic_endpoint_id}} 28 | {% endif %} 29 |
30 |
31 |
32 | 34 |
35 | {% if forloop.counter0 == 0 %} 36 |
37 |
38 | {% trans "saved." %} 39 |
40 |
41 | {% endif %} 42 | {% if forloop.counter0 > 0 %} 43 |
44 |
45 | 46 |
47 |
48 | {% endif %} 49 |
50 | 51 |
52 |
53 |
54 | {% endfor %} 55 |
56 | {% endblock %} 57 | 58 | 59 | {% block extrajs %} 60 | 61 | 62 | 63 | {% endblock extrajs %} -------------------------------------------------------------------------------- /apimanager/dynamicendpoints/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from dynamicendpoints.views import IndexView, dynamicendpoints_save,dynamicendpoints_delete 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='dynamicendpoints-index'), 14 | re_path(r'save/dynamicendpoint', dynamicendpoints_save, 15 | name='dynamicendpoint-save'), 16 | re_path(r'delete/dynamicendpoint', dynamicendpoints_delete, 17 | name='dynamicendpoint-delete') 18 | ] 19 | -------------------------------------------------------------------------------- /apimanager/entitlementrequests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/entitlementrequests/__init__.py -------------------------------------------------------------------------------- /apimanager/entitlementrequests/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for consumers app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class AppsConfig(AppConfig): 10 | """Config for entitlement requests""" 11 | name = 'entitlementrequests' 12 | -------------------------------------------------------------------------------- /apimanager/entitlementrequests/static/entitlementrequests/css/entitlementrequests.css: -------------------------------------------------------------------------------- 1 | .table-responsive { 2 | margin-top: 20px; 3 | } 4 | 5 | #entitlementrequests .filter a { 6 | font-size: 12px; 7 | } 8 | -------------------------------------------------------------------------------- /apimanager/entitlementrequests/static/entitlementrequests/js/entitlementrequests.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | }); -------------------------------------------------------------------------------- /apimanager/entitlementrequests/templates/entitlementrequests/includes/filter_time.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% trans "Last Hour" %} 3 | {% trans "Last Day" %} 4 | {% trans "Last Week" %} 5 | {% trans "Last Month" %} 6 | {% trans "Last Year" %} 7 | {% trans "All" %} 8 | -------------------------------------------------------------------------------- /apimanager/entitlementrequests/templates/entitlementrequests/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load humanize static %} 3 | {% load i18n %} 4 | {% block page_title %}{{ block.super }} / Entitlement Requests {% endblock page_title %} 5 | 6 | {% block content %} 7 |
8 |

{% trans "Entitlement Requests" %}

9 | 10 |
11 |
12 |
13 | 16 |
17 | {% include "entitlementrequests/includes/filter_time.html" %} 18 |
19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {% for entitlementrequest in entitlementrequests %} 37 | {% url 'users-detail' entitlementrequest.user.user_id as url_users_detail %} 38 | 39 | 40 | 41 | 42 | 43 | 50 | 59 | 60 | {% endfor %} 61 | 62 | 63 |
{% trans "Role Name" %}{% trans "User name" %}{% trans "Bank ID" %}{% trans "Created" %}{% trans "Action" %}{% trans "Action" %}
{{ entitlementrequest.role_name }}{{ entitlementrequest.user.username }}{{ entitlementrequest.bank_id }}{{ entitlementrequest.created|naturaltime }} 44 |
45 | {% csrf_token %} 46 | 47 | 48 |
49 |
51 |
52 | {% csrf_token %} 53 | 54 | 55 | 56 | 57 |
58 |
64 |
65 | 66 | 67 |
68 | {% endblock content %} 69 | 70 | 71 | 72 | {% block extrajs %} 73 | {% comment %} 74 | 75 | 77 | {% endcomment %} 78 | 79 | {% endblock extrajs %} 80 | 81 | 82 | {% block extracss %} 83 | 84 | {% endblock extracss %} 85 | -------------------------------------------------------------------------------- /apimanager/entitlementrequests/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for entitlement requests app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexView, RejectEntitlementRequest, AcceptEntitlementRequest 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='entitlementrequests-index'), 14 | re_path(r'^entitlement-requests/entitlement_request_id/(?P[\w\@\.\+-]+)$', 15 | RejectEntitlementRequest.as_view(), 16 | name='entitlement-request-delete'), 17 | re_path(r'^entitlement-requests/user_id/(?P[\w\@\.\+-]+)$', 18 | AcceptEntitlementRequest.as_view(), 19 | name='entitlement-request-accept'), 20 | ] 21 | -------------------------------------------------------------------------------- /apimanager/locale/all/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/all/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/locale/all/LC_MESSAGES/django.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2022-05-10 09:52+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: base/templates/base.html:48 21 | msgid "Home" 22 | msgstr "" 23 | 24 | #: base/templates/base.html:50 25 | msgid "Consumers" 26 | msgstr "" 27 | 28 | #: base/templates/base.html:52 29 | msgid "Entitlement Requests" 30 | msgstr "" 31 | 32 | #: base/templates/base.html:57 33 | msgid "Users" 34 | msgstr "" 35 | 36 | #: base/templates/base.html:59 37 | msgid "All" 38 | msgstr "" 39 | 40 | #: base/templates/base.html:68 41 | msgid "Metrics" 42 | msgstr "" 43 | 44 | #: base/templates/base.html:79 45 | msgid "Resources" 46 | msgstr "" 47 | 48 | #: base/templates/base.html:92 49 | msgid "Configurations" 50 | msgstr "" 51 | 52 | #: base/templates/home.html:5 53 | msgid "Welcome to API Manager" 54 | msgstr "" 55 | -------------------------------------------------------------------------------- /apimanager/locale/de/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/de/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/locale/deepl_translation_function.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | import dotenv 4 | 5 | BASE_DIR = os.getcwd() #method tells us the location of current working directory 6 | 7 | # Add .env variables anywhere before SECRET_KEY 8 | dotenv_file = os.path.join(BASE_DIR, ".env") 9 | if os.path.isfile(f"{BASE_DIR}/.env"): 10 | dotenv.load_dotenv(dotenv_file) 11 | # Update secret key 12 | deepl_auth_key = os.environ['deepl_auth_key'] # Instead of your actual Auth Key 13 | 14 | headers = { 15 | 'Content-Type': 'application/x-www-form-urlencoded', 16 | } 17 | def translator(text, language) : 18 | try: 19 | a= text.strip().encode('utf-8') 20 | data = f'auth_key={auth_key}&text={a}&target_lang={language}' 21 | 22 | response = requests.post('https://api.deepl.com/v2/translate', headers=headers, data=data) 23 | #print( response.json()["translations"]["text"]) 24 | 25 | return " ".join(response.json()["translations"][0]["text"].split(" ")[1:]) 26 | except Exception as e : 27 | print(e) 28 | return text -------------------------------------------------------------------------------- /apimanager/locale/es/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/es/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/locale/fi/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/fi/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/locale/fi/LC_MESSAGES/django.po: -------------------------------------------------------------------------------- 1 | # Open Bank Project API Manager i18n files. 2 | # Copyright (C) 2022 TESOBE GmbH 3 | # This file is distributed under the AGPL. Commercial licences are available from TESOBE. 4 | # FIRST AUTHOR , 2022. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2022-05-09 09:00+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | 21 | #: apimanager/settings.py:175 22 | msgid "English" 23 | msgstr "" 24 | 25 | #: apimanager/settings.py:176 26 | msgid "French" 27 | msgstr "" 28 | 29 | #: base/templates/home.html:4 30 | msgid "Hello" 31 | msgstr "" 32 | 33 | #: base/templates/home.html:7 base/views.py:39 34 | msgid "Consumers" 35 | msgstr "consommatrice" 36 | -------------------------------------------------------------------------------- /apimanager/locale/fr/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/fr/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/locale/fr/LC_MESSAGES/django.po: -------------------------------------------------------------------------------- 1 | # Open Bank Project API Manager i18n files. 2 | # Copyright (C) 2022 TESOBE GmbH 3 | # This file is distributed under the AGPL. Commercial licences are available from TESOBE. 4 | # FIRST AUTHOR , 2022. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2022-05-10 08:11+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 20 | 21 | #: base/templates/base.html:50 22 | msgid "Consumers" 23 | msgstr "consommatrice" 24 | 25 | #: base/templates/home.html:5 26 | msgid "Welcome to API Manager" 27 | msgstr "Bienvenue dans le gestionnaire d'API" 28 | -------------------------------------------------------------------------------- /apimanager/locale/generatePo.py: -------------------------------------------------------------------------------- 1 | from deepl_translation_function import translator # Convert one language to another 2 | from concurrent.futures import ThreadPoolExecutor as tpe # Multithreading 3 | from threading import Lock # Locking Purpose 4 | 5 | lock=Lock() # Intializing Lock 6 | languages=['de','es','fr','hi'] # Defining languages 7 | 8 | 9 | # This class is used for converting languages 10 | class languageConverting(): 11 | def parametersTextConverte(self, stString, prevlangToNewlang): 12 | """ 13 | This function translates one language into another language. It takes two 14 | parameters 15 | 1. prevStrToNewString :=> String that you want to convert 16 | 2. prevlangToNewlang :=> Languages(fr,hi,es etc) 17 | """ 18 | self.prevStrToNewString = prevStrToNewString 19 | self.prevlangToNewlang = prevlangToNewlang 20 | translator = translator(text=self.prevStrToNewString, language=self.prevlangToNewlang) 21 | 22 | return (str(translator)) 23 | # This is method for writing file 24 | 25 | def localeWriteFile(language): 26 | fileName=f'locale/{language}/LC_MESSAGES/django.po' # Openning a file 27 | try: 28 | with open(fileName,encoding='utf-8') as f: # Reading from the file 29 | a=[i.replace("\n","") for i in f.readlines()] # Reading everyline from a file and store it into a 30 | except Exception as e: # same like try block. 31 | b=0 32 | for i in range(len(a)): 33 | if 'msgid' in a[i] and a[i]!='msgid ""': 34 | b=i 35 | break 36 | 37 | if b!=0: 38 | trans=languageConverting() # Creating object for translation class 39 | for i in range(b-1,len(a)): 40 | try: 41 | if "msgid" in a[i]: 42 | msgid,msgstr=a[i],a[i+1] 43 | if msgstr == 'msgstr ""': 44 | ms=msgid[7:len(msgid)-1] 45 | val=trans.parametersTextConverte(ms,language) 46 | a[i+1]=f'msgstr "{val}"' 47 | except: pass 48 | try: 49 | lock.acquire() 50 | with open(fileName,'w',encoding='utf-8') as f: 51 | for i in a: 52 | f.write(f"{i}\n") 53 | lock.release() 54 | except Exception as e: 55 | lock.release() 56 | else: 57 | 58 | with tpe() as e: 59 | e.map(localeWriteFile,languages) 60 | -------------------------------------------------------------------------------- /apimanager/locale/hi/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/locale/hi/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /apimanager/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apimanager.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django # noqa 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /apimanager/methodrouting/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/methodrouting/__init__.py -------------------------------------------------------------------------------- /apimanager/methodrouting/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class MethodRoutingConfig(AppConfig): 10 | """Config for methodrouting""" 11 | name = 'methodrouting' 12 | -------------------------------------------------------------------------------- /apimanager/methodrouting/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | 4 | class MethodRoutingForm(forms.Form): 5 | method_routing_body = forms.CharField( 6 | label='Method Routing Body', 7 | widget=forms.Textarea( 8 | attrs={ 9 | 'class': 'form-control', 10 | } 11 | ), 12 | required=False 13 | ) -------------------------------------------------------------------------------- /apimanager/methodrouting/static/methodrouting/js/methodrouting.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | const schema = {}; 3 | const options = { 4 | mode: 'code', 5 | modes: ['code', 'text', 'tree', 'preview'] 6 | }; 7 | 8 | //each method_routing will have each own json_editor, and will put data into it when click `parameter` box 9 | //and will use the data from click `save` button. 10 | let json_editors = [] 11 | $('.parameters').click(function() { 12 | let runner = $(this).parent().parent().parent(); 13 | let json_editor_id= $(runner).find('.jsoneditor_div')[0].id; 14 | let json_editor_number = json_editor_id.replace("jsoneditor",""); 15 | let container = $("#"+json_editor_id); 16 | let parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text()); 17 | let jsoneditor_div = $(runner).find('.jsoneditor_div'); 18 | //make sure only create one jsoneditor_div block, click once to open and then close the block. 19 | if (typeof json_editors[json_editor_number] === 'undefined') { 20 | json_editors[json_editor_number] = new JSONEditor(container[0], options, parameters); 21 | jsoneditor_div.css("display","block"); 22 | }else{ 23 | // json_editors[json_editor_number] = json_editors[json_editor_number].set(parameters) 24 | if(jsoneditor_div.css("display") ==="block"){ 25 | jsoneditor_div.css("display","none"); 26 | }else{ 27 | jsoneditor_div.css("display","block"); 28 | } 29 | } 30 | }); 31 | 32 | $('.runner button.forSave').click(function() { 33 | let runner = $(this).parent().parent().parent(); 34 | let method_routing_id = $(runner).find('.method_routing_id').text(); 35 | let method_name = $(runner).find('.method_name').text(); 36 | let connector_name = $(runner).find('.connector_name').val(); 37 | let bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val(); 38 | let is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val(); 39 | let parameters = $(runner).find('textarea[name="parameters"]').val(); 40 | let jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id; 41 | let json_editor_number = jsoneditor_id.replace("jsoneditor",""); 42 | //if the user do not click the `parameters` box, then there is no json_editors here,so we use the parameters directly. 43 | if (typeof json_editors[json_editor_number] === 'undefined') { 44 | parameters_Json_editor = parameters; 45 | } else { 46 | parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get()); 47 | } 48 | $('.runner button.forSave').attr("disabled","disabled"); 49 | $('.runner button.forDelete').attr("disabled","disabled"); 50 | $.post('methodrouting/save/method', { 51 | 'method_routing_id': method_routing_id, 52 | 'method_name': method_name, 53 | 'connector_name': connector_name, 54 | 'bank_id_pattern': bank_id_pattern, 55 | 'is_bank_id_exact_match': is_bank_id_exact_match, 56 | 'parameters_Json_editor': parameters_Json_editor, 57 | }, function (response) { 58 | location.reload(); 59 | }); 60 | runner.find('jsoneditor_div').css("display","none"); 61 | return false; 62 | }); 63 | 64 | $('.runner button.forDelete').click(function() { 65 | let runner = $(this).parent().parent().parent(); 66 | let method_routing_id = $(runner).find('.method_routing_id').text(); 67 | $('.runner button.forSave').attr("disabled","disabled"); 68 | $('.runner button.forDelete').attr("disabled","disabled"); 69 | $.post('methodrouting/delete/method', { 70 | 'method_routing_id': method_routing_id 71 | }, function (response) { 72 | location.reload(); 73 | }); 74 | return false; 75 | }); 76 | }); 77 | -------------------------------------------------------------------------------- /apimanager/methodrouting/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from methodrouting.views import IndexView, methodrouting_save, methodrouting_delete 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='methodrouting-index'), 14 | re_path(r'save/method', methodrouting_save, 15 | name='methodrouting-save'), 16 | re_path(r'delete/method', methodrouting_delete, 17 | name='methodrouting-delete'), 18 | ] 19 | -------------------------------------------------------------------------------- /apimanager/metrics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/metrics/__init__.py -------------------------------------------------------------------------------- /apimanager/metrics/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for metrics app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class MetricsConfig(AppConfig): 10 | """Config for metrics""" 11 | name = 'metrics' 12 | -------------------------------------------------------------------------------- /apimanager/metrics/static/metrics/css/metrics.css: -------------------------------------------------------------------------------- 1 | #metrics form { 2 | margin-bottom: 10px; 3 | } 4 | 5 | #metrics #metrics-data { 6 | margin-top: 40px; 7 | } 8 | 9 | #metrics #metrics-list ul { 10 | margin-left: -25px; 11 | } 12 | 13 | .hiddenRow { 14 | padding: 0 !important; 15 | } -------------------------------------------------------------------------------- /apimanager/metrics/static/metrics/js/include_system_calls.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/metrics/static/metrics/js/include_system_calls.js -------------------------------------------------------------------------------- /apimanager/metrics/static/metrics/js/lastEndpointMetric.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | getMetricLastEndpoint(); 3 | }); 4 | 5 | function getMetricLastEndpoint(){ 6 | $.ajax({url: "/metrics/api/last-endpoint", success: function(result){ 7 | var content = "" 8 | +result['implemented_by_partial_function']+" took " 9 | +result['duration']+" ms at " 10 | +result['date']+" " 11 | +result['verb']+" " 12 | + result['url']; 13 | $("#last_endpoint").text(content); 14 | setTimeout(function(){getMetricLastEndpoint();}, 5000); // will call function to update time every 5 seconds 15 | }}); 16 | } 17 | -------------------------------------------------------------------------------- /apimanager/metrics/static/metrics/js/metrics.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | const BarchartData = $.parseJSON($('#barchart_data_div').attr("value")); 3 | let barChart = new Chart($("#barchart"), { 4 | type: 'horizontalBar', 5 | data: { 6 | labels: BarchartData['labels'], 7 | datasets: [{ 8 | label: 'Count', 9 | data: BarchartData['data'], 10 | backgroundColor: BarchartData['backgroundColor'], 11 | borderColor: BarchartData['borderColor'], 12 | borderWidth: 1 13 | }] 14 | }, 15 | options: { 16 | scales: { 17 | xAxes: [{ 18 | ticks: { 19 | beginAtZero: true 20 | } 21 | }] 22 | }, 23 | legend: { 24 | display: false 25 | } 26 | } 27 | }); 28 | 29 | }); 30 | -------------------------------------------------------------------------------- /apimanager/metrics/static/metrics/js/spinner.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | $('.spinner').on('click', function() { 3 | var e=this; 4 | setTimeout(function() { 5 | e.innerHTML=' Loading...'; 6 | e.disabled=true; 7 | },0); 8 | return true; 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /apimanager/metrics/templates/metrics/api_summary_partial_function.html: -------------------------------------------------------------------------------- 1 | {% extends 'metrics/api.html' %} 2 | {% load static %} 3 | {% load i18n %} 4 | 5 | {% block nav_tabs %} 6 | 10 | {% endblock nav_tabs %} 11 | 12 | {% block tab_content %} 13 |
14 | 15 |
16 | 17 | {% endblock tab_content %} 18 | 19 | {% block extrajs %} 20 | 21 | 22 | {% endblock extrajs %} 23 | -------------------------------------------------------------------------------- /apimanager/metrics/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for metrics app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import ( 9 | APIMetricsView, 10 | APISummaryPartialFunctionView, 11 | ConnectorMetricsView, 12 | MonthlyMetricsSummaryView, 13 | YearlySummaryView, 14 | QuarterlySummaryView, 15 | WeeklySummaryView, 16 | DailySummaryView, 17 | HourlySummaryView, 18 | CustomSummaryView, 19 | get_metric_last_endpoint 20 | ) 21 | 22 | urlpatterns = [ 23 | re_path(r'^api/$', 24 | APIMetricsView.as_view(), 25 | name='api-metrics'), 26 | re_path(r'^api/last-endpoint/$', 27 | get_metric_last_endpoint, 28 | name='api-metrics-last-endpoint'), 29 | re_path(r'^api/summary-partial-function$', 30 | APISummaryPartialFunctionView.as_view(), 31 | name='api-metrics-summary-partial-function'), 32 | re_path(r'^connector/$', 33 | ConnectorMetricsView.as_view(), 34 | name='connector-metrics'), 35 | re_path(r'^monthly-summary/$', 36 | MonthlyMetricsSummaryView.as_view(), 37 | name='metrics-summary'), 38 | re_path(r'^yearly-summary/$', 39 | YearlySummaryView.as_view(), 40 | name='yearly-summary'), 41 | re_path(r'^quarterly-summary/$', 42 | QuarterlySummaryView.as_view(), 43 | name='quarterly-summary'), 44 | re_path(r'^weekly-summary/$', 45 | WeeklySummaryView.as_view(), 46 | name='weekly-summary'), 47 | re_path(r'^daily-summary/$', 48 | DailySummaryView.as_view(), 49 | name='daily-summary'), 50 | re_path(r'^hourly-summary/$', 51 | HourlySummaryView.as_view(), 52 | name='hourly-summary'), 53 | re_path(r'^custom-summary/$', 54 | CustomSummaryView.as_view(), 55 | name='custom-summary'), 56 | ] 57 | -------------------------------------------------------------------------------- /apimanager/obp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/obp/__init__.py -------------------------------------------------------------------------------- /apimanager/obp/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for OBP app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class OBPConfig(AppConfig): 10 | """Config for OBP""" 11 | name = 'obp' 12 | -------------------------------------------------------------------------------- /apimanager/obp/authenticator.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Base authenticator for OBP app 4 | """ 5 | 6 | 7 | class AuthenticatorError(Exception): 8 | """Exception class for Authenticator errors""" 9 | pass 10 | 11 | 12 | class Authenticator(object): 13 | """Generic authenticator to the API""" 14 | pass 15 | -------------------------------------------------------------------------------- /apimanager/obp/directlogin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | DirectLogin authenticator for OBP app 4 | """ 5 | 6 | 7 | import requests 8 | from apimanager import local_settings 9 | 10 | from django.conf import settings 11 | 12 | from .authenticator import Authenticator, AuthenticatorError 13 | 14 | 15 | class DirectLoginAuthenticator(Authenticator): 16 | """Implements a DirectLogin authenticator to the API""" 17 | 18 | token = None 19 | 20 | def __init__(self, token=None): 21 | self.token = token 22 | 23 | # This method will call '/my/logins/direct' endpoint and get the directLogin token back, store it to self.token filed. 24 | # the requestheaders are from the home.html form. eg: 25 | # username="susan.uk.29@example.com",password="2b78e8", consumer_key="my5qhma1cfig5wstj5poa355onjchk0enkf3boq4" 26 | def prepare_direct_login_token(self, requestheaders): 27 | """ 28 | Logs into the API and returns the token 29 | 30 | data is a dict which contains keys username, password and consumer_key 31 | """ 32 | requestheaders['consumer_key']=local_settings.OAUTH_CONSUMER_KEY 33 | #print("hello",local_settings.OAUTH_CONSUMER_KEY) 34 | url = settings.API_HOST + settings.DIRECTLOGIN_PATH 35 | authorization = 'DirectLogin username="{}",password="{}",consumer_key="{}"'.format( 36 | requestheaders['username'], 37 | requestheaders['password'], 38 | requestheaders['consumer_key'] 39 | ) 40 | headers = {'Authorization': authorization} 41 | 42 | try: 43 | # 'http://127.0.0.1:8080/my/logins/direct' 44 | # Headers:{'Authorization': 'DirectLogin username="susan.uk.29@example.com",password="2b78e8", 45 | # consumer_key="my5qhma1cfig5wstj5poa355onjchk0enkf3boq4"'} 46 | # This will get the directLogin Token back. 47 | response = requests.post(url, headers=headers) 48 | except requests.exceptions.ConnectionError as err: 49 | raise AuthenticatorError(Exception("The OBP-API server is not running or does not respond properly." 50 | "Please check OBP-API server. " 51 | "Details: "+str(err))) 52 | except Exception as err: 53 | raise AuthenticatorError(Exception("Unknown Error. Details:"+ str(err))) 54 | 55 | # This is the direct-Login Token: 56 | # : {'token': 'eyJhbGciOiJIUzI1NiJ9.eyIiOiIifQ.HURJVvyGgcPcjvrfRCSbRyk1_ssjlAUk8fP0leKx8kw'} 57 | result = response.json() 58 | if response.status_code != 201: 59 | raise AuthenticatorError(result['message']) 60 | else: 61 | self.token = result['token'] 62 | 63 | def get_session(self): 64 | """Returns a session object to make authenticated requests""" 65 | headers = {'Authorization': 'DirectLogin token={}'.format(self.token)} 66 | session = requests.Session() 67 | session.headers.update(headers) 68 | return session 69 | -------------------------------------------------------------------------------- /apimanager/obp/forms.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Forms for OBP app 4 | """ 5 | 6 | from django import forms 7 | 8 | from .authenticator import AuthenticatorError 9 | from .directlogin import DirectLoginAuthenticator 10 | from .gatewaylogin import GatewayLoginAuthenticator 11 | 12 | 13 | class DirectLoginForm(forms.Form): 14 | username = forms.CharField(widget=forms.TextInput( 15 | attrs={'class': 'form-control'})) 16 | password = forms.CharField(widget=forms.PasswordInput( 17 | attrs={'class': 'form-control'})) 18 | # We are now getting consumer_key from settings 19 | #consumer_key = forms.CharField(widget=forms.TextInput( 20 | #attrs={'class': 'form-control'})) 21 | 22 | def clean(self): 23 | """ 24 | Stores an authenticator in cleaned_data after successful login to API 25 | """ 26 | cleaned_data = super(DirectLoginForm, self).clean() 27 | authenticator = DirectLoginAuthenticator() 28 | try: 29 | authenticator.prepare_direct_login_token(cleaned_data) 30 | cleaned_data['authenticator'] = authenticator 31 | except AuthenticatorError as err: 32 | raise forms.ValidationError(err) 33 | return cleaned_data 34 | 35 | 36 | class GatewayLoginForm(forms.Form): 37 | username = forms.CharField(widget=forms.TextInput( 38 | attrs={'class': 'form-control'})) 39 | secret = forms.CharField(widget=forms.PasswordInput( 40 | attrs={'class': 'form-control'})) 41 | 42 | def clean(self): 43 | """ 44 | Stores an authenticator in cleaned_data after successful login to API 45 | """ 46 | cleaned_data = super(GatewayLoginForm, self).clean() 47 | authenticator = GatewayLoginAuthenticator() 48 | try: 49 | authenticator.prepare_gateway_login_token(cleaned_data) 50 | cleaned_data['authenticator'] = authenticator 51 | except AuthenticatorError as err: 52 | raise forms.ValidationError(err) 53 | return cleaned_data 54 | -------------------------------------------------------------------------------- /apimanager/obp/gatewaylogin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | GatewayLogin authenticator for OBP app 4 | """ 5 | 6 | 7 | import jwt 8 | import requests 9 | 10 | from django.conf import settings 11 | 12 | from .authenticator import Authenticator, AuthenticatorError 13 | 14 | 15 | class GatewayLoginAuthenticator(Authenticator): 16 | """Implements a GatewayLogin authenticator to the API""" 17 | 18 | token = None 19 | 20 | def __init__(self, token=None): 21 | self.token = token 22 | 23 | def create_jwt(self, data): 24 | """ 25 | Creates a JWT used for future requests tothe API 26 | data is a dict which contains keys username, secret 27 | """ 28 | message = { 29 | 'login_user_name': data['username'], 30 | 'time_stamp': 'unused', 31 | 'app_id': '', # Do not create new consumer 32 | 'app_name': '', # Do not create new consumer 33 | 'temenos_id': '', # Whatever that does 34 | } 35 | if settings.GATEWAYLOGIN_HAS_CBS: 36 | # Not sure if that is the right thing to do 37 | message['is_first'] = True 38 | else: 39 | # Fake when there is no core banking system 40 | message.update({ 41 | 'is_first': False, 42 | 'cbs_token': 'dummy', 43 | }) 44 | token = jwt.encode(message, data['secret'], 'HS256') 45 | self.token = token.decode('utf-8') 46 | return self.token 47 | 48 | def prepare_gateway_login_token(self, data): 49 | token = self.create_jwt(data) 50 | # Make a test call to see if the token works 51 | url = '{}{}'.format(settings.API_VERSION, '/users/current') 52 | api = self.get_session() 53 | try: 54 | response = api.get(url) 55 | except requests.exceptions.ConnectionError as err: 56 | raise AuthenticatorError(Exception("The OBP-API server is not running or does not respond properly." 57 | "Please check OBP-API server. " 58 | "Details: " + str(err))) 59 | except Exception as err: 60 | raise AuthenticatorError(Exception("Unknown Error. Details:" + str(err))) 61 | # this will show the obp errors 62 | if response.status_code != 200: 63 | raise AuthenticatorError(response.json()['message']) 64 | else: 65 | return token 66 | 67 | def get_session(self): 68 | """Returns a session object to make authenticated requests""" 69 | headers = { 70 | 'Authorization': 'GatewayLogin token="{}"'.format(self.token), 71 | } 72 | session = requests.Session() 73 | session.headers.update(headers) 74 | return session 75 | -------------------------------------------------------------------------------- /apimanager/obp/oauth.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | OAuth authenticator for OBP app 4 | """ 5 | 6 | import logging 7 | 8 | from django.conf import settings 9 | 10 | from requests.exceptions import ConnectionError 11 | from requests_oauthlib import OAuth1Session 12 | from requests_oauthlib.oauth1_session import TokenRequestDenied 13 | 14 | from .authenticator import Authenticator, AuthenticatorError 15 | 16 | # Set up logging 17 | LOGGER = logging.getLogger("requests_oauthlib") 18 | LOGGER.setLevel(logging.DEBUG) # Enable detailed logging for requests-oauthlib 19 | 20 | # Enable logging for oauthlib to capture signature creation 21 | logging.getLogger("oauthlib").setLevel(logging.DEBUG) 22 | 23 | # Optionally, format logging output 24 | logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') 25 | 26 | class OAuthAuthenticator(Authenticator): 27 | """Implements an OAuth authenticator to the API""" 28 | 29 | token = None 30 | secret = None 31 | 32 | def __init__(self, token=None, secret=None): 33 | self.token = token 34 | self.secret = secret 35 | 36 | def get_authorization_url(self, callback_uri): 37 | session = OAuth1Session( 38 | settings.OAUTH_CONSUMER_KEY, 39 | client_secret=settings.OAUTH_CONSUMER_SECRET, 40 | callback_uri=callback_uri, 41 | ) 42 | try: 43 | url = settings.API_HOST + settings.OAUTH_TOKEN_PATH 44 | # Fetch the request token, logging the signature details 45 | response = session.fetch_request_token(url, verify=settings.VERIFY) 46 | except (ValueError, TokenRequestDenied, ConnectionError) as err: 47 | raise AuthenticatorError(err) 48 | else: 49 | self.token = response.get('oauth_token') 50 | self.secret = response.get('oauth_token_secret') 51 | url = settings.API_PORTAL + settings.OAUTH_AUTHORIZATION_PATH 52 | authorization_url = session.authorization_url(url) 53 | LOGGER.log(logging.INFO, 'Initial token {}, secret {}'.format( 54 | self.token, self.secret)) 55 | return authorization_url 56 | 57 | def set_access_token(self, authorization_url): 58 | session = OAuth1Session( 59 | settings.OAUTH_CONSUMER_KEY, 60 | settings.OAUTH_CONSUMER_SECRET, 61 | resource_owner_key=self.token, 62 | resource_owner_secret=self.secret, 63 | ) 64 | session.parse_authorization_response(authorization_url) 65 | url = settings.API_HOST + settings.OAUTH_ACCESS_TOKEN_PATH 66 | try: 67 | response = session.fetch_access_token(url) 68 | except (TokenRequestDenied, ConnectionError) as err: 69 | raise AuthenticatorError(err) 70 | else: 71 | self.token = response.get('oauth_token') 72 | self.secret = response.get('oauth_token_secret') 73 | LOGGER.log(logging.INFO, 'Updated token {}, secret {}'.format( 74 | self.token, self.secret)) 75 | 76 | def get_session(self): 77 | session = OAuth1Session( 78 | settings.OAUTH_CONSUMER_KEY, 79 | client_secret=settings.OAUTH_CONSUMER_SECRET, 80 | resource_owner_key=self.token, 81 | resource_owner_secret=self.secret, 82 | ) 83 | return session 84 | -------------------------------------------------------------------------------- /apimanager/obp/templates/obp/directlogin.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |

DirectLogin

5 |
6 | {% if form.non_field_errors %}
{{ form.non_field_errors }}
{% endif %} 7 | {% csrf_token %} 8 |
9 | {% if form.username.errors %}
{{ form.username.errors }}
{% endif %} 10 | 11 | {{ form.username }} 12 |
13 |
14 | {% if form.password.errors %}
{{ form.password.errors }}
{% endif %} 15 | 16 | {{ form.password }} 17 |
18 |
19 | {% if form.consumer_key.errors %}
{{ form.consumer_key.errors }}
{% endif %} 20 | 21 | {{ form.consumer_key }} 22 |
23 | 24 |
25 | {% endblock content %} 26 | -------------------------------------------------------------------------------- /apimanager/obp/templates/obp/gatewaylogin.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |

GatewayLogin

5 |
6 | {% if form.non_field_errors %}
{{ form.non_field_errors }}
{% endif %} 7 | {% csrf_token %} 8 |
9 | {% if form.username.errors %}
{{ form.username.errors }}
{% endif %} 10 | 11 | {{ form.username }} 12 |
13 |
14 | {% if form.secret.errors %}
{{ form.secret.errors }}
{% endif %} 15 | 16 | {{ form.secret }} 17 |
18 | 19 |
20 | {% endblock content %} 21 | -------------------------------------------------------------------------------- /apimanager/obp/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for OBP app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import ( 9 | OAuthInitiateView, OAuthAuthorizeView, 10 | DirectLoginView, 11 | GatewayLoginView, 12 | LogoutView, 13 | ) 14 | 15 | 16 | urlpatterns = [ 17 | re_path(r'^oauth/initiate$', 18 | OAuthInitiateView.as_view(), name='oauth-initiate'), 19 | re_path(r'^oauth/authorize$', 20 | OAuthAuthorizeView.as_view(), name='oauth-authorize'), 21 | re_path(r'^directlogin$', 22 | DirectLoginView.as_view(), name='directlogin'), 23 | re_path(r'^gatewaylogin$', 24 | GatewayLoginView.as_view(), name='gatewaylogin'), 25 | re_path(r'^logout$', 26 | LogoutView.as_view(), name='oauth-logout'), 27 | ] 28 | -------------------------------------------------------------------------------- /apimanager/productlist/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/productlist/__init__.py -------------------------------------------------------------------------------- /apimanager/productlist/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/productlist/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ProductsConfig(AppConfig): 5 | name = 'productlist' -------------------------------------------------------------------------------- /apimanager/productlist/forms.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/productlist/forms.py -------------------------------------------------------------------------------- /apimanager/productlist/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/productlist/static/productlist/css/productlist.css: -------------------------------------------------------------------------------- 1 | #product_list div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/productlist/static/productlist/js/productlist.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/productlist/templates/productlist/productlist.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "Product List" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "Product List" %}

5 |
6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for product in products_list %} 18 | 19 | 20 | 21 | 22 | 23 | 35 | 36 | {% endfor %} 37 | 38 | 39 |
{% trans "Product Code" %}{% trans "Bank Id" %}{% trans "Name" %}{% trans "More info" %}
{{ product.product_code }}{{ product.bank_id }}{{ product.name }} 24 |
25 |
    26 |
  • {% trans "Description" %}: 27 |
      28 |
    • {{product.more_info_url}}
    • 29 |
    30 |
  • 31 | 32 |
33 |
34 |
40 |
41 |
42 | 43 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 44 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/productlist/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/productlist/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for Product list app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import ProductListView, ExportCsvView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | ProductListView.as_view(), 12 | name='product-list'), 13 | re_path(r'^export_csv$', 14 | ExportCsvView.as_view(), 15 | name='export-csv-product'), 16 | 17 | ] 18 | -------------------------------------------------------------------------------- /apimanager/products/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/products/__init__.py -------------------------------------------------------------------------------- /apimanager/products/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apimanager/products/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BranchesConfig(AppConfig): 5 | name = 'products' 6 | -------------------------------------------------------------------------------- /apimanager/products/forms.py: -------------------------------------------------------------------------------- 1 | """ 2 | Forms of branches app 3 | """ 4 | 5 | from django import forms 6 | from django.utils.translation import gettext_lazy as _ 7 | import random 8 | 9 | 10 | class CreateProductForm(forms.Form): 11 | 12 | product_code = forms.CharField( 13 | label=_('Product Code'), 14 | widget=forms.TextInput( 15 | attrs={ 16 | 'placeholder': 'Product-Code-{}'.format(random.randint(1,1000)), 17 | 'class': 'form-control', 18 | } 19 | ), 20 | initial='Product-Code-{}'.format(random.randint(1,1000)), 21 | ) 22 | 23 | bank_id = forms.ChoiceField( 24 | label=_('Bank'), 25 | widget=forms.Select( 26 | attrs={ 27 | 'class': 'form-control', 28 | } 29 | ), 30 | choices=[], 31 | ) 32 | 33 | parent_product_code = forms.CharField( 34 | label=_('parent_product_code'), 35 | widget=forms.TextInput( 36 | attrs={ 37 | 'placeholder': _('parent_product_code'), 38 | 'class': 'form-control', 39 | } 40 | ), 41 | required=False 42 | ) 43 | 44 | name = forms.CharField( 45 | label=_('Name'), 46 | widget=forms.TextInput( 47 | attrs={ 48 | 'placeholder': _('The name of the branch'), 49 | 'class': 'form-control', 50 | } 51 | ), 52 | required=True 53 | ) 54 | more_info_url = forms.CharField( 55 | label=_('more_info_url'), 56 | widget=forms.TextInput( 57 | attrs={ 58 | 'placeholder': _('The name of the branch'), 59 | 'class': 'form-control', 60 | } 61 | ), 62 | required=False 63 | ) 64 | terms_and_conditions_url = forms.CharField( 65 | label=_('terms_and_conditions_url'), 66 | widget=forms.TextInput( 67 | attrs={ 68 | 'placeholder': _('terms_and_conditions_url'), 69 | 'class': 'form-control', 70 | } 71 | ), 72 | required=False 73 | ) 74 | description = forms.CharField( 75 | label=_('description'), 76 | widget=forms.TextInput( 77 | attrs={ 78 | 'placeholder': _('description'), 79 | 'class': 'form-control', 80 | } 81 | ), 82 | required=False 83 | ) 84 | 85 | meta_license_id = forms.CharField( 86 | label=_('meta_license_id'), 87 | widget=forms.TextInput( 88 | attrs={ 89 | 'placeholder': 'PDDL', 90 | 'class': 'form-control', 91 | } 92 | ), 93 | required=False, 94 | ) 95 | 96 | meta_license_name = forms.CharField( 97 | label=_('meta_license_name'), 98 | widget=forms.TextInput( 99 | attrs={ 100 | 'placeholder': 'Open Data Commons Public Domain Dedication and License', 101 | 'class': 'form-control', 102 | } 103 | ), 104 | required=False, 105 | ) 106 | 107 | def __init__(self, *args, **kwargs): 108 | kwargs.setdefault('label_suffix', '') 109 | super(CreateProductForm, self).__init__(*args, **kwargs) 110 | -------------------------------------------------------------------------------- /apimanager/products/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/products/static/products/css/products.css: -------------------------------------------------------------------------------- 1 | #products div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100% 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/products/static/products/js/products.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('#info').click(function() { 3 | alert("Hello World") 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /apimanager/products/templates/products/update.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | {% load i18n %} 4 | {% block page_title %}{{ block.super }} / Products {% endblock page_title %} 5 | {% block content %} 6 | 7 |
8 |

{% trans "ATM Detail" %}

9 |

{{ bank_id }} : {{ product_code }}

10 |
11 | {% csrf_token %} 12 | {% if form.non_field_errors %} 13 |
14 | {{ form.non_field_errors }} 15 |
16 | {% endif %} 17 | 40 | 41 |
42 |
43 | {% if form.terms_and_conditions_url.errors %}
{{ form.terms_and_conditions_url.errors }}
{% endif %} 44 |
45 | {{ form.terms_and_conditions_url.label_tag }} 46 | {{ form.terms_and_conditions_url }} 47 |
48 |
49 |
50 | {% if form.description.errors %}
{{ form.description.errors }}
{% endif %} 51 |
52 | {% trans "description" %} 53 | {{ form.description }} 54 |
55 |
56 |
57 | {% if form.meta_license_name.errors %}
{{ form.meta_license_name.errors }}
{% endif %} 58 |
59 | {{ form.meta_license_name.label_tag }} 60 | {{ form.meta_license_name }} 61 |
62 |
63 |
64 | 65 |
66 |
67 | {% endblock %} 68 | 69 | {% block extrajs %} 70 | {% comment %} 71 | 72 | 74 | {% endcomment %} 75 | {% endblock extrajs %} 76 | 77 | 78 | {% block extracss %} 79 | 80 | {% endblock extracss %} 81 | -------------------------------------------------------------------------------- /apimanager/products/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/products/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for metrics app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexProductView, UpdateProductView, create_list 9 | 10 | urlpatterns = [ 11 | re_path(r'^create', 12 | IndexProductView.as_view(), 13 | name='products-create'), 14 | re_path(r'^update/(?P[0-9\w\@\.\+-]+)/bank/(?P[0-9\w\@\.\+-]+)/$', 15 | UpdateProductView.as_view(), 16 | name='products_update'), 17 | re_path(r'^createProductList', 18 | create_list, 19 | name = 'create-product-list'), 20 | ] 21 | -------------------------------------------------------------------------------- /apimanager/systemviews/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/systemviews/__init__.py -------------------------------------------------------------------------------- /apimanager/systemviews/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SystemViewsConfig(AppConfig): 5 | name = 'systemviews' 6 | -------------------------------------------------------------------------------- /apimanager/systemviews/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | # -*- coding: utf-8 -*- 5 | -------------------------------------------------------------------------------- /apimanager/systemviews/static/systemviews/css/systemviews.css: -------------------------------------------------------------------------------- 1 | #system_view div { 2 | margin: 5px 0; 3 | } 4 | 5 | /* The actual popup (appears on top) */ 6 | .popuptext { 7 | width: 250px; 8 | background-color: #555; 9 | color: #fff; 10 | text-align: left; 11 | border-radius: 6px; 12 | padding: 8px 0; 13 | z-index: 1; 14 | /*bottom: 125%;*/ 15 | top:100%; 16 | left: 50%; 17 | margin-left: -80px; 18 | } 19 | -------------------------------------------------------------------------------- /apimanager/systemviews/static/systemviews/js/systemviews.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/systemviews/static/systemviews/js/systemviews.js -------------------------------------------------------------------------------- /apimanager/systemviews/templates/systemviews/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% load i18n %} 2 | {% block page_title %} {{ block.super }} / {% trans "System View" %}{% endblock page_title %} {% block content %} 3 |
4 |

{% trans "System Views" %}

5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
{% trans "Id" %}{% trans "Short Name" %}{% trans "Is Public" %}{% trans "Description" %}
{{ system_view.id }}{{ system_view.short_name }}{{ system_view.is_public }}{{ system_view.description }}{% trans "Detail" %}
24 |
25 |
26 | 27 | {% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} 28 | {% endblock extracss %} -------------------------------------------------------------------------------- /apimanager/systemviews/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apimanager/systemviews/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for System View app 4 | """ 5 | 6 | from django.urls import re_path 7 | from .views import SystemView 8 | 9 | urlpatterns = [ 10 | re_path(r'^$', 11 | SystemView.as_view(), 12 | name='system_view'), 13 | ] 14 | -------------------------------------------------------------------------------- /apimanager/systemviews/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | # -*- coding: utf-8 -*- 5 | """ 6 | Views of System View app 7 | """ 8 | import datetime 9 | from django.contrib import messages 10 | from django.contrib.auth.mixins import LoginRequiredMixin 11 | import json 12 | from django.urls import reverse_lazy 13 | from django.http import HttpResponse 14 | from django.views.generic import FormView,TemplateView, View 15 | from obp.api import API, APIError 16 | 17 | 18 | class SystemView(LoginRequiredMixin, FormView): 19 | template_name = "systemviews/index.html" 20 | success_url = '/systemview' 21 | 22 | def get_systemview(self): 23 | api = API(self.request.session.get('obp')) 24 | try: 25 | system_view = [] 26 | urlpath = '/system-views/owner' 27 | result = api.get(urlpath) 28 | system_view = result 29 | except APIError as err: 30 | messages.error(self.request, err) 31 | return [] 32 | except Exception as inst: 33 | messages.error(self.request, "Unknown Error {}".format(type(inst).__name__)) 34 | return [] 35 | return system_view 36 | def get_context_data(self, **kwargs): 37 | system_view = self.get_systemview() 38 | context = {} 39 | context.update({ 40 | 'system_view': system_view, 41 | }) 42 | return context 43 | -------------------------------------------------------------------------------- /apimanager/users/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/users/__init__.py -------------------------------------------------------------------------------- /apimanager/users/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for users app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class UsersConfig(AppConfig): 10 | """Config for users""" 11 | name = 'users' 12 | -------------------------------------------------------------------------------- /apimanager/users/forms.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Forms of users app 4 | """ 5 | 6 | from django import forms 7 | from django.utils.translation import gettext_lazy as _ 8 | 9 | class AddEntitlementForm(forms.Form): 10 | user_id = forms.CharField( 11 | widget=forms.HiddenInput(), 12 | required=True, 13 | ) 14 | role_name = forms.CharField( 15 | label=_('Role name'), 16 | widget=forms.TextInput( 17 | attrs={ 18 | 'class': 'form-control', 19 | } 20 | ), 21 | required=True, 22 | ) 23 | bank_id = forms.ChoiceField( 24 | label=_('Bank'), 25 | widget=forms.Select( 26 | attrs={ 27 | 'class': 'form-control', 28 | } 29 | ), 30 | choices=[], 31 | required=False, 32 | ) 33 | 34 | def __init__(self, *args, **kwargs): 35 | kwargs.setdefault('label_suffix', '') 36 | super(AddEntitlementForm, self).__init__(*args, **kwargs) 37 | 38 | class CreateInvitationForm(forms.Form): 39 | 40 | USER_CHOICE = ( 41 | ('', _('Any')), 42 | ('DEVELOPER', 'DEVELOPER'), 43 | ('CUSTOMER', 'CUSTOMER'), 44 | ) 45 | bank_id = forms.ChoiceField( 46 | label=_('Bank'), 47 | widget=forms.Select( 48 | attrs={ 49 | 'class': 'form-control', 50 | } 51 | ), 52 | choices=[], 53 | ) 54 | first_name = forms.CharField( 55 | label=_('First Name'), 56 | widget=forms.TextInput( 57 | attrs={ 58 | 'placeholder': _('First Name'), 59 | 'class': 'form-control', 60 | } 61 | ), 62 | ) 63 | last_name = forms.CharField( 64 | label=_('Last Name'), 65 | widget=forms.TextInput( 66 | attrs={ 67 | 'placeholder': _('Last Name'), 68 | 'class': 'form-control', 69 | } 70 | ), 71 | ) 72 | email = forms.CharField( 73 | label=_('Email'), 74 | widget=forms.EmailInput( 75 | attrs={ 76 | 'placeholder': 'felixsmith@example.com', 77 | 'class': 'form-control', 78 | } 79 | ), 80 | required=True, 81 | ) 82 | company = forms.CharField( 83 | label=_('Company'), 84 | widget=forms.TextInput( 85 | attrs={ 86 | 'placeholder': _('TESOBE GmbH'), 87 | 'class': 'form-control', 88 | } 89 | ), 90 | required=True, 91 | ) 92 | country = forms.CharField( 93 | label=_('Country'), 94 | widget=forms.TextInput( 95 | attrs={ 96 | 'placeholder': _('Germany'), 97 | 'class': 'form-control', 98 | } 99 | ), 100 | required=True, 101 | ) 102 | purpose = forms.ChoiceField( 103 | label=_('Purpose'), 104 | choices=USER_CHOICE, 105 | widget=forms.Select( 106 | attrs={ 107 | 'class': 'form-control', 108 | } 109 | ), 110 | initial='', 111 | required=False, 112 | ) 113 | 114 | def __init__(self, *args, **kwargs): 115 | kwargs.setdefault('label_suffix', '') 116 | super(CreateInvitationForm, self).__init__(*args, **kwargs) 117 | -------------------------------------------------------------------------------- /apimanager/users/static/users/css/users.css: -------------------------------------------------------------------------------- 1 | #users #users-list { 2 | margin-top: 20px; 3 | } 4 | 5 | #users #users-filters .col-xs-12 { 6 | padding-top: 10px; 7 | } 8 | 9 | #users-detail div { 10 | margin: 5px 0; 11 | } 12 | -------------------------------------------------------------------------------- /apimanager/users/static/users/js/users.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | }); 3 | -------------------------------------------------------------------------------- /apimanager/users/templates/users/includes/filter_email.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 |
3 |
4 |
5 | 6 | 7 |
8 | 9 | 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /apimanager/users/templates/users/includes/filter_locked.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% trans "Active" %} 3 | {% trans "Locked" %} 4 | {% trans "All" %} -------------------------------------------------------------------------------- /apimanager/users/templates/users/includes/filter_pagination.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 10 |
11 | 12 | 13 |
-------------------------------------------------------------------------------- /apimanager/users/templates/users/includes/filter_role.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 |
3 |
4 | 7 | 14 |
15 |
16 | -------------------------------------------------------------------------------- /apimanager/users/templates/users/includes/filter_username.html: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 |
3 |
4 |
5 | 6 | 7 |
8 | 9 | 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /apimanager/users/templates/users/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | {% load i18n %} 4 | {% block page_title %}{{ block.super }} / Users{% endblock page_title %} 5 | 6 | {% block content %} 7 |
8 |

{% trans "Users" %}

9 | 10 |
11 |

{% trans "Filters" %}

12 | 25 | 38 |
39 | 40 | 41 |
42 |
43 | 44 |

{% trans "Pagination" %}

45 | {% include "users/includes/filter_pagination.html" %} 46 |
47 |
48 | 49 |

{% trans "Statistics" %}

50 |
    51 |
  • {% trans "Total number of users" %}: {{ statistics.users_num }} 52 |
53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {% for user in users %} 64 | {% url 'users-detail' user.user_id as url_users_detail %} 65 | 66 | 67 | 68 | 69 | 70 | 71 | {% endfor %} 72 | 73 |
{% trans "User Id" %}{% trans "Username" %}{% trans "Email" %}{% trans "Action" %}
{{ user.user_id }}{{ user.username }}{{ user.email }}{% trans "Detail" %}
74 |
75 |
76 | {% endblock %} 77 | 78 | {% block extrajs %} 79 | {% comment %} 80 | 81 | 83 | {% endcomment %} 84 | {% endblock extrajs %} 85 | 86 | 87 | {% block extracss %} 88 | 89 | {% endblock extracss %} 90 | -------------------------------------------------------------------------------- /apimanager/users/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for users app 4 | """ 5 | 6 | from django.urls import re_path 7 | from django.urls import path 8 | 9 | from .views import IndexView, DetailView, MyDetailView, DeleteEntitlementView, InvitationView, UserStatusUpdateView, \ 10 | ExportCsvView, AutocompleteFieldView, DeleteAttributeView 11 | 12 | urlpatterns = [ 13 | re_path(r'^all$', 14 | IndexView.as_view(), 15 | name='users-index'), 16 | re_path(r'^all/user_id/(?P[\w\@\.\+-]+)$', 17 | DetailView.as_view(), 18 | name='users-detail'), 19 | re_path(r'^myuser$', 20 | MyDetailView.as_view(), 21 | name='my-user-detail'), 22 | re_path(r'^myuser/invitation$', 23 | InvitationView.as_view(), 24 | name='my-user-invitation'), 25 | re_path(r'^(?P[\w-]+)/entitlement/delete/(?P[\w-]+)$', 26 | DeleteEntitlementView.as_view(), 27 | name='users-delete-entitlement'), 28 | re_path(r'^(?P[\w-]+)/atribute/delete/(?P[\w-]+)$', 29 | DeleteAttributeView.as_view(), 30 | name='users-delete-attribute'), 31 | re_path(r'^(?P[\w-]+)/userStatusUpdateView/(?P[\w\@\.\+-]+)$', 32 | UserStatusUpdateView.as_view(), 33 | name='user-status-update'), 34 | re_path(r'^export_csv$', 35 | ExportCsvView.as_view(), 36 | name='export-csv-users'), 37 | ] 38 | -------------------------------------------------------------------------------- /apimanager/webui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBankProject/API-Manager/f5d38cfc4ff0c2687b6117403a20f5bf11d33a55/apimanager/webui/__init__.py -------------------------------------------------------------------------------- /apimanager/webui/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | App config for config app 4 | """ 5 | 6 | from django.apps import AppConfig 7 | 8 | 9 | class WebuiConfig(AppConfig): 10 | """Config for config""" 11 | name = 'webui' 12 | -------------------------------------------------------------------------------- /apimanager/webui/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | 4 | class WebuiForm(forms.Form): 5 | webui_props_name = forms.CharField( 6 | label='WEBUI Props Name', 7 | widget=forms.TextInput( 8 | attrs={ 9 | 'class': 'form-control', 10 | } 11 | ), 12 | required=True, 13 | ) 14 | webui_props_value = forms.CharField( 15 | label='WEBUI Props Value', 16 | widget=forms.Textarea( 17 | attrs={ 18 | 'class': 'form-control', 19 | 'cols': '40', 20 | 'rows': '1' 21 | } 22 | ), 23 | required=False 24 | ) -------------------------------------------------------------------------------- /apimanager/webui/static/webui/css/webui.css: -------------------------------------------------------------------------------- 1 | #config pre { 2 | overflow: auto; 3 | word-wrap: normal; 4 | white-space: pre; 5 | } 6 | #config .string { color: green; } 7 | #config .number { color: darkorange; } 8 | #config .boolean { color: blue; } 9 | #config .null { color: magenta; } 10 | #config .key { color: red; } 11 | -------------------------------------------------------------------------------- /apimanager/webui/static/webui/js/webui.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function($) { 2 | $('.runner button.forSave').click(function(e) { 3 | e.preventDefault(); 4 | const t = $(this); 5 | const runner = t.parent().parent().parent(); 6 | const web_ui_props_name = $(runner).find('.web_ui_props_name').text(); 7 | const web_ui_props_value = $(runner).find('.web_ui_props_value').val(); 8 | $('.runner button.forSave').attr("disabled", "disabled"); 9 | $('.runner button.forDelete').attr("disabled", "disabled"); 10 | $.post('save/method', { 11 | 'web_ui_props_name': web_ui_props_name, 12 | 'web_ui_props_value': web_ui_props_value, 13 | }, function(response) { 14 | location.reload(); 15 | }); 16 | }); 17 | 18 | $('.runner button.forDelete').click(function(e) { 19 | e.preventDefault(); 20 | const t = $(this); 21 | const runner = t.parent().parent().parent(); 22 | const props_id = $(runner).find('.web_ui_props_id'); 23 | const web_ui_props_id = props_id.val(); 24 | $('.runner button.forSave').attr("disabled", "disabled"); 25 | $('.runner button.forDelete').attr("disabled", "disabled"); 26 | $.post('delete/method', { 27 | 'web_ui_props_id': web_ui_props_id, 28 | }, function(response) { 29 | location.reload(); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /apimanager/webui/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | URLs for config app 4 | """ 5 | 6 | from django.urls import re_path 7 | 8 | from .views import IndexView, webui_save, webui_delete 9 | 10 | urlpatterns = [ 11 | re_path(r'^$', 12 | IndexView.as_view(), 13 | name='webui-index'), 14 | re_path(r'save/method', webui_save, 15 | name='methodrouting-save'), 16 | re_path(r'delete/method', webui_delete, 17 | name='methodrouting-delete') 18 | ] 19 | -------------------------------------------------------------------------------- /apimanager/webui/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Views of config app 4 | """ 5 | 6 | import json 7 | from django.contrib import messages 8 | from django.contrib.auth.mixins import LoginRequiredMixin 9 | from django.views.generic import FormView 10 | from obp.api import API, APIError 11 | from django.http import JsonResponse, HttpResponseRedirect, HttpResponse 12 | from .forms import WebuiForm 13 | from django.urls import reverse, reverse_lazy 14 | from django.views.decorators.csrf import csrf_exempt 15 | from base.utils import exception_handle, error_once_only 16 | 17 | class IndexView(LoginRequiredMixin, FormView): 18 | """Index view for config""" 19 | template_name = "webui/index.html" 20 | form_class = WebuiForm 21 | success_url = reverse_lazy('webui-index') 22 | 23 | def dispatch(self, request, *args, **kwargs): 24 | self.api = API(request.session.get('obp')) 25 | return super(IndexView, self).dispatch(request, *args, **kwargs) 26 | 27 | def get_context_data(self, **kwargs): 28 | context = super(IndexView, self).get_context_data(**kwargs) 29 | api = API(self.request.session.get('obp')) 30 | urlpath = '/management/webui_props?active=true' 31 | 32 | try: 33 | response = api.get(urlpath) 34 | if 'code' in response and response['code'] >= 400: 35 | messages.error(self.request, response['message']) 36 | context.update({'webui_props': []}) 37 | else: 38 | context.update(response) 39 | except APIError as err: 40 | messages.error(self.request, err) 41 | except Exception as err: 42 | messages.error(self.request, err) 43 | return context 44 | 45 | def get_form(self, *args, **kwargs): 46 | form = super(IndexView, self).get_form(*args, **kwargs) 47 | return form 48 | 49 | @exception_handle 50 | @csrf_exempt 51 | def webui_save(request): 52 | api = API(request.session.get('obp')) 53 | urlpath = '/management/webui_props' 54 | web_ui_props_name = request.POST.get('web_ui_props_name') 55 | web_ui_props_value = request.POST.get('web_ui_props_value') 56 | #print("web_ui_props_name", request.get) 57 | payload = { 58 | 'name': web_ui_props_name, 59 | 'value': web_ui_props_value 60 | } 61 | response = api.post(urlpath, payload=payload) 62 | return response 63 | 64 | @exception_handle 65 | @csrf_exempt 66 | def webui_delete(request): 67 | web_ui_props_id = request.POST.get('web_ui_props_id') 68 | if web_ui_props_id == 'default' or web_ui_props_id == '' or web_ui_props_id is None: 69 | return {'code':403,'message':'Cann\'t delete web_ui_props_id default'} 70 | else: 71 | api = API(request.session.get('obp')) 72 | urlpath = '/management/webui_props/{}'.format(web_ui_props_id) 73 | result = api.delete(urlpath) 74 | return result 75 | -------------------------------------------------------------------------------- /gunicorn.conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import multiprocessing 3 | import os 4 | 5 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 6 | 7 | bind = '127.0.0.1:8000' 8 | accesslog = os.path.join(BASE_DIR, 'logs', 'gunicorn.access.log') 9 | errorlog = os.path.join(BASE_DIR, 'logs', 'gunicorn.error.log') 10 | loglevel = 'info' 11 | capture_output = True 12 | workers = multiprocessing.cpu_count() * 2 + 1 13 | -------------------------------------------------------------------------------- /nginx.apimanager.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | server_name apimanager; 4 | 5 | location / { 6 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 7 | # enable this if and only if you use HTTPS 8 | # proxy_set_header X-Forwarded-Proto https; 9 | proxy_set_header Host $http_host; 10 | proxy_redirect off; 11 | proxy_pass http://127.0.0.1:8000; 12 | } 13 | 14 | location /en/static { 15 | alias /usr/share/nginx/html; 16 | } 17 | location /es/static { 18 | alias /usr/share/nginx/html; 19 | } 20 | location /static { 21 | alias /usr/share/nginx/html; 22 | } 23 | } -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | psycopg 2 | #Django==1.11.7 3 | Django==4.2.16 4 | oauthlib==3.2.2 5 | requests==2.32.3 6 | requests-oauthlib==1.3.1 7 | PyJWT==2.8.0 8 | gunicorn==22.0.0 9 | matplotlib 10 | django-bootstrap-datepicker-plus 11 | django-mathfilters 12 | django-bootstrap4 13 | django-csp -------------------------------------------------------------------------------- /supervisor.apimanager.conf: -------------------------------------------------------------------------------- 1 | [program:apimanager] 2 | directory = /var/www/apimanager/API-Manager/apimanager 3 | user = www-data 4 | group = www-data 5 | autostart=true 6 | autorestart=true 7 | startretries=3 8 | command = /var/www/apimanager/venv/bin/gunicorn --config /var/www/apimanager/API-Manager/gunicorn.conf.py apimanager.wsgi 9 | stdout_logfile = /var/www/apimanager/logs/supervisor.stdout.log 10 | stderr_logfile = /var/www/apimanager/logs/supervisor.stderr.log 11 | --------------------------------------------------------------------------------