diff --git a/docker-compose-parts/api.yml b/docker-compose-parts/api.yml index cbe71ae..cad5fbe 100644 --- a/docker-compose-parts/api.yml +++ b/docker-compose-parts/api.yml @@ -11,14 +11,16 @@ services: container_name: isard-sso-api volumes: - /etc/localtime:/etc/localtime:ro - - ${CUSTOM_PATH}/custom/menu/custom.yaml:/api/src/custom.yaml - - ${CUSTOM_PATH}/custom/menu/system.yaml:/api/src/system.yaml + #- ${BUILD_ROOT_PATH}/docker/api/src:/api:rw ## Develop + - ${CUSTOM_PATH}/custom/menu/custom.yaml:/api/custom.yaml + - ${CUSTOM_PATH}/custom/menu/system.yaml:/api/system.yaml - ${CUSTOM_PATH}/custom/img:/api/api/static/img + - ${DATA_FOLDER}/avatars/:/api/avatars:ro restart: unless-stopped networks: - isard_net - # ports: - # - published: 80 + ports: + # - published: 7039 # target: 7039 env_file: - .env \ No newline at end of file diff --git a/docker/api/requirements.pip3 b/docker/api/requirements.pip3 index 1ca641a..f23cf0d 100644 --- a/docker/api/requirements.pip3 +++ b/docker/api/requirements.pip3 @@ -13,3 +13,4 @@ six==1.15.0 Werkzeug==1.0.1 zope.event==4.4 zope.interface==5.1.0 +python-keycloak==0.24.0 diff --git a/docker/api/src/api/__init__.py b/docker/api/src/api/__init__.py index 1abe5ec..2117ef3 100644 --- a/docker/api/src/api/__init__.py +++ b/docker/api/src/api/__init__.py @@ -59,7 +59,7 @@ def send_templates(path): Import all views ''' from .views import MenuViews - +from .views import AvatarsViews diff --git a/docker/api/src/api/lib/avatars.py b/docker/api/src/api/lib/avatars.py new file mode 100644 index 0000000..6b694b8 --- /dev/null +++ b/docker/api/src/api/lib/avatars.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +# coding=utf-8 +import time +from api import app as application +from datetime import datetime, timedelta +import pprint + +import logging +import traceback +import yaml, json + +from jinja2 import Environment, FileSystemLoader + +from keycloak import KeycloakAdmin + + + +class Avatars(): + def __init__(self): + self.keycloak_admin = KeycloakAdmin(server_url="http://isard-sso-keycloak:8080/auth/", + username='admin', + password='keycloakkeycloak', + realm_name="master", + verify=True) + + def get_user_avatar(self,username): + return self.keycloak_admin.get_user_id(username) + + + + + +# # Add user +# new_user = keycloak_admin.create_user({"email": "example@example.com", +# "username": "example@example.com", +# "enabled": True, +# "firstName": "Example", +# "lastName": "Example"}) +# print(new_user) \ No newline at end of file diff --git a/docker/api/src/api/static/templates/header.html b/docker/api/src/api/static/templates/header.html new file mode 100644 index 0000000..5d94278 --- /dev/null +++ b/docker/api/src/api/static/templates/header.html @@ -0,0 +1,171 @@ + +
\ No newline at end of file diff --git a/docker/api/src/api/static/templates/header.json b/docker/api/src/api/static/templates/header.json new file mode 100644 index 0000000..4eb2fd6 --- /dev/null +++ b/docker/api/src/api/static/templates/header.json @@ -0,0 +1 @@ +{"background_login": "https://api.santantoni.duckdns.org/img/background.png", "colours": {"background": "#F0F0F0", "primary": "#92AE01", "secondary": "#FFFFFF"}, "logo": "https://api.santantoni.duckdns.org/img/logo.png", "apps_external": [{"href": "https://myweb", "icon": "fa fa-university", "name": "Escola Web", "shortname": "web"}, {"href": "https://myvideos", "icon": "fa fa-youtube-play", "name": "Youtube", "shortname": "youtube"}, {"href": "https://mydictionary", "icon": "fa fa-book", "name": "Diccionari", "shortname": "diccionari"}, {"href": "http://meet.jit.si", "icon": "fa fa-video-camera", "name": "Reunions Jitsi", "shortname": "jitsi"}, {"href": "https://www.duckduckgo.com", "icon": "fa fa-search", "name": "Cercar", "shortname": "search"}, {"href": "https://www.openstreetmap.org", "icon": "fa fa-map-marker", "name": "Maps", "shortname": "maps"}], "apps_internal": [{"href": "https://nextcloud.santantoni.duckdns.org/", "icon": "fa fa-cloud", "name": "N\u00favol + crear arxius", "shortname": "cloud"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/mail/setup", "icon": "fa fa-envelope-o", "name": "Correu", "shortname": "email"}, {"href": "https://pad.santantoni.duckdns.org/", "icon": "fa fa-file-text-o", "name": "Pads", "shortname": "pads"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/forms", "icon": "fa fa-check-square-o", "name": "Formularis", "shortname": "forms"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/polls", "icon": "fa fa-bar-chart", "name": "Enquestes", "shortname": "feedback"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/spreed", "icon": "fa fa-commenting-o", "name": "Xat", "shortname": "chat"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/calendar", "icon": "fa fa-calendar", "name": "Calendari", "shortname": "schedule"}, {"href": "https://wp.santantoni.duckdns.org/wp-login.php?saml_sso", "icon": "fa fa-rss", "name": "Webs", "shortname": "webs"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/bbb", "icon": "fa fa-video-camera", "name": "Reunions BBB", "shortname": "meets_bbb"}, {"href": "https://nextcloud.santantoni.duckdns.org/apps/photos", "icon": "fa fa-file-image-o", "name": "Fotos", "shortname": "photos"}], "user": {"account": "https://sso.santantoni.duckdns.org/auth/realms/master/account", "avatar": "https://sso.santantoni.duckdns.org/auth/realms/master/avatar-provider", "password": "https://sso.santantoni.duckdns.org/auth/realms/master/password"}} \ No newline at end of file diff --git a/docker/api/src/api/static/templates/header_nextcloud.html b/docker/api/src/api/static/templates/header_nextcloud.html new file mode 100644 index 0000000..5d94278 --- /dev/null +++ b/docker/api/src/api/static/templates/header_nextcloud.html @@ -0,0 +1,171 @@ + + \ No newline at end of file diff --git a/docker/api/src/api/views/AvatarsViews.py b/docker/api/src/api/views/AvatarsViews.py new file mode 100644 index 0000000..59df1fe --- /dev/null +++ b/docker/api/src/api/views/AvatarsViews.py @@ -0,0 +1,19 @@ +#!flask/bin/python +# coding=utf-8 +from api import app +import logging as log +import traceback + +from uuid import uuid4 +import time,json +import sys,os +from flask import render_template, Response, request, redirect, url_for, jsonify, send_from_directory + +from ..lib.avatars import Avatars +avatars = Avatars() + +@app.route("/avatar/