Comments (4)
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.
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.
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.
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)
- Add license information to setup.py HOT 1
- A message for a misconfiguration
- CSRF must be initialized HOT 4
- Logging: flask-ldap3-login adds the console handler to the root level logger HOT 3
- How to automatically add domain name to the username
- DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.4 HOT 14
- Drop support for Python 3.4
- Only cn attribute is working HOT 2
- Drop support for Python 2.7 HOT 1
- result.user_groups TypeError: 'NoneType' object is not callable HOT 3
- DeprecationWarning: Required is going away in WTForms 3.0, use DataRequired HOT 7
- AttributeError when login form does not validate. HOT 1
- TLS connection as default
- Authenticate flask app against multiple AD's HOT 2
- user data attributes are lists sometimes
- get_object() throws a KeyError exception when user not found HOT 2
- Unable to differentiate between broken connection and user not found HOT 2
- Inappropriate setup of Tls context within init_app() for default server. HOT 1
- get_user_groups() malforms CN causing false query results and empty user_groups HOT 1
- AttributeError: module 'wtforms.validators' has no attribute 'Required HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-ldap3-login.