forked from Github-Mirrors/canaille
Renamed LDAPObjectHelper into LDAPObject
This commit is contained in:
parent
e9070c305e
commit
7877998818
4 changed files with 11 additions and 11 deletions
|
@ -20,7 +20,7 @@ from flask import Flask, g, request, render_template
|
|||
from flask_babel import Babel
|
||||
|
||||
from .flaskutils import current_user
|
||||
from .ldaputils import LDAPObjectHelper
|
||||
from .ldaputils import LDAPObject
|
||||
from .oauth2utils import config_oauth
|
||||
from .models import User, Token, AuthorizationCode, Client, Consent
|
||||
|
||||
|
@ -111,7 +111,7 @@ def setup_app(app):
|
|||
sentry_sdk.init(dsn=app.config["SENTRY_DSN"], integrations=[FlaskIntegration()])
|
||||
|
||||
try:
|
||||
LDAPObjectHelper.root_dn = app.config["LDAP"]["ROOT_DN"]
|
||||
LDAPObject.root_dn = app.config["LDAP"]["ROOT_DN"]
|
||||
base = app.config["LDAP"]["USER_BASE"]
|
||||
if base.endswith(app.config["LDAP"]["ROOT_DN"]):
|
||||
base = base[: -len(app.config["LDAP"]["ROOT_DN"]) - 1]
|
||||
|
|
|
@ -2,7 +2,7 @@ import ldap
|
|||
from flask import g
|
||||
|
||||
|
||||
class LDAPObjectHelper:
|
||||
class LDAPObject:
|
||||
_object_class_by_name = None
|
||||
_attribute_type_by_name = None
|
||||
may = None
|
||||
|
|
|
@ -9,10 +9,10 @@ from authlib.oauth2.rfc6749 import (
|
|||
util,
|
||||
)
|
||||
from flask import current_app, session
|
||||
from .ldaputils import LDAPObjectHelper
|
||||
from .ldaputils import LDAPObject
|
||||
|
||||
|
||||
class User(LDAPObjectHelper):
|
||||
class User(LDAPObject):
|
||||
id = "cn"
|
||||
admin = False
|
||||
|
||||
|
@ -68,7 +68,7 @@ class User(LDAPObjectHelper):
|
|||
return self.cn[0]
|
||||
|
||||
|
||||
class Client(LDAPObjectHelper, ClientMixin):
|
||||
class Client(LDAPObject, ClientMixin):
|
||||
objectClass = ["oauthClient"]
|
||||
base = "ou=clients,ou=oauth"
|
||||
id = "oauthClientID"
|
||||
|
@ -137,7 +137,7 @@ class Client(LDAPObjectHelper, ClientMixin):
|
|||
)
|
||||
|
||||
|
||||
class AuthorizationCode(LDAPObjectHelper, AuthorizationCodeMixin):
|
||||
class AuthorizationCode(LDAPObject, AuthorizationCodeMixin):
|
||||
objectClass = ["oauthAuthorizationCode"]
|
||||
base = "ou=authorizations,ou=oauth"
|
||||
id = "oauthCode"
|
||||
|
@ -173,7 +173,7 @@ class AuthorizationCode(LDAPObjectHelper, AuthorizationCodeMixin):
|
|||
return self.oauthCodeChallenge
|
||||
|
||||
|
||||
class Token(LDAPObjectHelper, TokenMixin):
|
||||
class Token(LDAPObject, TokenMixin):
|
||||
objectClass = ["oauthToken"]
|
||||
base = "ou=tokens,ou=oauth"
|
||||
id = "oauthAccessToken"
|
||||
|
@ -217,7 +217,7 @@ class Token(LDAPObjectHelper, TokenMixin):
|
|||
return self.expire_date >= datetime.datetime.now()
|
||||
|
||||
|
||||
class Consent(LDAPObjectHelper):
|
||||
class Consent(LDAPObject):
|
||||
objectClass = ["oauthConsent"]
|
||||
base = "ou=consents,ou=oauth"
|
||||
id = "cn"
|
||||
|
|
|
@ -10,7 +10,7 @@ from flask_webtest import TestApp
|
|||
from werkzeug.security import gen_salt
|
||||
from oidc_ldap_bridge import create_app
|
||||
from oidc_ldap_bridge.models import User, Client, Token, AuthorizationCode, Consent
|
||||
from oidc_ldap_bridge.ldaputils import LDAPObjectHelper
|
||||
from oidc_ldap_bridge.ldaputils import LDAPObject
|
||||
|
||||
|
||||
class CustomSlapdObject(slapdtest.SlapdObject):
|
||||
|
@ -85,7 +85,7 @@ def slapd_server():
|
|||
+ "\n"
|
||||
)
|
||||
|
||||
LDAPObjectHelper.root_dn = slapd.suffix
|
||||
LDAPObject.root_dn = slapd.suffix
|
||||
User.base = "ou=users"
|
||||
conn = ldap.ldapobject.SimpleLDAPObject(slapd.ldap_uri)
|
||||
conn.simple_bind_s(slapd.root_dn, slapd.root_pw)
|
||||
|
|
Loading…
Reference in a new issue