From e5d3af1b5154dee12605b2fffb92175d91257fae Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Sun, 29 Oct 2017 19:15:29 +1100 Subject: [PATCH] Make redirect_uri verification optional because many IndieAuth clients don't implement it - show a stylish icon to convey whether the client was verified --- lemonauth/static/lemonauth/css/indie.styl | 11 +++++++++++ lemonauth/templates/lemonauth/indie.html | 19 ++++++++++++++++++- lemonauth/views/indie.py | 14 ++++++++------ lemoncurry/static/lemoncurry/css/theme.js | 9 ++++++++- lemoncurry/static/tippy.js | 1 + lemoncurry/templates/lemoncurry/layout.html | 5 +++++ package.json | 3 ++- yarn.lock | 10 ++++++++++ 8 files changed, 63 insertions(+), 9 deletions(-) create mode 120000 lemoncurry/static/tippy.js diff --git a/lemonauth/static/lemonauth/css/indie.styl b/lemonauth/static/lemonauth/css/indie.styl index ad7a699..ee7a853 100644 --- a/lemonauth/static/lemonauth/css/indie.styl +++ b/lemonauth/static/lemonauth/css/indie.styl @@ -2,3 +2,14 @@ img height 2em margin-right .5em +.tippy-tooltip + &.success-theme + color $base0B + background-color $base03 + &.warning-theme + color $base0A + background-color $base03 +.verified-success + color $base0B +.verified-warning + color $base0A diff --git a/lemonauth/templates/lemonauth/indie.html b/lemonauth/templates/lemonauth/indie.html index 1f03a0a..d6a769d 100644 --- a/lemonauth/templates/lemonauth/indie.html +++ b/lemonauth/templates/lemonauth/indie.html @@ -1,5 +1,5 @@ {% extends 'lemoncurry/layout.html' %} -{% load static %} +{% load markdown static %} {% block styles %} @@ -13,6 +13,11 @@ sign in to {% if app %}{{ app.name | first }}{% endif %} {% if app %}({% endif %}{{ params.client_id }}{% if app %}){% endif %}? + {% if verified %} + + {% else %} + + {% endif %}
@@ -35,4 +40,16 @@
+ + + +{% endblock %} +{% block foot %} + {% endblock %} diff --git a/lemonauth/views/indie.py b/lemonauth/views/indie.py index 2dff96d..acb5a3e 100644 --- a/lemonauth/views/indie.py +++ b/lemonauth/views/indie.py @@ -58,18 +58,20 @@ class IndieView(TemplateView): rels = (client.to_dict()['rel-urls'] .get(params['redirect_uri'], {}) .get('rels', ())) - if 'redirect_uri' not in rels: - return HttpResponseBadRequest( - 'your redirect_uri is not published on your client_id page', - content_type='text/plain' - ) + verified = 'redirect_uri' in rels try: app = client.to_dict(filter_by_type='h-x-app')[0]['properties'] except IndexError: app = None - return {'app': app, 'me': me, 'params': params, 'title': 'indieauth'} + return { + 'app': app, + 'me': me, + 'verified': verified, + 'params': params, + 'title': 'indieauth', + } def post(self, request): post = request.POST.dict() diff --git a/lemoncurry/static/lemoncurry/css/theme.js b/lemoncurry/static/lemoncurry/css/theme.js index 47d0b61..06e806f 100644 --- a/lemoncurry/static/lemoncurry/css/theme.js +++ b/lemoncurry/static/lemoncurry/css/theme.js @@ -11,8 +11,15 @@ module.exports = function() { return function(style) { for (let i = 0; i < 16; i++) { const key = 'base0' + i.toString(16).toUpperCase(); + const hex = theme[key]; + const colour = new stylus.nodes.RGBA( + parseInt(hex.substr(0, 2), 16), + parseInt(hex.substr(2, 2), 16), + parseInt(hex.substr(4, 2), 16), + 1 + ); - style.define('$' + key, new stylus.nodes.Literal('#' + theme[key])); + style.define('$' + key, colour); } }; }; diff --git a/lemoncurry/static/tippy.js b/lemoncurry/static/tippy.js new file mode 120000 index 0000000..3bb7734 --- /dev/null +++ b/lemoncurry/static/tippy.js @@ -0,0 +1 @@ +../../node_modules/tippy.js/dist \ No newline at end of file diff --git a/lemoncurry/templates/lemoncurry/layout.html b/lemoncurry/templates/lemoncurry/layout.html index 9b8d350..021dea9 100644 --- a/lemoncurry/templates/lemoncurry/layout.html +++ b/lemoncurry/templates/lemoncurry/layout.html @@ -24,6 +24,7 @@ integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous" /> {% compress css %} + {% block styles %}{% endblock %} {% endcompress %} @@ -64,5 +65,9 @@ integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"> + {% compress js %} + + {% block foot %}{% endblock %} + {% endcompress %} diff --git a/package.json b/package.json index 4273ab0..c6d2a84 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "stylus": "^0.54.5" }, "dependencies": { - "openwebicons": "^1.4.3" + "openwebicons": "^1.4.3", + "tippy.js": "^1.4.1" } } diff --git a/yarn.lock b/yarn.lock index 448e842..6a327dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -108,6 +108,10 @@ path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" +popper.js@^1.12.4: + version "1.12.6" + resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.12.6.tgz#91e12a97b07815258b76915d64044e8ac053d426" + sax@0.5.x: version "0.5.8" resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1" @@ -133,6 +137,12 @@ stylus@^0.54.5: sax "0.5.x" source-map "0.1.x" +tippy.js@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-1.4.1.tgz#a20831a53e40566825c0b3c6ad72afc30e97c6f5" + dependencies: + popper.js "^1.12.4" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"