-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved session cookie security & first implementation of api
- Loading branch information
Showing
17 changed files
with
359 additions
and
72 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
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
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
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,3 @@ | ||
def create_module(app, **kwargs): | ||
from .api_routes import api_blueprint | ||
app.register_blueprint(api_blueprint) |
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,82 @@ | ||
import json | ||
import os | ||
import sys | ||
import requests | ||
from flask import url_for, session, request, Blueprint, current_app | ||
from flask import render_template, redirect, jsonify | ||
from flask_session import Session | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) | ||
import common.functions as functions | ||
from common.db_IO import Connection | ||
from ..utils import * | ||
|
||
|
||
api_blueprint = Blueprint( | ||
'api', | ||
__name__ | ||
) | ||
|
||
|
||
@api_blueprint.route('/api/v1.0/get/consensus_classification', methods=['GET']) | ||
@accept_token | ||
def consensus_classification(): | ||
|
||
conn = Connection(roles = ["read_only"]) | ||
|
||
variant_id = request.args.get('variant_id') | ||
if variant_id is None: | ||
chrom = request.args.get('chrom') | ||
pos = request.args.get('pos') | ||
ref = request.args.get('ref') | ||
alt = request.args.get('alt') | ||
|
||
variant_id = conn.get_variant_id(chrom, pos, ref, alt) | ||
|
||
if variant_id is None: | ||
conn.close() | ||
abort(404, "Requested variant does not exist or missing variant information") | ||
|
||
variant = conn.get_variant(variant_id, include_annotations = False, include_consensus = True, include_user_classifications = False, include_heredicare_classifications=False, include_automatic_classification=False, include_clinvar=False, include_consequences=False, include_assays=False, include_literature=False, include_external_ids=False) | ||
conn.close() | ||
|
||
|
||
v_res = prepare_variant(variant) | ||
mrcc = variant.get_recent_consensus_classification() | ||
mrcc_res = prepare_classification(mrcc) | ||
|
||
result = { | ||
"variant": v_res, | ||
"classification": mrcc_res | ||
} | ||
|
||
return jsonify(result) | ||
|
||
|
||
def prepare_variant(variant): | ||
result = { | ||
"id": variant.id, | ||
"chrom": variant.chrom, | ||
"pos": variant.pos, | ||
"ref": variant.ref, | ||
"alt": variant.alt, | ||
"variant_type": variant.variant_type, | ||
"hidden": variant.is_hidden | ||
} | ||
return result | ||
|
||
def prepare_classification(classification): | ||
result = { | ||
"comment": classification.comment, | ||
"date": classification.date, | ||
"literature": classification.literature, | ||
"scheme": {"name": classification.scheme.display_name, "reference": classification.scheme.reference}, | ||
"criteria": classification.scheme.criteria, | ||
"class_by_scheme": classification.scheme.selected_class, | ||
"selected_class": classification.selected_class, | ||
"classification_type": classification.type | ||
} | ||
return result | ||
|
||
|
||
|
||
|
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
33 changes: 33 additions & 0 deletions
33
src/frontend_celery/webapp/templates/auth/generate_api_key.html
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,33 @@ | ||
{% extends 'base.html' %} | ||
|
||
|
||
{% block content %} | ||
|
||
<div class="container"> | ||
|
||
|
||
<h1> {% block title %} Edit your personal information {% endblock %} </h1> | ||
|
||
|
||
<div class="alert alert-danger"> | ||
Copy the key somewhere safe it is only shown <strong>once on this page</strong>! <br> | ||
If you lose your API key you have to generate a new one. | ||
</div> | ||
<div class="d-flex justify-content-center"> | ||
<div class="width_very_large alert alert-secondary text_align_center"> | ||
{{api_key}} | ||
</div> | ||
</div> | ||
|
||
<div> | ||
Documentation on how to access the HerediVar API can be found <a href="{{url_for('main.documentation')}}">here</a> | ||
</div> | ||
|
||
|
||
</div> | ||
|
||
|
||
{% endblock %} | ||
|
||
{% block special_scripts %} | ||
{% endblock %} |
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
Oops, something went wrong.