-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #24146: Backport user table to Rudder 7.3 #5378
Fixes #24146: Backport user table to Rudder 7.3 #5378
Conversation
9ddf8bc
to
3977f3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some types that should ideally be added right now (I think there are many more, I did only some git diff
between the 8.1 branch and this one to find that types were deleted)
...pp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/users/UserRepository.scala
Outdated
Show resolved
Hide resolved
import com.normation.rudder.users.UserSerialization._ | ||
import doobie._ | ||
|
||
implicit val logger = Doobie.slf4jDoobieLogger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in the 8.1 branch, if it's really really needed here the type should be explicit !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, that one is not important: what we want to have is a nice upmerge experience. For that, we want to limit changes between branches, and so want want to have the same changes on all branches (for ex adding types).
But here, since the code was removed in upper branch, adding the type would likely cause a merge conflict, while letting it unchanged is ok (the deletion was already merged).
...ources/rudder/rudder-core/src/test/scala/com/normation/rudder/users/UserRepositoryTest.scala
Outdated
Show resolved
Hide resolved
...ources/rudder/rudder-core/src/test/scala/com/normation/rudder/users/UserRepositoryTest.scala
Outdated
Show resolved
Hide resolved
...ources/rudder/rudder-core/src/test/scala/com/normation/rudder/users/UserRepositoryTest.scala
Outdated
Show resolved
Hide resolved
...es/rudder/rudder-web/src/main/scala/bootstrap/liftweb/checks/migration/CheckTableUsers.scala
Outdated
Show resolved
Hide resolved
/* | ||
* During 7.3 cycle, we added the registration of users and their sessions in base. | ||
* This is to allows better security logs on user sessions + allows to de-correlate rudder | ||
* users from the `rudder-user.xml` file. | ||
*/ | ||
class CheckTableUsers( | ||
doobie: Doobie | ||
) extends BootstrapChecks { | ||
|
||
import doobie._ | ||
|
||
override def description: String = "Check if database tables Users and UserSessions exist" | ||
|
||
def createUserTables: IOResult[Unit] = { | ||
val sql1 = sql"""CREATE TABLE IF NOT EXISTS Users ( | ||
id text PRIMARY KEY NOT NULL CHECK (id <> '') | ||
, creationDate timestamp with time zone NOT NULL | ||
, status text NOT NULL | ||
, managedBy text NOT NULL CHECK (managedBy <> '') | ||
, name text | ||
, email text | ||
, lastLogin timestamp with time zone | ||
, statusHistory jsonb | ||
, otherInfo jsonb -- general additional user info | ||
);""" | ||
|
||
val sql2 = sql"""CREATE TABLE IF NOT EXISTS UserSessions ( | ||
userId text NOT NULL CHECK (userId <> '') | ||
, sessionId text NOT NULL CHECK (sessionId <> '') | ||
, creationDate timestamp with time zone NOT NULL | ||
, authMethod text | ||
, permissions text[] | ||
, endDate timestamp with time zone | ||
, endCause text | ||
);""" | ||
|
||
transactIOResult(s"Error with 'Users' table creation")(xa => sql1.update.run.transact(xa)).unit *> | ||
transactIOResult(s"Error with 'v' table creation")(xa => sql2.update.run.transact(xa)).unit | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some database compatibility issues that may arise :
- The users is version 7.3 will have the tables created, and when upgrading to 8.1 they will need to add a column
tenants
to theUserSessions
table : we should create a migration for that - I imagine there will be no user rolling back from version 8.1 to 7.3, but for developement I have an error reading user sessions from the table when the webapp starts (see the fix I suggested in
UserRepository
file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we will need an additionnal migration to add the tenants column
...pp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/users/UserRepository.scala
Outdated
Show resolved
Hide resolved
@@ -991,6 +979,44 @@ object RudderParsedProperties { | |||
} | |||
} | |||
|
|||
// user clean-up | |||
val RUDDER_USERS_CLEAN_CRON = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val RUDDER_USERS_CLEAN_CRON = ( | |
val RUDDER_USERS_CLEAN_CRON: Option[CronExpr] = ( |
745474c
to
4d4a1a8
Compare
The failing tests have nothing to do with the code (they will be investigated appart). Merging by hand because it targets a branch unknown of our bot. |
d0fd857
into
Normation:backports/7.3.12/24146
https://issues.rudder.io/issues/24146
Backport of #5121 for branche 7.3.