lifecycle: fix install_id migration not running (#7116)

* lifecycle: fix install_id migration not running

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* fix ldap test?

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* idk if this works

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-10-09 19:52:06 +02:00 committed by GitHub
parent 94fd22b448
commit a22bc5a261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 10 deletions

View File

@ -59,7 +59,7 @@ func (ds *DirectSearcher) SearchSubschema(req *search.Request) (ldap.ServerSearc
"( 2.5.21.2 NAME 'dITContentRules' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )", "( 2.5.21.2 NAME 'dITContentRules' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )",
"( 2.5.21.5 NAME 'attributeTypes' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )", "( 2.5.21.5 NAME 'attributeTypes' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )",
"( 2.5.21.6 NAME 'objectClasses' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )", "( 2.5.21.6 NAME 'objectClasses' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' NO-USER-MODIFICATION )",
"( 0.9.2342.19200300.100.1.1 NAME 'uid' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' )", "( 0.9.2342.19200300.100.1.1 NAME 'uid' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
"( 0.9.2342.19200300.100.1.3 NAME 'mail' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )", "( 0.9.2342.19200300.100.1.3 NAME 'mail' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
"( 0.9.2342.19200300.100.1.41 NAME 'mobile' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )", "( 0.9.2342.19200300.100.1.41 NAME 'mobile' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
"( 1.2.840.113556.1.2.13 NAME 'displayName' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )", "( 1.2.840.113556.1.2.13 NAME 'displayName' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",

View File

@ -4,9 +4,11 @@ from uuid import uuid4
from authentik.lib.config import CONFIG from authentik.lib.config import CONFIG
from lifecycle.migrate import BaseMigration from lifecycle.migrate import BaseMigration
SQL_STATEMENT = """CREATE TABLE IF NOT EXISTS authentik_install_id ( SQL_STATEMENT = """BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS authentik_install_id (
id TEXT NOT NULL id TEXT NOT NULL
);""" );
COMMIT;"""
class Migration(BaseMigration): class Migration(BaseMigration):
@ -17,8 +19,8 @@ class Migration(BaseMigration):
return not bool(self.cur.rowcount) return not bool(self.cur.rowcount)
def upgrade(self, migrate=False): def upgrade(self, migrate=False):
with self.con.transaction():
self.cur.execute(SQL_STATEMENT) self.cur.execute(SQL_STATEMENT)
with self.con.transaction():
if migrate: if migrate:
# If we already have migrations in the database, assume we're upgrading an existing install # If we already have migrations in the database, assume we're upgrading an existing install
# and set the install id to the secret key # and set the install id to the secret key

View File

@ -231,6 +231,7 @@ class TestProviderLDAP(SeleniumTestCase):
for obj in response: for obj in response:
del obj["raw_attributes"] del obj["raw_attributes"]
del obj["raw_dn"] del obj["raw_dn"]
obj["attributes"] = dict(obj["attributes"])
o_user = outpost.user o_user = outpost.user
expected = [ expected = [
{ {
@ -244,11 +245,13 @@ class TestProviderLDAP(SeleniumTestCase):
"sn": o_user.name, "sn": o_user.name,
"mail": "", "mail": "",
"objectClass": [ "objectClass": [
"user", "top",
"person",
"organizationalPerson", "organizationalPerson",
"inetOrgPerson", "inetOrgPerson",
"goauthentik.io/ldap/user", "user",
"posixAccount", "posixAccount",
"goauthentik.io/ldap/user",
], ],
"uidNumber": 2000 + o_user.pk, "uidNumber": 2000 + o_user.pk,
"gidNumber": 2000 + o_user.pk, "gidNumber": 2000 + o_user.pk,
@ -270,11 +273,13 @@ class TestProviderLDAP(SeleniumTestCase):
"sn": embedded_account.name, "sn": embedded_account.name,
"mail": "", "mail": "",
"objectClass": [ "objectClass": [
"user", "top",
"person",
"organizationalPerson", "organizationalPerson",
"inetOrgPerson", "inetOrgPerson",
"goauthentik.io/ldap/user", "user",
"posixAccount", "posixAccount",
"goauthentik.io/ldap/user",
], ],
"uidNumber": 2000 + embedded_account.pk, "uidNumber": 2000 + embedded_account.pk,
"gidNumber": 2000 + embedded_account.pk, "gidNumber": 2000 + embedded_account.pk,
@ -296,11 +301,13 @@ class TestProviderLDAP(SeleniumTestCase):
"sn": self.user.name, "sn": self.user.name,
"mail": self.user.email, "mail": self.user.email,
"objectClass": [ "objectClass": [
"user", "top",
"person",
"organizationalPerson", "organizationalPerson",
"inetOrgPerson", "inetOrgPerson",
"goauthentik.io/ldap/user", "user",
"posixAccount", "posixAccount",
"goauthentik.io/ldap/user",
], ],
"uidNumber": 2000 + self.user.pk, "uidNumber": 2000 + self.user.pk,
"gidNumber": 2000 + self.user.pk, "gidNumber": 2000 + self.user.pk,