コード例 #1
0
ファイル: check_token.py プロジェクト: techspecs/jet-bridge
def check_token_command(api_url):
    try:
        if not is_resource_token_activated(settings.PROJECT, settings.TOKEN):
            logger.warning('[!] Your resource token is not activated')
            logger.warning('[!] Project: {}'.format(settings.PROJECT))
            logger.warning('[!] Token: {}'.format(settings.TOKEN))

            if settings.DATABASE_ENGINE != 'none' and settings.AUTO_OPEN_REGISTER and api_url.startswith(
                    'http'):
                register_url = '{}register/'.format(api_url)

                if settings.TOKEN:
                    register_url += '?token={}'.format(settings.TOKEN)

                if webbrowser.open(register_url):
                    logger.warning(
                        '[!] Activation page was opened in your browser - {}'.
                        format(register_url))
            else:
                register_url = '{}register/'.format(api_url)
                logger.warning(
                    '[!] Go to {} to activate it'.format(register_url))
    except RequestException:
        logger.error('[!] Can\'t connect to Jet Admin API')
        logger.error('[!] Token verification failed')
コード例 #2
0
def project_auth(token, permission=None):
    if not settings.TOKEN:
        return {'result': False}

    url = api_method_url('project_auth/')
    data = {'project_token': settings.TOKEN, 'token': token}
    headers = {
        'User-Agent':
        '{} v{}'.format(configuration.get_type(), configuration.get_version())
    }

    if permission:
        data.update(permission)

    r = requests.request('POST', url, data=data, headers=headers)
    success = 200 <= r.status_code < 300

    if not success:
        logger.error('Project Auth request error', r.status_code, r.reason)
        return {'result': False}

    result = r.json()

    if result.get('access_disabled'):
        return {'result': False, 'warning': result.get('warning')}

    return {'result': True, 'warning': result.get('warning')}
コード例 #3
0
ファイル: check_token.py プロジェクト: preetgur/main
def check_token_command(api_url):
    try:
        if not is_token_activated():
            logger.warning('[!] Your server token is not activated')
            logger.warning('[!] Token: {}'.format(settings.TOKEN))

            if settings.AUTO_OPEN_REGISTER and api_url.startswith('http'):
                register_url = '{}register/?token={}'.format(
                    api_url, settings.TOKEN)

                if webbrowser.open(register_url):
                    logger.warning(
                        '[!] Activation page was opened in your browser - {}'.
                        format(register_url))
            else:
                register_url = '{}register/'.format(api_url)
                logger.warning(
                    '[!] Go to {} to activate it'.format(register_url))
    except RequestException:
        logger.error('[!] Can\'t connect to Jet Admin API')
        logger.error('[!] Token verification failed')
コード例 #4
0
WEB_BASE_URL = options.web_base_url
API_BASE_URL = options.api_base_url

MEDIA_STORAGE = options.media_storage
MEDIA_ROOT = options.media_root
MEDIA_BASE_URL = options.media_base_url

DATABASE_ENGINE = options.database_engine
DATABASE_HOST = options.database_host
DATABASE_PORT = options.database_port
DATABASE_USER = options.database_user
DATABASE_PASSWORD = options.database_password
DATABASE_NAME = options.database_name
DATABASE_EXTRA = options.database_extra
DATABASE_ONLY = options.database_only.split(
    ',') if options.database_only else None
DATABASE_EXCEPT = options.database_except.split(
    ',') if options.database_except else None
DATABASE_SCHEMA = options.database_schema

try:
    SSO_APPLICATIONS = json.loads(options.sso_applications)
except Exception as e:
    logger.error('SSO_APPLICATIONS parsing failed', exc_info=e)
    SSO_APPLICATIONS = {}

ALLOW_ORIGIN = options.allow_origin

POSSIBLE_HOST = os.environ.get('POSSIBLE_HOST')