-
Notifications
You must be signed in to change notification settings - Fork 185
Creates a admin user automatically when installing ravada. #2263
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -207,6 +207,7 @@ sub _install($self) { | |||||
| $self->_upgrade_timestamps(); | ||||||
| $self->_update_data(); | ||||||
| $self->_init_user_daemon(); | ||||||
| $self->_init_user_admin(); | ||||||
| $self->_sql_insert_defaults(); | ||||||
|
|
||||||
| $self->_do_create_constraints(); | ||||||
|
|
@@ -321,6 +322,30 @@ sub _init_user_daemon { | |||||
| } | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| sub _init_user_admin { | ||||||
| my $self = shift; | ||||||
| return if !$FIRST_TIME_RUN; | ||||||
|
|
||||||
| my $sth = $CONNECTOR->dbh->prepare( | ||||||
| "SELECT count(*) FROM users WHERE is_admin=1 AND name <> ?" | ||||||
| ); | ||||||
| $sth->execute($USER_DAEMON_NAME); | ||||||
| my ($count) = $sth->fetchrow; | ||||||
| $sth->finish; | ||||||
| return if $count; | ||||||
|
|
||||||
| my $user_admin = Ravada::Auth::SQL->new(name => 'admin'); | ||||||
| return if $user_admin->id; | ||||||
|
|
||||||
| Ravada::Auth::SQL::add_user( | ||||||
| name => 'admin' | ||||||
| ,password => 'admin' | ||||||
| ,is_admin => 1 | ||||||
| ); | ||||||
| warn "INFO: created default admin user 'admin' with password 'admin'\n" | ||||||
|
||||||
| warn "INFO: created default admin user 'admin' with password 'admin'\n" | |
| warn "INFO: created default admin user 'admin'\n" |
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.
Creating a default admin user with hardcoded credentials ('admin'/'admin') poses a serious security risk. If users don't change these credentials immediately, their Ravada installation will be vulnerable to unauthorized access.
Consider one of these alternatives: