-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
505 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Read up on pre-commit | ||
# https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/ | ||
|
||
repos: | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: fix-encoding-pragma | ||
- id: no-commit-to-branch | ||
branch: master | ||
- id: flake8 | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: 18.9b0 | ||
hooks: | ||
- id: black | ||
language_version: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
# Flask-Beet Extension | ||
|
||
[![build status](https://secure.travis-ci.org/blockchainprojects/flask_beet.png?branch=master)](https://travis-ci.org/#!/blockchainprojects/flask_beet) | ||
|
||
Flask-beet is a Flask extension for allow login (flask-security/flask-login) | ||
via signed messages and the [Beet app](http://get-beet.io). | ||
|
||
The login requires a unique string to be signed and submitted. The signature is | ||
created with the memo key of an account on the BitShares Blockchain, | ||
|
||
## Installation | ||
|
||
Install the extension with one of the following commands: | ||
|
||
$ pip install flask_beet | ||
|
||
## Usage | ||
|
||
Using SeaSurf is fairly straightforward. Begin by importing the extension and | ||
then passing your application object back to the extension, like this: | ||
|
||
from flask import Flask | ||
from flask_beet import Beet | ||
app = Flask(__name__) | ||
beet = Beet(app) | ||
|
||
## Documentation | ||
|
||
The Sphinx-compiled documentation is available here: [flask-beet.rtfd.io](http://flask-beet.rtfd.io/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ flask_beet | |
:maxdepth: 6 | ||
|
||
flask_beet | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
bitshares | ||
|
||
# Flask | ||
Flask | ||
Flask-Login | ||
Flask-Security | ||
Flask-Session | ||
|
||
# Tooling | ||
SQLAlchemy | ||
WTForms | ||
Werkzeug | ||
uuid | ||
blinker | ||
|
||
# tests | ||
pytest | ||
pytest-mock | ||
coverage | ||
mock | ||
flask-testing | ||
flask-sqlalchemy | ||
|
||
# template | ||
Flask-Sphinx-Themes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
tests package | ||
============= | ||
|
||
Submodules | ||
---------- | ||
|
||
.. toctree:: | ||
|
||
tests.test_beet | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: tests | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests.test\_beet module | ||
======================= | ||
|
||
.. automodule:: tests.test_beet | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{%- with messages = get_flashed_messages(with_categories=true) -%} | ||
{% if messages %} | ||
{% for category, message in messages %} | ||
{% if category == "error" %} | ||
<div class="ui icon error message"> | ||
<i class="warning icon"></i> | ||
<div class="content"> | ||
<div class="header"> | ||
An error occured! | ||
</div> | ||
{% else %} | ||
<div class="ui icon info message"> | ||
<i class="info icon"></i> | ||
<div class="content"> | ||
<div class="header"> | ||
Notice | ||
</div> | ||
{% endif %} | ||
{{ message }} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
{%- endwith %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<script type="text/javascript" src="{{url_for('.beet_js')}}"></script> | ||
<script type="text/javascript"> | ||
function connectBeet() { | ||
beet.get("{{app.config.get('BEET_APP_NAME')}}", "BTS").then(beet => { | ||
var payload = "{{signed_message_payload}}"; | ||
beet.BTS.signMessage(payload).then(res => { | ||
document.getElementById("signedMessage").value = JSON.stringify(res); | ||
console.log(document.getElementById("signedMessage").value) | ||
document.getElementById("beetLogin").submit(); | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
} | ||
</script> | ||
|
||
<form class="ui form" id="beetLogin" method="POST"> | ||
{{ loginForm.csrf_token }} | ||
<button class="ui basic button" value="Beet" onclick="connectBeet()" type="button"> | ||
<h2 class="ui header"><img class="image icon" src="{{url_for('.beet_logo')}}"/> | ||
<div class="content">Login | ||
<div class="sub header">with Beet</div> | ||
</div> | ||
</h2> | ||
</button> | ||
<div class="ui accordion"> | ||
<div class="title"><i class="dropdown icon"></i>I don't have Beet installed!</div> | ||
<div class="{% if loginForm.message.errors %}active {% endif %}content"> | ||
<p>Please sign the following message</p> | ||
<p class="text centered ui label">{{signed_message_payload}}</p> | ||
<div class="field {% if loginForm.message.errors %} error {% endif %}"> | ||
<label>Signed Messaged</label> | ||
<div class="ui input"> | ||
{{ loginForm.message()|safe }} | ||
</div> | ||
{% if loginForm.message.errors %} | ||
<div class="ui red message"> | ||
<div class="header">Error</div> | ||
<div class="ui list"> | ||
{% for error in loginForm.message.errors %} | ||
<div class="item">{{error}}</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{{ loginForm.submit()|safe }} | ||
</div> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% block content -%} | ||
{%- endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pytest | ||
pytest-mock | ||
coverage | ||
mock | ||
flask-testing | ||
flask-sqlalchemy |
Oops, something went wrong.