-
Notifications
You must be signed in to change notification settings - Fork 1
Source: Introduce Usernames #338
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
Conversation
9e07bb4 to
85e43f8
Compare
e2a1836 to
f3870a3
Compare
85e43f8 to
6c9901a
Compare
6c9901a to
3ac0733
Compare
| -- listener_{username,password_hash} are required to limit API access for incoming connections to the Listener. | ||
| listener_username varchar(255), |
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.
While testing Icinga/icinga-notifications-web#390 with the branch https://github.com/Icinga/icinga-notifications/ pull/324, I noticed that icingadb was unable to connect to the notifications API because I had accidentally omitted to define a “listener_password” when creating a resource.
However, since the column is nullable, no error is displayed if a resource is defined without a password.
As these fields are required, they should not be nullable.
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.
Both columns are nullable to ease the database schema migration. But, as @yhabteab also suggested above, maybe the primary key can be changed from an ID to this username, being UNIQUE and everything.
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.
maybe the primary key can be changed from an ID to this username
I mean technically possible, but that would then also have to be used for foreign keys (obviously) and make it pretty much impossible to change the username for a source. Also keep in mind that it's currently included in the object IDs as objects are handled as being source-specific:
icinga-notifications/internal/object/object.go
Lines 197 to 199 in cea444e
| sourceBytes := make([]byte, 8) | |
| binary.BigEndian.PutUint64(sourceBytes, uint64(source)) | |
| h.Write(sourceBytes) |
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.
Due to the size of the changes, I am also no fan of changing the primary key.
However, back to the original comment:
While testing Icinga/icinga-notifications-web#390 with the branch https://github.com/Icinga/icinga-notifications/ pull/324, I noticed that
icingadbwas unable to connect to thenotifications APIbecause I had accidentally omitted to define a “listener_password” when creating a resource.
Without a password, Icinga Notifications would reject the connection. That's intended.
But, as I commented above, this would allow schema migrations and keep elements of old and now removed sources - such as Icinga 2.
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.
Both columns are nullable to ease the database schema migration.
Why both though? I was a bit too focused on listener_password_hash, as that was the culprit in the the original comment. For that one, I see that the nullable for the migration applies: we can't really set a meaningful password during the migration, so the plan for the migration is:
- Apply the schema upgrade.
- Manually assign passwords to icinga2 sources in web.
- Configure these source credentials in Icinga DB.
Note that web should probably enforce that listener_password_hash is set. Otherwise that'll create a source that can't authenticate itself. A corresponding not null constraint can then be added in a migration for a later version (otherwise, the migration for this version would need a second schema migration file that needs to be applied later).
However, for listener_username, the migration file sets the value to the previously used source-${id} string, so I don't see a reason why that shouldn't get a not null constraint.
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.
3ac0733 to
e9f0ed2
Compare
e9f0ed2 to
fcd9fff
Compare
|
There's still something unaddressed from #338 (comment):
I've also added references to the Icinga Notifications Web issue + PR in the description. |
|
I was also convinced that the user name must not be nullable until right now. But then I saw that for the unique check we'd need to include deleted rows as they are part of the unique constraint still. Thus I'd object it being non-nullable. |
|
I see. It should be treated by Notifications Web like a required column for live rows nonetheless. That could be expressed as a |
0a27e8c to
46b5d59
Compare
julianbrost
left a comment
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.
Looks good to me now, wait for Icinga/icinga-notifications-web#401 with merging though.
I didn't mark all conversations as resolved as I didn't start them, maybe their authors (@yhabteab @sukhwinder33445) want to take another look as well.
Unique usernames were added to Sources for HTTP Authentication. Before, the HTTP Authentication expected a username based on the Source ID, such as "source-23". This was not very practical. Thus, an unique username column was introduced and the Listener's authentication code was adequately altered. Fixes #227.
46b5d59 to
fc17f36
Compare
Done. |
This gives a single file that can be applied during the upgrade more easily, having it in individual files was mostly to avoid merge conflicts during development. The combined files were created with the following command: cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql The order of files matches the order in which the PRs that added them were merged (though the order shouldn't really matter as there are no dependencies between the individual files): - #216 - #324 - #344 - #338
This gives a single file that can be applied during the upgrade more easily, having it in individual files was mostly to avoid merge conflicts during development. The combined files were created with the following command: cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql The order of files matches the order in which the PRs that added them were merged (though the order shouldn't really matter as there are no dependencies between the individual files): - #216 - #324 - #344 - #338
Unique usernames were added to Sources for HTTP Authentication.
Before, the HTTP Authentication expected a username based on the Source ID, such as "source-23". This was not very practical. Thus, an unique username column was introduced and the Listener's authentication code was adequately altered.
Blocked By
Fixes #227.
refs Icinga/icinga-notifications-web#398