Giter Site home page Giter Site logo

Comments (4)

nickw444 avatar nickw444 commented on May 18, 2024

This is definitely possible - I have done this in many projects. I.e. having local root privilege users.

You can do this by providing a custom Login Form. See forms.py - it provides LDAPLoginForm. You can either make your own, or create a subclass of this to provide the custom validation.

Your best bet here would be to do something like:

from flask_ldap3_login.forms import LDAPLoginForm
from flask_wtf import FlaskForm

class MyAuthForm(LDAPLoginForm):
    def validate(self,  *args, **kwargs):
        valid = FlaskForm.validate(self, *args, **kwargs)
        if not valid:
            print("Form validation failed")
            return valid
        if self.username.data == 'root' and self.password.data == 'mycoolpassword':
            # TODO: Replace this with a call to your users datastore.
            return True

        # User not a local user, just do the normal LDAP validation
        return super().validate(*args, **kwargs)

from flask-ldap3-login.

keans avatar keans commented on May 18, 2024

Thanks for the reply. Yes, I also thought about overwriting the form, but I thought that is a common desire that could be implemented as part of the module. Anyways, I will try your suggestion...

from flask-ldap3-login.

nickw444 avatar nickw444 commented on May 18, 2024

I aim to keep this module as use-case agnostic as possible to allow it to be as flexible as possible and work for the masses.

from flask-ldap3-login.

nickw444 avatar nickw444 commented on May 18, 2024

Closing this issue out for now, if you have any other problems feel free to reply or open another issue.

from flask-ldap3-login.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.