Example #1
0
 def get(self, request, name=None):
     '''
         Lists all existing modules if not pk. If pk show the module given.
     '''
     if name is None: # show all
         data = {'methods': []}
         for k in METHODS.keys():
             desc = METHODS.get(k).DESCRIPTION
             config = METHODS.get(k).CONFIG
             pipe = VALID_PIPELINES
             meta = VALID_FIELDS
             data['methods'].append(
                     [k, {
                             'description': desc,
                             'auth_method_config': config,
                             'pipelines': pipe,
                             'extra_fields': meta,
                         }]
             )
     elif name in METHODS.keys(): # show module
         desc = METHODS.get(name).DESCRIPTION
         config = METHODS.get(name).CONFIG
         pipe = VALID_PIPELINES
         meta = VALID_FIELDS
         data = {
                 name: {
                     'description': desc,
                     'auth_method_config': config,
                     'pipelines': pipe,
                     'extra_fields': meta,
                 }
         }
     return json_response(data)
Example #2
0
    def get(self, request, name=None):
        '''
            Lists all existing modules if not pk. If pk show the module given.
        '''
        if name is None:  # show all
            data = {'methods': []}
            for k in METHODS.keys():
                desc = METHODS.get(k).DESCRIPTION
                config = METHODS.get(k).CONFIG
                pipe = VALID_PIPELINES
                meta = VALID_FIELDS
                data['methods'].append([
                    k, {
                        'description': desc,
                        'auth_method_config': config,
                        'pipelines': pipe,
                        'extra_fields': meta,
                    }
                ])
        elif name in METHODS.keys():  # show module
            desc = METHODS.get(name).DESCRIPTION
            config = METHODS.get(name).CONFIG
            pipe = VALID_PIPELINES
            meta = VALID_FIELDS
            data = {
                name: {
                    'description': desc,
                    'auth_method_config': config,
                    'pipelines': pipe,
                    'extra_fields': meta,
                }
            }

        jsondata = json.dumps(data)
        return HttpResponse(jsondata, content_type='application/json')
Example #3
0
 def get_form(self, request, obj=None, **kwargs):
     choices = []
     for k in METHODS.keys():
         choices.append((k, k + ': ' + METHODS.get(k).DESCRIPTION))
     AuthEventAdminForm.Meta.widgets['auth_method'] = forms.Select(attrs={'obj':'str'}, choices=choices)
     f = super(AuthEventAdmin, self).get_form(request, obj, **kwargs)
     return f
Example #4
0
def check_authmethod(method):
    """ Check if method exists in method list. """
    from authmethods import METHODS
    if method in METHODS.keys():
        return ''
    else:
        return "Invalid authmethod\n"
Example #5
0
def check_authmethod(method):
    """ Check if method exists in method list. """
    from authmethods import METHODS
    if method in METHODS.keys():
        return ''
    else:
        return "Invalid authmethod\n"
Example #6
0
 def get_form(self, request, obj=None, **kwargs):
     choices = []
     for k in METHODS.keys():
         choices.append((k, k + ': ' + METHODS.get(k).DESCRIPTION))
     AuthEventAdminForm.Meta.widgets['auth_method'] = forms.Select(
         attrs={'obj': 'str'}, choices=choices)
     f = super(AuthEventAdmin, self).get_form(request, obj, **kwargs)
     return f
Example #7
0
    class Meta:
        model = AuthEvent
        fields = ('auth_method', 'census', 'auth_method_config',
                  'extra_fields', 'status')
        choices = []
        for k in METHODS.keys():
            choices.append((k, k + ': ' + METHODS.get(k).DESCRIPTION))

        widgets = {
            'auth_method': forms.Select(attrs={'obj': 'str'}, choices=choices),
        }