Example #1
0
def check(request: HttpRequest):
    s_h = settings.SECURE_PROXY_SSL_HEADER
    a_h = settings.FLOOR_AUTHENTICATION_HEADER
    # noinspection PyArgumentList
    gpg_valid = False
    for key in GPG.list_keys(False):
        if key['keyid'] == settings.GNUPG_KEYID:
            gpg_valid = True
    import moneta.defaults

    default_conf_path = moneta.defaults.__file__
    if default_conf_path.endswith('.pyc'):
        default_conf_path = default_conf_path[:-1]

    template_values = {
        'media_root': settings.MEDIA_ROOT, 'media_url': settings.MEDIA_URL,
        'static_root': settings.STATIC_ROOT, 'static_url': settings.STATIC_URL,
        'debug': settings.DEBUG, 'use_x_forwared_host': settings.USE_X_FORWARDED_HOST,
        'secure_proxy_ssl_header_name': s_h[0][5:],
        'secure_proxy_ssl_header_value': s_h[1],
        'authentication_header': a_h,
        'has_authentication_header': request.META.get(a_h, '') == request.user.username,
        'has_secure_proxy_ssl_header': request.META.get(s_h[0], '') == s_h[1],
        'host': request.get_host().rpartition(':')[0],
        'has_allowed_host': request.get_host() in settings.ALLOWED_HOSTS,
        'gpg_valid': gpg_valid, 'gpg_available': GPG.list_keys(False),
    }

    return render_to_response('moneta/help.html', template_values, RequestContext(request))
Example #2
0
def check(request: HttpRequest):
    s_h = settings.SECURE_PROXY_SSL_HEADER
    a_h = settings.FLOOR_AUTHENTICATION_HEADER
    # noinspection PyArgumentList
    gpg_valid = False
    for key in GPG.list_keys(False):
        if key['keyid'] == settings.GNUPG_KEYID:
            gpg_valid = True
    import moneta.defaults

    default_conf_path = moneta.defaults.__file__
    if default_conf_path.endswith('.pyc'):
        default_conf_path = default_conf_path[:-1]

    template_values = {
        'media_root': settings.MEDIA_ROOT,
        'media_url': settings.MEDIA_URL,
        'static_root': settings.STATIC_ROOT,
        'static_url': settings.STATIC_URL,
        'debug': settings.DEBUG,
        'use_x_forwared_host': settings.USE_X_FORWARDED_HOST,
        'secure_proxy_ssl_header_name': s_h[0][5:],
        'secure_proxy_ssl_header_value': s_h[1],
        'authentication_header': a_h,
        'has_authentication_header':
        request.META.get(a_h, '') == request.user.username,
        'has_secure_proxy_ssl_header': request.META.get(s_h[0], '') == s_h[1],
        'host': request.get_host().rpartition(':')[0],
        'has_allowed_host': request.get_host() in settings.ALLOWED_HOSTS,
        'gpg_valid': gpg_valid,
        'gpg_available': GPG.list_keys(False),
    }

    return render_to_response('moneta/help.html', template_values,
                              RequestContext(request))
Example #3
0
 def handle(self, *args, **options):
     command = options['gpg_command']
     if command not in ('generate', 'show', 'export'):
         raise CommandError('Usage: gpg_gen <generate|show|export>')
     if command == 'generate':
         if options['absent'] and len(GPG.list_keys(False)) > 0:
             return
         input_data = GPG.gen_key_input(key_type=options['type'],
                                        key_length=int(options['length']),
                                        name_real=options['name'],
                                        name_comment=options['comment'],
                                        name_email=options['email'],
                                        expire_date=options['years'])
         key = GPG.gen_key(input_data)
         print("Fingerprint", key)
     elif command == 'show':
         if options['onlyid']:
             for key in GPG.list_keys(False):
                 print("{keyid}".format(**key))
         else:
             print("Available keys:")
             for key in GPG.list_keys(False):
                 print(
                     "id (GNUPG_KEYID) : {keyid}, longueur : {length}, empreinte : {fingerprint}"
                     .format(**key))
     elif command == 'export':
         print(GPG.export_keys(settings.GNUPG_KEYID))
Example #4
0
 def handle(self, *args, **options):
     command = options['gpg_command']
     if command not in ('generate', 'show', 'export'):
         raise CommandError('Usage: gpg_gen <generate|show|export>')
     if command == 'generate':
         if options['absent'] and len(GPG.list_keys(False)) > 0:
             return
         input_data = GPG.gen_key_input(key_type=options['type'], key_length=int(options['length']),
                                        name_real=options['name'], name_comment=options['comment'],
                                        name_email=options['email'],
                                        expire_date=options['years'])
         key = GPG.gen_key(input_data)
         print("Fingerprint", key)
     elif command == 'show':
         if options['onlyid']:
             for key in GPG.list_keys(False):
                 print("{keyid}".format(**key))
         else:
             print("Available keys:")
             for key in GPG.list_keys(False):
                 print("id (GNUPG_KEYID) : {keyid}, longueur : {length}, empreinte : {fingerprint}".format(**key))
     elif command == 'export':
         print(GPG.export_keys(settings.GNUPG_KEYID))