Esempio n. 1
0
def hue(request):
    apps = appmanager.get_apps_dict(request.user)

    return render(
        'hue.mako', request, {
            'apps':
            apps,
            'interpreters':
            get_ordered_interpreters(request.user),
            'is_s3_enabled':
            is_s3_enabled() and has_s3_access(request.user),
            'is_ldap_setup':
            'desktop.auth.backend.LdapBackend'
            in desktop.conf.AUTH.BACKEND.get(),
            'leaflet': {
                'layer': desktop.conf.LEAFLET_TILE_LAYER.get(),
                'attribution':
                desktop.conf.LEAFLET_TILE_LAYER_ATTRIBUTION.get()
            },
            'is_demo':
            desktop.conf.DEMO_ENABLED.get(),
            'banner_message':
            get_banner_message(request),
            'cluster_config':
            ClusterConfig(request.user),
            'user_preferences':
            dict((x.key, x.value)
                 for x in UserPreferences.objects.filter(user=request.user))
        })
Esempio n. 2
0
def hue(request):
    apps = appmanager.get_apps_dict(request.user)

    return render(
        'hue.mako', request, {
            'apps':
            apps,
            'tours_and_tutorials':
            Settings.get_settings().tours_and_tutorials,
            'interpreters':
            get_ordered_interpreters(request.user),
            'is_s3_enabled':
            is_s3_enabled() and has_s3_access(request.user),
            'is_ldap_setup':
            'desktop.auth.backend.LdapBackend'
            in desktop.conf.AUTH.BACKEND.get(),
            'leaflet': {
                'layer': desktop.conf.LEAFLET_TILE_LAYER.get(),
                'attribution':
                desktop.conf.LEAFLET_TILE_LAYER_ATTRIBUTION.get()
            },
            'is_demo':
            desktop.conf.DEMO_ENABLED.get(),
            'banner_message':
            get_banner_message(request),
            'cluster_config':
            ClusterConfig(request.user)
        })
Esempio n. 3
0
File: api2.py Progetto: tyluan/hue
def get_config(request):
  cluster_config = ClusterConfig(request.user)
  app_config = cluster_config.get_apps()

  return JsonResponse({
    'status': 0,
    'app_config': app_config,
    'main_button_action': cluster_config.main_quick_action,
    'button_actions': [
      app for app in [
        app_config.get('editor'),
        app_config.get('dashboard'),
        app_config.get('scheduler')
      ] if app is not None
    ],
  })
Esempio n. 4
0
def get_config(request):
    app_config = ClusterConfig(request.user).get_apps()

    return JsonResponse({
        'status':
        0,
        'app_config':
        app_config,
        'main_button_action':
        app_config['editor']['interpreters'][1],
        'button_actions': [
            app_config['editor'], app_config['dashboard'],
            app_config['scheduler']
        ],
    })
Esempio n. 5
0
def test_app_permissions():
  USERNAME = '******'
  GROUPNAME = 'impala_only'
  resets = [
    desktop.conf.REDIRECT_WHITELIST.set_for_testing('^\/.*$,^http:\/\/testserver\/.*$'),
    HAS_SQL_ENABLED.set_for_testing(False)
  ]

  try:
    c = make_logged_in_client(USERNAME, groupname=GROUPNAME, recreate=True, is_superuser=False)
    user = rewrite_user(User.objects.get(username=USERNAME))

    # Reset all perms
    GroupPermission.objects.filter(group__name=GROUPNAME).delete()

    def check_app(status_code, app_name):
      if app_name in DESKTOP_APPS:
        assert_equal(
            status_code,
            c.get('/' + app_name, follow=True).status_code,
            'status_code=%s app_name=%s' % (status_code, app_name))

    # Access to nothing
    check_app(401, 'beeswax')
    check_app(401, 'impala')
    check_app(401, 'hbase')
    check_app(401, 'pig')
    check_app(401, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_false('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('browser' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('dashboard' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('sdkapps' in apps, apps)

    # Add access to beeswax
    grant_access(USERNAME, GROUPNAME, "beeswax")
    check_app(200, 'beeswax')
    check_app(401, 'impala')
    check_app(401, 'hbase')
    check_app(401, 'pig')
    check_app(401, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_true('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('browser' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('dashboard' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('sdkapps' in apps, apps)

    # Add access to hbase
    grant_access(USERNAME, GROUPNAME, "hbase")
    check_app(200, 'beeswax')
    check_app(401, 'impala')
    check_app(200, 'hbase')
    check_app(401, 'pig')
    check_app(401, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_true('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_true('browser' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_true('hbase' in apps['browser']['interpreter_names'], apps['browser'])
    assert_false('dashboard' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('sdkapps' in apps, apps)

    # Reset all perms
    GroupPermission.objects.filter(group__name=GROUPNAME).delete()
    check_app(401, 'beeswax')
    check_app(401, 'impala')
    check_app(401, 'hbase')
    check_app(401, 'pig')
    check_app(401, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_false('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('browser' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('dashboard' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('sdkapps' in apps, apps)

    # Test only impala perm
    grant_access(USERNAME, GROUPNAME, "impala")
    check_app(401, 'beeswax')
    check_app(200, 'impala')
    check_app(401, 'hbase')
    check_app(401, 'pig')
    check_app(401, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_false('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_true('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_false('browser' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('dashboard' in apps, apps)
    assert_false('scheduler' in apps, apps)
    assert_false('sdkapps' in apps, apps)

    # Oozie Editor and Browser
    grant_access(USERNAME, GROUPNAME, "oozie")
    check_app(401, 'beeswax')
    check_app(200, 'impala')
    check_app(401, 'hbase')
    check_app(401, 'pig')
    check_app(200, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_true('scheduler' in apps, apps)
    assert_false('browser' in apps, apps) # Actually should be true, but logic not implemented

    grant_access(USERNAME, GROUPNAME, "pig")
    check_app(401, 'beeswax')
    check_app(200, 'impala')
    check_app(401, 'hbase')
    check_app(200, 'pig')
    check_app(200, 'oozie')

    apps = ClusterConfig(user=user).get_apps()
    assert_false('hive' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_true('impala' in apps.get('editor', {}).get('interpreter_names', []), apps)
    assert_true('pig' in apps.get('editor', {}).get('interpreter_names', []), apps)
  finally:
    for f in resets:
      f()