From 1cd7e589366ccbf93cdef29e34eab4fb571dc92f Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Feb 24 2020 13:57:36 +0000 Subject: Add theming capabilities Signed-off-by: Stasiek Michalski --- diff --git a/ipsilon/ipsilon b/ipsilon/ipsilon index 1a63cfa..fe62143 100755 --- a/ipsilon/ipsilon +++ b/ipsilon/ipsilon @@ -54,6 +54,12 @@ for option in admin_config: cherrypy.config[option] = admin_config[option] template_loaders = [] +theme_dir = cherrypy.config.get('theme_dir') +if theme_dir: + if theme_dir.startswith('/'): + template_loaders.append(FileSystemLoader(os.path.join(theme_dir, 'templates'))) + else: + template_loaders.append(FileSystemLoader(os.path.join(cherrypy.config['base.dir'], theme_dir, 'templates'))) default_template_dir = 'templates' template_dir = cherrypy.config.get('template_dir', default_template_dir) if template_dir.startswith('/'): @@ -85,6 +91,9 @@ if __name__ == "__main__": 'tools.staticdir.dir': 'ui'}, '/cache': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'cache'}} + if theme_dir: + conf['/ui/res'] = {'tools.staticdir.on': True, + 'tools.staticdir.dir': os.path.join(theme_dir, 'res')} cherrypy.quickstart(Root('default', template_env), cherrypy.config.get('base.mount') or '/', conf) diff --git a/quickrun.py b/quickrun.py index 2bbe16d..0235955 100755 --- a/quickrun.py +++ b/quickrun.py @@ -130,6 +130,12 @@ if __name__ == '__main__': penv.update(os.environ) penv['PYTHONPATH'] = os.getcwd() + if not os.path.exists(args['workdir']): + conf = config(args['workdir']) + init(args['workdir']) + else: + conf = os.path.join(args['workdir'], 'ipsilon.conf') + schema_init = os.path.join(os.getcwd(), 'ipsilon/install/ipsilon-upgrade-database') exe = os.path.join(os.getcwd(), 'ipsilon/ipsilon') @@ -137,11 +143,9 @@ if __name__ == '__main__': if args['cleanup']: shutil.rmtree(args['workdir']) - if not os.path.exists(args['workdir']): - conf = config(args['workdir']) - init(args['workdir']) - else: - conf = os.path.join(args['workdir'], 'ipsilon.conf') + if not os.path.exists(os.path.join(args['workdir'], 'themes')): + os.symlink(os.path.join(os.getcwd(), 'themes'), + os.path.join(args['workdir'], 'themes')) if not os.path.exists(os.path.join(args['workdir'], 'ui')): os.symlink(os.path.join(os.getcwd(), 'ui'), diff --git a/themes/Fedora/res/fedora-authn-logo-white.png b/themes/Fedora/res/fedora-authn-logo-white.png new file mode 100644 index 0000000..555fe59 Binary files /dev/null and b/themes/Fedora/res/fedora-authn-logo-white.png differ diff --git a/themes/Fedora/res/login.css b/themes/Fedora/res/login.css new file mode 100644 index 0000000..58eda39 --- /dev/null +++ b/themes/Fedora/res/login.css @@ -0,0 +1,7 @@ +html, body, .bodycontent { + height: 100vh; + max-width: 100vw; + margin: 0; + display: flex; + flex-flow: column; +} diff --git a/themes/Fedora/templates/index.html b/themes/Fedora/templates/index.html new file mode 100644 index 0000000..1385877 --- /dev/null +++ b/themes/Fedora/templates/index.html @@ -0,0 +1,7 @@ +{% extends "layout.html" %} +{% block maintitle %} +Federated Open Authentication +{% endblock %} +{% block main %} +You will be redirected to this application whenever another application requires you to authenticate. +{% endblock %} diff --git a/themes/Fedora/templates/internalerror.html b/themes/Fedora/templates/internalerror.html new file mode 100644 index 0000000..4c7f6d0 --- /dev/null +++ b/themes/Fedora/templates/internalerror.html @@ -0,0 +1,15 @@ +{% extends "layout.html" %} +{% block maintitle %} +500 - Internal Server Error +{% endblock %} +{% block main %} + {% if message: %} +

{{ message }}

+ {% else %} +

Ipsilon encountered an unexpected internal error while trying to + fulfill your request.

+ {% endif %} +

Please retry again.

+

If the error persists, contact the server administrator to resolve + the problem.

+{% endblock %} diff --git a/themes/Fedora/templates/layout.html b/themes/Fedora/templates/layout.html new file mode 100644 index 0000000..c0648a2 --- /dev/null +++ b/themes/Fedora/templates/layout.html @@ -0,0 +1,52 @@ + + + + + {{ title }} + + + + + + + + + {%- if heads %} + {%- for group, value in heads.items() %} + {%- for head in value %} + {{ head | safe }} + {%- endfor %} + {%- endfor %} + {%- endif %} + + + +
+
+
+ {% block toptext %}{% endblock %} +
+
+ {% block maintitle %}{% endblock %} +
+
+ {% block main %}{% endblock %} +
+
+ {% block after_card %}{% endblock %} +
+
+
+ + + + diff --git a/themes/Fedora/templates/login/form.html b/themes/Fedora/templates/login/form.html new file mode 100644 index 0000000..5ea6c90 --- /dev/null +++ b/themes/Fedora/templates/login/form.html @@ -0,0 +1,32 @@ +{% extends "layout.html" %} +{% block title %}Login{% endblock %} +{% block toptext %} + +
{{ login_target }} wants to use your Fedora Account System (FAS) credentials
+{% endblock %} +{% block cardwidths %}col-md-6 col-sm-8{% endblock %} +{% block maintitle %} + Log in with FAS +{% endblock %} +{% block main %} + {% if error %}

{{error}}

{% endif %} +
+ +
+ +
+ +
+ +
+
+{% endblock %} + +{% block after_card %} + +
Don't have a FAS account? Sign up now.
+ +{% endblock %} diff --git a/themes/Fedora/templates/login/index.html b/themes/Fedora/templates/login/index.html new file mode 100644 index 0000000..14ec837 --- /dev/null +++ b/themes/Fedora/templates/login/index.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} +{% block title %}Login{% endblock %} +{% block toptext %} +{{ login_target }} is asking to authenticate using Ipsilon +{% endblock %} +{% block main %} +
+ Redirecting... {{ redirect }} +
+{% endblock %} + diff --git a/themes/Fedora/templates/logout.html b/themes/Fedora/templates/logout.html new file mode 100644 index 0000000..aec445c --- /dev/null +++ b/themes/Fedora/templates/logout.html @@ -0,0 +1,13 @@ +{% extends "layout.html" %} +{% block maintitle %} +Logged out +{% endblock %} +{% block main %} +{% if user.name %} +

Something prevented a successful logout

+

You are still logged in as {{ user.fullname }}

+{% else %} +

Successfully logged out.

+

Return to Home page

+{% endif %} +{% endblock %} diff --git a/themes/Fedora/templates/notfound.html b/themes/Fedora/templates/notfound.html new file mode 100644 index 0000000..123328e --- /dev/null +++ b/themes/Fedora/templates/notfound.html @@ -0,0 +1,13 @@ +{% extends "layout.html" %} +{% block maintitle %} +404 - Not Found +{% endblock %} +{% block main %} + {% if message: %} +

{{ message }}

+ {% else %} +

This page does not exist.

+ {% endif %} +

If you think this is an error, contact the server administrator to resolve + the problem.

+{% endblock %} diff --git a/themes/Fedora/templates/openid/consent_form.html b/themes/Fedora/templates/openid/consent_form.html new file mode 100644 index 0000000..b47a0a7 --- /dev/null +++ b/themes/Fedora/templates/openid/consent_form.html @@ -0,0 +1,37 @@ +{% extends "layout.html" %} +{% block toptext %} +

{{trustroot}} requests to use the following details from your FAS Account

+{% endblock %} +{% block cardwidths %}col-md-10 col-md-offset-1{% endblock %} +{% block maintitle %}Review the authorization details{% endblock %} +{% block main %} +
+
+ + {% for entry in authz_details|dictsort %} +
+
{{ entry[0] }}
+ {%- if entry[1] is iterable and not entry[1] is string -%} +
{{ entry[1] | join(', ') }}
+ {%- else -%} +
{{ entry[1] }}
+ {%- endif -%} +
+ {% endfor %} + +
+
Remember approval
+
+
+
+
+ + +

+ +
+{% endblock %} diff --git a/themes/Fedora/templates/openid/userpage.html b/themes/Fedora/templates/openid/userpage.html new file mode 100644 index 0000000..74ae88a --- /dev/null +++ b/themes/Fedora/templates/openid/userpage.html @@ -0,0 +1,7 @@ +{% extends "layout.html" %} +{% block toptext %} +This is the OpenID page for {{username}}. +{% endblock %} +{% block main %} +This page is primarily used internally +{% endblock %} diff --git a/themes/Fedora/templates/openid/xrds.xml b/themes/Fedora/templates/openid/xrds.xml new file mode 100644 index 0000000..86b3e0f --- /dev/null +++ b/themes/Fedora/templates/openid/xrds.xml @@ -0,0 +1,16 @@ + + + + +{%- for t in types %} + {{ t }} +{%- endfor %} +{%- if uri %} + {{ uri }} +{%- endif %} +{%- if localid %} + {{ localid }} +{%- endif %} + + + diff --git a/themes/Fedora/templates/persona/provisioning.html b/themes/Fedora/templates/persona/provisioning.html new file mode 100644 index 0000000..0ced48f --- /dev/null +++ b/themes/Fedora/templates/persona/provisioning.html @@ -0,0 +1,59 @@ +{% extends "layout.html" %} +{% block toptext %} +This page is used internally +{% endblock %} +{% block main %} + + +{% endblock %} diff --git a/themes/Fedora/templates/persona/signin_result.html b/themes/Fedora/templates/persona/signin_result.html new file mode 100644 index 0000000..a2fc18b --- /dev/null +++ b/themes/Fedora/templates/persona/signin_result.html @@ -0,0 +1,19 @@ +{% extends "layout.html" %} +{% block toptext %} +This page is used internally +{% endblock %} +{% block main %} + + +{% endblock %} diff --git a/themes/Fedora/templates/unauthorized.html b/themes/Fedora/templates/unauthorized.html new file mode 100644 index 0000000..9762691 --- /dev/null +++ b/themes/Fedora/templates/unauthorized.html @@ -0,0 +1,12 @@ +{% extends "layout.html" %} +{% block maintitle %} +401 - Unauthorized +{% endblock %} +{% block main %} + {% if message: %} +

{{ message }}

+ {% else %} +

Authentication was not succesful

+ {% endif %} +

Try to login again

+{% endblock %} diff --git a/themes/openSUSE/res/login.css b/themes/openSUSE/res/login.css new file mode 100644 index 0000000..58eda39 --- /dev/null +++ b/themes/openSUSE/res/login.css @@ -0,0 +1,7 @@ +html, body, .bodycontent { + height: 100vh; + max-width: 100vw; + margin: 0; + display: flex; + flex-flow: column; +} diff --git a/themes/openSUSE/templates/index.html b/themes/openSUSE/templates/index.html new file mode 100644 index 0000000..8d7afb7 --- /dev/null +++ b/themes/openSUSE/templates/index.html @@ -0,0 +1,5 @@ +{% extends "layout.html" %} +{% block main %} +
Federated Open Authentication
+
You will be redirected to this application whenever another application requires you to authenticate.
+{% endblock %} diff --git a/themes/openSUSE/templates/internalerror.html b/themes/openSUSE/templates/internalerror.html new file mode 100644 index 0000000..6675f44 --- /dev/null +++ b/themes/openSUSE/templates/internalerror.html @@ -0,0 +1,19 @@ +{% extends "layout.html" %} +{% block toptext %} +
+ {% if message: %} + {{ message }} + {% else %} + Ipsilon encountered an unexpected internal error while trying to + fulfill your request. + {% endif %} +
+{% endblock %} +{% block main %} +
500 - Internal Server Error
+
+

Please retry again.

+

If the error persists, contact the server administrator to resolve + the problem.

+
+{% endblock %} diff --git a/themes/openSUSE/templates/layout.html b/themes/openSUSE/templates/layout.html new file mode 100644 index 0000000..26bea0b --- /dev/null +++ b/themes/openSUSE/templates/layout.html @@ -0,0 +1,48 @@ + + + + + {% block title %}{{ title }}{% endblock %} + + + + + + + + + {%- if heads %} + {%- for group, value in heads.items() %} + {%- for head in value %} + {{ head | safe }} + {%- endfor %} + {%- endfor %} + {%- endif %} + + + +
+
+ {% block toptext %}{% endblock %} +
+ {% block main %}{% endblock %} +
+ {% block after_card %}{% endblock %} +
+
+ + + + diff --git a/themes/openSUSE/templates/login/form.html b/themes/openSUSE/templates/login/form.html new file mode 100644 index 0000000..aead180 --- /dev/null +++ b/themes/openSUSE/templates/login/form.html @@ -0,0 +1,33 @@ +{% extends "layout.html" %} +{% block title %}openSUSE Login{% endblock %} +{% block toptext %} +
+ + {%- if login_target %} + {{ login_target }} + {%- else %} + Application + {%- endif %} + wants to use your openSUSE Account credentials +
+{% endblock %} +{% block cardwidths %}col-md-6 col-sm-8{% endblock %} +{% block main %} + {% if error %}

{{error}}

{% endif %} +
+
+ +
+ +
+ +
+ +
+{% endblock %} diff --git a/themes/openSUSE/templates/login/index.html b/themes/openSUSE/templates/login/index.html new file mode 100644 index 0000000..4748a93 --- /dev/null +++ b/themes/openSUSE/templates/login/index.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} +{% block title %}openSUSE Login{% endblock %} +{% block toptext %} +{{ login_target }} is asking to authenticate +{% endblock %} +{% block main %} +
+ Redirecting... {{ redirect }} +
+{% endblock %} + diff --git a/themes/openSUSE/templates/logout.html b/themes/openSUSE/templates/logout.html new file mode 100644 index 0000000..de4f383 --- /dev/null +++ b/themes/openSUSE/templates/logout.html @@ -0,0 +1,13 @@ +{% extends "layout.html" %} +{% block main %} +
Logged out
+
+ {% if user.name %} +

Something prevented a successful logout

+

You are still logged in as {{ user.fullname }}

+ {% else %} +

Successfully logged out.

+

Return to Home page

+ {% endif %} +
+{% endblock %} diff --git a/themes/openSUSE/templates/notfound.html b/themes/openSUSE/templates/notfound.html new file mode 100644 index 0000000..676692c --- /dev/null +++ b/themes/openSUSE/templates/notfound.html @@ -0,0 +1,17 @@ +{% extends "layout.html" %} +{% block toptext %} +
+ {% if message: %} + {{ message }} + {% else %} + This page does not exist. + {% endif %} +
+{% endblock %} +{% block main %} +
404 - Not Found
+
+

If you think this is an error, contact the server administrator to resolve + the problem.

+
+{% endblock %} diff --git a/themes/openSUSE/templates/openid/consent_form.html b/themes/openSUSE/templates/openid/consent_form.html new file mode 100644 index 0000000..c10934f --- /dev/null +++ b/themes/openSUSE/templates/openid/consent_form.html @@ -0,0 +1,41 @@ +{% extends "layout.html" %} +{% block toptext %} +
+ + {{trustroot}} + requests to use the following details from your openSUSE Account +
+{% endblock %} +{% block cardwidths %}col-md-10{% endblock %} +{% block main %} +
+
    + {% for entry in authz_details|dictsort %} +
  • + {{ entry[0] }} + {%- if entry[1] is iterable and not entry[1] is string -%} + {{ entry[1] | join(', ') }} + {%- else -%} + {{ entry[1] }} + {%- endif -%} +
  • + {% endfor %} + +
  • + Remember approval + + + +
  • +
+ + +
+{% endblock %} diff --git a/themes/openSUSE/templates/openid/userpage.html b/themes/openSUSE/templates/openid/userpage.html new file mode 100644 index 0000000..c261b68 --- /dev/null +++ b/themes/openSUSE/templates/openid/userpage.html @@ -0,0 +1,5 @@ +{% extends "layout.html" %} +{% block main %} +
OpenID page for {{username}}
+
This page is primarily used internally.
+{% endblock %} diff --git a/themes/openSUSE/templates/openid/xrds.xml b/themes/openSUSE/templates/openid/xrds.xml new file mode 100644 index 0000000..86b3e0f --- /dev/null +++ b/themes/openSUSE/templates/openid/xrds.xml @@ -0,0 +1,16 @@ + + + + +{%- for t in types %} + {{ t }} +{%- endfor %} +{%- if uri %} + {{ uri }} +{%- endif %} +{%- if localid %} + {{ localid }} +{%- endif %} + + + diff --git a/themes/openSUSE/templates/persona/provisioning.html b/themes/openSUSE/templates/persona/provisioning.html new file mode 100644 index 0000000..0ced48f --- /dev/null +++ b/themes/openSUSE/templates/persona/provisioning.html @@ -0,0 +1,59 @@ +{% extends "layout.html" %} +{% block toptext %} +This page is used internally +{% endblock %} +{% block main %} + + +{% endblock %} diff --git a/themes/openSUSE/templates/persona/signin_result.html b/themes/openSUSE/templates/persona/signin_result.html new file mode 100644 index 0000000..a2fc18b --- /dev/null +++ b/themes/openSUSE/templates/persona/signin_result.html @@ -0,0 +1,19 @@ +{% extends "layout.html" %} +{% block toptext %} +This page is used internally +{% endblock %} +{% block main %} + + +{% endblock %} diff --git a/themes/openSUSE/templates/unauthorized.html b/themes/openSUSE/templates/unauthorized.html new file mode 100644 index 0000000..ae27f1d --- /dev/null +++ b/themes/openSUSE/templates/unauthorized.html @@ -0,0 +1,16 @@ +{% extends "layout.html" %} +{% block toptext %} +
+ {% if message: %} + {{ message }} + {% else %} + Authentication was not succesful + {% endif %} +
+{% endblock %} +{% block main %} +
401 - Unauthorized
+ +{% endblock %}