コード例 #1
0
ファイル: services.py プロジェクト: mydata-sdk/mydata-sdk-1.x
__maintainer__ = "Jani Yli-Kantola"
__contact__ = "https://github.com/mydata-sdk/mydata-stack-1.x"
__status__ = "Development"
"""

# Import dependencies
import json
import os
import sqlite3
from jwcrypto import jwk, jws

# create logger with 'spam_application'
from app.mod_blackbox.helpers import append_description_to_exception, KeyNotFoundError, get_custom_logger, jws_header_fix, \
    get_current_line_no

logger = get_custom_logger('mod_blackbox_services')

DELIMITTER = '/'
DATABASE = os.path.dirname(
    os.path.abspath(__file__)) + DELIMITTER + 'blackbox.sqlite'
#DATABASE = 'blackbox.sqlite'


def log_dict_as_json(data=None, pretty=0, lineno=None):
    """
    Writes dictionary to log entry as JSON

    :param data: Dictionary to log
    :param pretty: 0 or 1 defining if JSON should be pretty printed to log, Defaults to 0
    """
    if data is None:
コード例 #2
0
                "not_after": "String",
                "subject_id": "String",
                "cr_id": "325843db-5dc5-4005-a206-5f1fe8c76555"
            },
            "ki_cr": {},
            "role_specific_part": {
                "auth_token_issuer_key": "Get this from somewhere!",
                "role": "String: source",
                "resource_set_description": "String (RDF)"
            },
            "extensions": {}
        }
    }
}

logger = get_custom_logger('mod_blackbox_controllers')


def store_jwk(account_id=None, account_kid=None, account_key=None):
    """
    Stores JWK to key storage

    :param account_id: User account ID
    :param account_kid: Key ID
    :param account_key: JWK
    :return:
    """
    if account_id is None:
        raise AttributeError("Provide account_id as parameter")
    if account_kid is None:
        raise AttributeError("Provide account_kid as parameter")
コード例 #3
0
ファイル: controllers.py プロジェクト: jylika/mydata-sdk
__contact__ = "https://github.com/HIIT/mydata-stack"
__status__ = "Development"
__date__ = 26.5.2016
"""
import base64
from functools import wraps
from uuid import uuid4

from flask import request

from app import ApiError
from app.mod_api_auth.services import get_sqlite_connection, get_sqlite_cursor, store_api_key_to_db, get_api_key, \
    get_account_id
from app.mod_blackbox.helpers import append_description_to_exception, get_custom_logger

logger = get_custom_logger('mod_api_auth_controllers')


def store_api_key(account_id=None, account_api_key=None):
    """
    Stores API key

    :param account_id: User account ID
    :param account_api_key: API Key
    :return:
    """
    if account_id is None:
        raise AttributeError("Provide account_id as parameter")
    if account_api_key is None:
        raise AttributeError("Provide account_api_key as parameter")