From 52e437a14689f39f0481c5863725ca02ffafa4be Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Fri, 12 Nov 2021 20:23:21 +0100 Subject: [PATCH] baculum: Add API endpoints for API basic user management --- .../protected/API/Class/BasicConfig.php | 38 ++- gui/baculum/protected/API/Lang/en/messages.mo | Bin 17266 -> 17334 bytes gui/baculum/protected/API/Lang/en/messages.po | 3 + gui/baculum/protected/API/Lang/pl/messages.mo | Bin 18822 -> 18897 bytes gui/baculum/protected/API/Lang/pl/messages.po | 3 + gui/baculum/protected/API/Lang/pt/messages.mo | Bin 18884 -> 18952 bytes gui/baculum/protected/API/Lang/pt/messages.po | 3 + gui/baculum/protected/API/Lang/ru/messages.mo | Bin 23230 -> 23298 bytes gui/baculum/protected/API/Lang/ru/messages.po | 3 + .../protected/API/Pages/API/BasicUser.php | 273 +++++++++++++++ .../protected/API/Pages/API/BasicUsers.php | 37 ++ .../protected/API/Pages/API/OAuth2Client.php | 10 +- .../protected/API/Pages/API/config.xml | 1 + .../protected/API/Pages/API/endpoints.xml | 3 + .../API/Pages/Panel/APIBasicUsers.php | 19 +- .../protected/API/openapi_baculum.json | 319 ++++++++++++++++++ .../Common/Class/BasicUserConfig.php | 12 +- gui/baculum/protected/Common/Class/Errors.php | 20 +- .../Common/Portlets/NewAuthClient.tpl | 4 +- 19 files changed, 715 insertions(+), 33 deletions(-) create mode 100644 gui/baculum/protected/API/Pages/API/BasicUser.php create mode 100644 gui/baculum/protected/API/Pages/API/BasicUsers.php diff --git a/gui/baculum/protected/API/Class/BasicConfig.php b/gui/baculum/protected/API/Class/BasicConfig.php index b41ecc902..84e4fd584 100644 --- a/gui/baculum/protected/API/Class/BasicConfig.php +++ b/gui/baculum/protected/API/Class/BasicConfig.php @@ -131,6 +131,31 @@ class BasicConfig extends ConfigFileModule { return $is_valid; } + /** + * Get users. + * NOTE: User list bases on basic password file. + * @see BasicAPIUserConfig + * + * @return array basic user list + */ + public function getUsers() { + $basic_users = []; + $basic_apiuser = $this->getModule('basic_apiuser')->getUsers(); + $basic_config = $this->getConfig(); + foreach($basic_apiuser as $user => $pwd) { + $bconsole_cfg_path = ''; + if (key_exists($user, $basic_config) && key_exists('bconsole_cfg_path', $basic_config[$user])) { + $bconsole_cfg_path = $basic_config[$user]['bconsole_cfg_path']; + } + $basic_users[] = [ + 'username' => $user, + 'bconsole_cfg_path' => $bconsole_cfg_path + ]; + } + return $basic_users; + + } + /** * Add single basic user to config. * NOTE: Basic password hashes are stored in separate file. @@ -198,15 +223,18 @@ class BasicConfig extends ConfigFileModule { * @return boolean true on success, otherwise false */ public function removeUser($username) { - $success = false; $config = $this->getConfig(); if (key_exists($username, $config)) { unset($config[$username]); - $success = $this->setConfig($config); - } - if ($success) { - $success = $this->getModule('basic_apiuser')->removeUser($username); + $this->setConfig($config); } + /** + * There is returned only state of removing user from password file because + * because user can be defined in password file but it does not have + * to be defined in basic.conf file. It is for backward compatibility + * with config files. + */ + $success = $this->getModule('basic_apiuser')->removeUser($username); return $success; } } diff --git a/gui/baculum/protected/API/Lang/en/messages.mo b/gui/baculum/protected/API/Lang/en/messages.mo index d00e4cca8bed78257a077ade6edf708e2f17b42c..17872bad29ea3b16d4d0736888704178d88b2410 100644 GIT binary patch literal 17334 zc-rk*eRx~dc|YAUpjlczmN=h{k4gL)OR{4tv6cAS4l&rVu^k9)nRBIkY~3K~D)(O5 zF)dx24mJv1X`$`9vSxIo9b2Jc-I~D$Eo?1?wUiB3I$&X4>AH>e8SOL1c%D4%-uL{D zWJ$Im{I@@($MWxWP z4#Mvdt|Po~EuDq1b}i_4uf;h=2rngk4{=&h=fwO9)>eY$Nd?`#0wTg?1ZgfoN>5YF>DTKpcu-z9vI@V_^L z&o6JnzJIw1e141YU2Hd-AeWanVcuDT7i`_&bCXgfDK! zId_s%Y$F`rg7c=gz%D+v1^l1d0y?L+fX|1vfd6N=K<_VZ0i9P3uAxIVvfUBZ5stnK z>jJ_r@&1ID6Ykk6M3V3(!d+~yTcMY_YMeh>4Su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J+gTm%{E;%1_37dKZfmkRFtM(9Oc44igKX` zq7>laD6?pj-tW@;JEImCdMV1La~hl|=~c-}Hy6B7qPdc$?yZzfBbrZ)6E(-^^F?}n zXG~*7$J=5oKPjzRUE%iMc-#u^Ey&Z0VY>dL93;jJDkU>xzMZC)bLz2dqH*$OKGEW zNe%BmQo|THP(v4;R9>uM42&F0jlX?=l;20@Hb&UR}>a^+9G5t>0u~&RiM@xubCD`5dw0J$3 zA^Cq>JtbTQ&XK4ECxd^l=f+`N0~c7?K$mQ8pr8jE7&GS@Sc(TFnZDj6eO<2ClajQ| z%p?_SPSW=aL8~u1lNz1+Vt0}Y9#j4^NzH7HoG8}F{H<%GDW^2jLh~D`@d|K&;eK+l z$u3ZzEKoX>OC;nCt4u`4j*9K2ipVZgs*L21-V;B_&ZI`F zjg&}(RW00 z*D!#3_1+V*@5b>1DGai+HH>iiofMJZG|Zi2hE?Nsy(yKY&M>j%m#Mr}c|f|1p3hav z7WZ{SPfn4pr2mm1Uo(9LMFLAIm0_^_&t!)Ti}F&v-jCy#dOp9OC8V55zI`C|Qpc7l zB|oR@`8Sn6l%1+!OZ@Ne4a1z2U;Dq()7uZHrC2Kr^XoDB+>ve|Nv{u0y(E(4BXM=V z>tEpbqhTeQamllHDQDsMt`r8@q3YN{!>#oRDF<5&^Q}p5{#5y6?(zG6(he6$;n(XP zrTiDh`#5fCKa%0F9*~dWOT>7k-+3F39fn!^Ucd2a@!?Nag8a4_kIQwusWLVAQ zCm$QT#6^Z*!5v21tzi%Nm24>WS?Q9^dj1XBoEVnX7j*2c9T~$POxdx=QJU4BR%zdn IU-qp1Ka?5o`Tzg` diff --git a/gui/baculum/protected/API/Lang/pl/messages.po b/gui/baculum/protected/API/Lang/pl/messages.po index cc7c55fc0..208a35044 100644 --- a/gui/baculum/protected/API/Lang/pl/messages.po +++ b/gui/baculum/protected/API/Lang/pl/messages.po @@ -691,3 +691,6 @@ msgstr "Pliki bin.:" msgid "Configs:" msgstr "Pliki konfig.:" + +msgid "Dedicated Bconsole config" +msgstr "Dedykowana konfiguracja Bconsole" diff --git a/gui/baculum/protected/API/Lang/pt/messages.mo b/gui/baculum/protected/API/Lang/pt/messages.mo index a7351ef70c2b529ca7dd2c9f7652fc736338062c..7d8008aa760993203d5241ebedac2ab62aa05950 100644 GIT binary patch delta 4869 zc-mc<3zU>q9l-AfBFKB)o!OWBV0UJiiP@dmg=O6Lva`E0=muC|iU=u?ScDqID;T0g z5)E_(vJ|owjk2JC2tq&}p+rC|iVuPcOwN%G(J401;aLCw{{GpGDON{dHzD3wi=691km}HuV z0Uz;Ti3J`s{H6zsw0qF-IUDHb#{C`y==31KyEei5!rsCzVXp9+&6DLtfsim&q(1jD z(In#x<6JKSeZ!09j|)qL9rpZn;|VV&J}nFhFL)7Xa2A4lv-rMHD6d?VP-Jm;WQqM% zfLU1#ywX0{BAhAQDV(Pt%GZ;H-x2N-{v#VrH|H?%uXE7!HQ_B9J2_b9gB^x#)RUQ`DlE*kZ^3e2^ zJS=cJ58t25W1N2)2Z)qGVR1@+_~l32Eqpjv__7Kh94oBOckThaZ7Qt5=>j{`F`Oigog{smLr8I^q#%{xApH`ghf2UxaR+eA~brq2$L=?VxSj_5TK(7 z4UZHN#ixXGg?|&y)?gh*P<0Mt;t#Cdr#d`M=g)>@mJ$ylPA@ zp+1zB;JYy;nDDL=2AWqw<$PK=M}x8i3l;cqkx%$3{oaQQ7yAg>ZNhUq2?y_v6cAKm9{~1}e99y|r8YO#B%?Q9s3x0<-*BaIA}kbya|%T^*p%>;Q$I84Pc>50W5RVa7u5$ST(%c z_pWWY*gv7BlLry4T*LWrK#U1e4I$uig^e;ogtTLjtOgKghM;Yn4sf>Y-l%e4t z%COv(GF;I=Lcfv-mS~P($?*{syUTcgq+8IGn;jv|mPPRW`Usltj-dIm2&TIbL9o9^ z(5PRO39_PmUmV3U^-+90-rBRH2)rbUrJpiB8&w6w|1U&ItL;&udUupsf8IX4v7BJc zDaUkU%hB{cYcDG2`}T4y@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94vooH)dL3yfy z!L_%6F6jry7+R-Q>WTUP-#Wu_c4KEh@<8_dr*ZvKmRLh`%Hs2iVI}OBU5vyCuCIwE zI?y4*tawPGBB$o^edHX2Q#lhnI zHw@F`7ltM7C4K*x;i_{+4uXcMF{JOFlf?qp*Cm)_XKNVA@*5P9PZ>JuceuVGgvD8uc>j}2FUsc~JnzF=6#ek;PB*8$!#Jf%q)*=u-G^Xt1` zb!?fO*|Oho!H^0iyB1lk+}cA98@=Kp!&C51!^KDrs8XPQCS_Xt)*7CW<#($b#|+nr Ym-X4%p0p|LNj?4c3yz+H;d%D|0T(LkD*ylh diff --git a/gui/baculum/protected/API/Lang/pt/messages.po b/gui/baculum/protected/API/Lang/pt/messages.po index 1c3ce986b..0c5d798ff 100644 --- a/gui/baculum/protected/API/Lang/pt/messages.po +++ b/gui/baculum/protected/API/Lang/pt/messages.po @@ -692,3 +692,6 @@ msgstr "Binários:" msgid "Configs:" msgstr "Configurações:" + +msgid "Dedicated Bconsole config" +msgstr "Dedicated Bconsole config" diff --git a/gui/baculum/protected/API/Lang/ru/messages.mo b/gui/baculum/protected/API/Lang/ru/messages.mo index ecd7ee8b0031a33b6890bd3f0195bf7bbf0c5036..5d14856f5c8804a3f8e47132e421441e4ceed4e5 100644 GIT binary patch delta 4895 zc-mc<33Qaz8HT?o)nM68X0n-u%#xXsbtV&=q#49Xf+T@tl0YUD1BHY}MG8h)Bn(9a z!3AQfwiTtep|ns-O4wVGO+c!UvJ@1WSfa-k+d{3&p@-VOU*796bAqD}X97;|tsrv_RGMV!8ULt_#8M~BrKauN4pFUf|20c;GN(f!Dw)J6pR7wQ5>KsiiVVf zqrs^l{>f7O`8wDRW`Y}{XxK?`6nGKzfLFjV7++G+JI0X8Xf~V`%>lj#CToXaoOT4p zf_uTi;2H21uqT?Heqh@FJ-XjBxfV^s2V2M_3nP(h;qwx3Fvge37KUWHg&oefFcOO_ z^l*iR5ox#3!}X@4-xwaW(16nx8gRi3@F6$|{2Yu2ubXjV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xJ+3Fm`l(yQpv#IiRrmOuM!HJ9O68=A;v~gh(W$M#Pwn!*#Az+-w-Wu32c_#t(4pFic$_d0S2Mr0Qi`c zhdbG@c7d&8>N56#wsNNL<_6pdi7CN)so51Y z**vgOYIOx&F;KyAcZKQ0bz$v@!Yn+UVJgxUrsk*h`Pnej_d=NIIJ}avaBHlR1*p1` zn%)QAB^p(7f!~9rlE0NKJU-OT3Q5Z;+(cG`UQqyiN9qH3L^c^rf_OI5tGM~B1q-D` zt75PYR52)HWmCETZviLE?g!p25>Dd_3qf&F2UsZ@Ok)jqS5uS4)%5KSWgi%pf;OGw zrh)$ug{IRbEi-8PjWY&=82vv^9>k4hHT2;}HQauOM_3QCB22@Q2>XPV2racULf@W_ zFzwDq=-W>twCJ@6)6)`Vv^%35UlC`KC4~&FAwl=5VL>@$C;(#9eA}?<$#KxIXM9+%@40TFh@qwuKi&9E zX}>TkIrgGqBs?QsppJAXZOUbadAQNAK*;eM=|&~grOPxdi7|a9xhmm(hcpYaTgi8v zVVM+PO7&UAp)vDILr2dx%%Sy$9pvLfL>GIa?3!O0=Fw}0wX;i~OC6SceOEpN4eRzr zeYR8jZv4I@ZLxH=hSf-p3nKE{hGj{1krw&D(}z;TrMlSlI!XC8<#DM{dVa4`THKR{ zo|IDAs{fH7Uo*0=ACvAyDwAQJeqpjxhGDr3Q=IOUQpuNM$)E-`0BX5v4@i zJUySUlnp{E)q6wcIBi%A<;noa-VV~c%Xvi3SL-W+niSsEY1J?G4j`*URzH0=1~IAK`JwiteJ%U&p@rwzZK%Kr?o zH#d9m`?_J(_&|jHtxoWk;a8dz)aMPq)V%ua*X^6eCO7XktnX52WT$$I#x>XB0ZO~E6u8u)xCPJZ{L`4kH_yjWa~(6?{2WQ&##!U JZ&z@h + * @category API + * @package Baculum API + */ +class BasicUser extends BaculumAPIServer { + + public function get() { + $user = $this->Request->contains('id') ? $this->Request['id'] : 0; + $username = $this->getModule('basic_apiuser')->validateUsername($user) ? $user : null; + if (is_string($username)) { + $basic_config = $this->getModule('basic_config')->getConfig($username); + if (count($basic_config) > 0) { + $this->output = array_merge($basic_config, ['username' => $username]); + $this->error = BasicUserError::ERROR_NO_ERRORS; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_DOES_NOT_EXIST; + $this->error = BasicUserError::ERROR_BASIC_USER_DOES_NOT_EXIST; + } + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_USERNAME; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_USERNAME; + } + } + + public function create($params) { + $basic_apiuser = $this->getModule('basic_apiuser'); + $basic_config = $this->getModule('basic_config'); + $misc = $this->getModule('misc'); + $basic_cfg = $basic_apiuser->getUsers(); + $username = ''; + $password = ''; + $props = []; + + if (property_exists($params, 'username') && key_exists($params->username, $basic_cfg)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_ALREADY_EXISTS; + $this->error = BasicUserError::ERROR_BASIC_USER_ALREADY_EXISTS; + return; + } + + if (property_exists($params, 'username') && $basic_apiuser->validateUsername($params->username)) { + $username = $params->username; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_USERNAME; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_USERNAME; + return; + } + + if (property_exists($params, 'password')) { + $password = $params->password; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_PASSWORD; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_PASSWORD; + return; + } + + if (property_exists($params, 'bconsole_cfg_path')) { + if ($misc->isValidPath($params->bconsole_cfg_path)) { + $props['bconsole_cfg_path'] = $params->bconsole_cfg_path; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH; + return; + } + } else { + $props['bconsole_cfg_path'] = ''; + } + + if (property_exists($params, 'console') && property_exists($params, 'director')) { + if (!$misc->isValidName($params->console)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_CONSOLE; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_CONSOLE; + return; + } + if (!$misc->isValidName($params->director)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_DIRECTOR; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_DIRECTOR; + return; + } + $bs = $this->getModule('bacula_setting'); + + $dir_cfg = $bs->getConfig('bcons', 'Director', $params->director); + if ($dir_cfg['exitcode'] != 0) { + $this->output = $dir_cfg['output']; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + return; + } + + $console_cfg = $bs->getConfig('dir', 'Console', $params->console); + if ($console_cfg['exitcode'] != 0) { + $this->output = $console_cfg['output']; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + return; + } + + $cfg = [ + [ + 'Director' => [ + 'Name' => '"' . $dir_cfg['output']['Name'] . '"', + 'DirPort' => $dir_cfg['output']['DirPort'], + 'Address' => $dir_cfg['output']['Address'], + 'Password' => 'XXXX' + ], + 'Console' => [ + 'Name' => '"' . $console_cfg['output']['Name'] . '"', + 'Password' => '"' . $console_cfg['output']['Password'] . '"' + ] + ] + ]; + $json_tools = $this->getModule('api_config')->getConfig('jsontools'); + $dir = $json_tools['bconfig_dir']; + $file = sprintf('%s/bconsole-%s.cfg', $dir, $console_cfg['output']['Name']); + $this->getModule('bacula_config')->setConfig('bcons', $cfg, $file); + $props['bconsole_cfg_path'] = $file; + } + + // save config + $result = $basic_config->addUser($username, $password, $props); + + if ($result) { + $this->output = $props; + $this->error = BasicUserError::ERROR_NO_ERRORS; + } else { + $this->output = BasicUserError::MSG_ERROR_INTERNAL_ERROR; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + } + } + + public function set($id, $params) { + $basic_apiuser = $this->getModule('basic_apiuser'); + $basic_config = $this->getModule('basic_config'); + $misc = $this->getModule('misc'); + $basic_cfg = $basic_apiuser->getUsers(); + $username = ''; + $password = ''; + $props = []; + + if (property_exists($params, 'username') && !key_exists($params->username, $basic_cfg)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_DOES_NOT_EXIST; + $this->error = BasicUserError::ERROR_BASIC_USER_DOES_NOT_EXIST; + return; + } + + if (property_exists($params, 'username') && $basic_apiuser->validateUsername($params->username)) { + $username = $params->username; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_USERNAME; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_USERNAME; + return; + } + + if (property_exists($params, 'password')) { + $password = $params->password; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_PASSWORD; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_PASSWORD; + return; + } + + if (property_exists($params, 'bconsole_cfg_path')) { + if ($misc->isValidPath($params->bconsole_cfg_path)) { + $props['bconsole_cfg_path'] = $params->bconsole_cfg_path; + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH; + return; + } + } else { + $props['bconsole_cfg_path'] = ''; + } + + if (property_exists($params, 'console') && property_exists($params, 'director')) { + if (!$misc->isValidName($params->console)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_CONSOLE; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_CONSOLE; + return; + } + if (!$misc->isValidName($params->director)) { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_INVALID_DIRECTOR; + $this->error = BasicUserError::ERROR_BASIC_USER_INVALID_DIRECTOR; + return; + } + $bs = $this->getModule('bacula_setting'); + + $dir_cfg = $bs->getConfig('bcons', 'Director', $params->director); + if ($dir_cfg['exitcode'] != 0) { + $this->output = $dir_cfg['output']; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + return; + } + + $console_cfg = $bs->getConfig('dir', 'Console', $params->console); + if ($console_cfg['exitcode'] != 0) { + $this->output = $console_cfg['output']; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + return; + } + + $cfg = [ + [ + 'Director' => [ + 'Name' => '"' . $dir_cfg['output']['Name'] . '"', + 'DirPort' => $dir_cfg['output']['DirPort'], + 'Address' => $dir_cfg['output']['Address'], + 'Password' => 'XXXX' + ], + 'Console' => [ + 'Name' => '"' . $console_cfg['output']['Name'] . '"', + 'Password' => '"' . $console_cfg['output']['Password'] . '"' + ] + ] + ]; + $json_tools = $this->getModule('api_config')->getConfig('jsontools'); + $dir = $json_tools['bconfig_dir']; + $file = sprintf('%s/bconsole-%s.cfg', $dir, $console_cfg['output']['Name']); + $this->getModule('bacula_config')->setConfig('bcons', $cfg, $file); + $props['bconsole_cfg_path'] = $file; + } + + // save config + $result = $basic_config->editUser($username, $password, $props); + + if ($result) { + $this->output = $props; + $this->error = BasicUserError::ERROR_NO_ERRORS; + } else { + $this->output = BasicUserError::MSG_ERROR_INTERNAL_ERROR; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + } + } + + public function remove($id) { + $user_cfg = $this->getModule('basic_apiuser')->getUserCfg($id); + if (count($user_cfg) > 0) { + $result = $this->getModule('basic_config')->removeUser($id); + if ($result) { + $this->output = []; + $this->error = BasicUserError::ERROR_NO_ERRORS; + } else { + $this->output = BasicUserError::MSG_ERROR_INTERNAL_ERROR; + $this->error = BasicUserError::ERROR_INTERNAL_ERROR; + } + } else { + $this->output = BasicUserError::MSG_ERROR_BASIC_USER_DOES_NOT_EXIST; + $this->error = BasicUserError::ERROR_BASIC_USER_DOES_NOT_EXIST; + } + } +} +?> diff --git a/gui/baculum/protected/API/Pages/API/BasicUsers.php b/gui/baculum/protected/API/Pages/API/BasicUsers.php new file mode 100644 index 000000000..7c676f234 --- /dev/null +++ b/gui/baculum/protected/API/Pages/API/BasicUsers.php @@ -0,0 +1,37 @@ + + * @category API + * @package Baculum API + */ +class BasicUsers extends BaculumAPIServer { + + public function get() { + $this->output = $this->getModule('basic_config')->getUsers();; + $this->error = ClientError::ERROR_NO_ERRORS; + } +} +?> diff --git a/gui/baculum/protected/API/Pages/API/OAuth2Client.php b/gui/baculum/protected/API/Pages/API/OAuth2Client.php index 52fbbf4dc..ab291bba4 100644 --- a/gui/baculum/protected/API/Pages/API/OAuth2Client.php +++ b/gui/baculum/protected/API/Pages/API/OAuth2Client.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2020 Kern Sibbald + * Copyright (C) 2013-2021 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -130,14 +130,14 @@ class OAuth2Client extends BaculumAPIServer { $dir_cfg = $bs->getConfig('bcons', 'Director', $params->director); if ($dir_cfg['exitcode'] != 0) { - $this->output = $dir_cfg->output; + $this->output = $dir_cfg['output']; $this->error = OAuth2Error::ERROR_INTERNAL_ERROR; return; } $console_cfg = $bs->getConfig('dir', 'Console', $params->console); if ($console_cfg['exitcode'] != 0) { - $this->output = $console_cfg->output; + $this->output = $console_cfg['output']; $this->error = OAuth2Error::ERROR_INTERNAL_ERROR; return; } @@ -257,14 +257,14 @@ class OAuth2Client extends BaculumAPIServer { $dir_cfg = $bs->getConfig('bcons', 'Director', $params->director); if ($dir_cfg['exitcode'] != 0) { - $this->output = $dir_cfg->output; + $this->output = $dir_cfg['output']; $this->error = OAuth2Error::ERROR_INTERNAL_ERROR; return; } $console_cfg = $bs->getConfig('dir', 'Console', $params->console); if ($console_cfg['exitcode'] != 0) { - $this->output = $console_cfg->output; + $this->output = $console_cfg['output']; $this->error = OAuth2Error::ERROR_INTERNAL_ERROR; return; } diff --git a/gui/baculum/protected/API/Pages/API/config.xml b/gui/baculum/protected/API/Pages/API/config.xml index a44502c1a..c5cc3731f 100644 --- a/gui/baculum/protected/API/Pages/API/config.xml +++ b/gui/baculum/protected/API/Pages/API/config.xml @@ -11,6 +11,7 @@ + diff --git a/gui/baculum/protected/API/Pages/API/endpoints.xml b/gui/baculum/protected/API/Pages/API/endpoints.xml index 6e54bf056..4f507d65d 100644 --- a/gui/baculum/protected/API/Pages/API/endpoints.xml +++ b/gui/baculum/protected/API/Pages/API/endpoints.xml @@ -109,6 +109,9 @@ + + + diff --git a/gui/baculum/protected/API/Pages/Panel/APIBasicUsers.php b/gui/baculum/protected/API/Pages/Panel/APIBasicUsers.php index d9c6f278a..ea93bc0fe 100644 --- a/gui/baculum/protected/API/Pages/Panel/APIBasicUsers.php +++ b/gui/baculum/protected/API/Pages/Panel/APIBasicUsers.php @@ -46,7 +46,7 @@ class APIBasicUsers extends BaculumAPIPage { } public function loadBasicUsers($sender, $param) { - $users = $this->getBasicUsers(); + $users = $this->getModule('basic_config')->getUsers(); $this->getCallbackClient()->callClientFunction( 'oAPIBasicUsers.load_basic_users_cb', [$users] @@ -74,23 +74,6 @@ class APIBasicUsers extends BaculumAPIPage { } } - private function getBasicUsers() { - $basic_users = array(); - $basic_apiuser = $this->getModule('basic_apiuser')->getUsers(); - $basic_config = $this->getModule('basic_config')->getConfig(); - foreach($basic_apiuser as $user => $pwd) { - $bconsole_cfg_path = ''; - if (key_exists($user, $basic_config) && key_exists('bconsole_cfg_path', $basic_config[$user])) { - $bconsole_cfg_path = $basic_config[$user]['bconsole_cfg_path']; - } - $basic_users[] = [ - 'username' => $user, - 'bconsole_cfg_path' => $bconsole_cfg_path - ]; - } - return $basic_users; - } - public function deleteBasicUser($sender, $param) { $username = $param->getCallbackParameter(); $this->getModule('basic_config')->removeUser($username); diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index 472c55d48..4df9b3e05 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -108,6 +108,15 @@ "OAuth2Client": { "$ref": "#/definitions/OAuth2Client" }, + "BasicUsers": { + "type": "array", + "items": { + "$ref": "#/definitions/BasicUser" + } + }, + "BasicUser": { + "$ref": "#/definitions/BasicUser" + }, "AutochangerDriveVolume": { "$ref": "#/definitions/AutochangerDriveVolume" }, @@ -5540,6 +5549,24 @@ "type": "string" } }, + { + "name": "console", + "in": "body", + "required": false, + "description": "Director Console name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'director' parameter.", + "schema": { + "type": "string" + } + }, + { + "name": "director", + "in": "body", + "required": false, + "description": "Director Name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'console' parameter.", + "schema": { + "type": "string" + } + }, { "name": "name", "in": "body", @@ -5625,6 +5652,24 @@ "type": "string" } }, + { + "name": "console", + "in": "body", + "required": false, + "description": "Director Console name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'director' parameter.", + "schema": { + "type": "string" + } + }, + { + "name": "director", + "in": "body", + "required": false, + "description": "Director Name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'console' parameter.", + "schema": { + "type": "string" + } + }, { "name": "name", "in": "body", @@ -5676,6 +5721,267 @@ } ] } + }, + "/api/v2/basic/users": { + "get": { + "tags": ["basic"], + "summary": "Basic user list", + "description": "Get Basic user list.", + "responses": { + "200": { + "description": "List of Basic users properties", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "$ref": "#/components/schemas/BasicUsers" + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 1000] + } + } + } + } + } + } + } + } + }, + "/api/v2/basic/users/{username}": { + "get": { + "tags": ["basic"], + "summary": "Specific Basic user config", + "description": "Get specific Basic user config", + "responses": { + "200": { + "description": "Specific Basic user config", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "$ref": "#/components/schemas/BasicUser" + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 140, 142, 1000] + } + } + } + } + } + } + }, + "parameters": [ + { + "name": "username", + "in": "path", + "required": true, + "description": "Basic user name", + "schema": { + "type": "string" + } + } + ] + }, + "put": { + "tags": ["basic"], + "summary": "Set Basic user settings", + "description": "Set specific Basic user settings", + "consumes": [ "application/json" ], + "responses": { + "200": { + "description": "Set Basic user settings", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "type": "object", + "description": "Updated Basic user settings" + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 140, 142, 143, 144, 145, 146, 1000] + } + } + } + } + } + } + }, + "parameters": [ + { + "name": "username", + "in": "path", + "required": true, + "description": "Basic user name", + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "body", + "required": false, + "description": "Basic user password", + "schema": { + "type": "string" + } + }, + { + "name": "bconsole_cfg_path", + "in": "body", + "required": false, + "description": "Dedicated Bconsole configuration file path", + "schema": { + "type": "string" + } + }, + { + "name": "console", + "in": "body", + "required": false, + "description": "Director Console name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'director' parameter.", + "schema": { + "type": "string" + } + }, + { + "name": "director", + "in": "body", + "required": false, + "description": "Director Name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'console' parameter.", + "schema": { + "type": "string" + } + } + ] + }, + "post": { + "tags": ["basic"], + "summary": "Create Basic user account", + "description": "Create specific Basic user account", + "consumes": [ "application/json" ], + "responses": { + "200": { + "description": "Create Basic user account", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "type": "object", + "description": "New Basic user settings" + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 141, 142, 143, 144, 145, 146, 1000] + } + } + } + } + } + } + }, + "parameters": [ + { + "name": "username", + "in": "path", + "required": true, + "description": "Basic user name", + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "body", + "required": true, + "description": "Basic user password", + "schema": { + "type": "string" + } + }, + { + "name": "bconsole_cfg_path", + "in": "body", + "required": false, + "description": "Dedicated Bconsole configuration file path", + "schema": { + "type": "string" + } + }, + { + "name": "console", + "in": "body", + "required": false, + "description": "Director Console name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'director' parameter.", + "schema": { + "type": "string" + } + }, + { + "name": "director", + "in": "body", + "required": false, + "description": "Director Name to create dedicated bconsole.conf that is assigned to account. Parameter must be used together with 'console' parameter.", + "schema": { + "type": "string" + } + } + ] + }, + "delete": { + "tags": ["basic"], + "summary": "Delete Basic user account", + "description": "Delete Basic user account.", + "responses": { + "200": { + "description": "Delete Basic user account", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "type": "array", + "items": { + } + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 140, 1000] + } + } + } + } + } + } + }, + "parameters": [ + { + "name": "username", + "in": "path", + "required": true, + "description": "Basic user name", + "schema": { + "type": "string" + } + } + ] + } } }, "definitions": { @@ -6340,6 +6646,19 @@ } } }, + "BasicUser": { + "type": "object", + "properties": { + "bconsole_cfg_path": { + "description": "Dedicated Bconsole configuration file", + "type": "string" + }, + "username": { + "description": "User login name", + "type": "string" + } + } + }, "AutochangerDriveVolume": { "type": "object", "properties": { diff --git a/gui/baculum/protected/Common/Class/BasicUserConfig.php b/gui/baculum/protected/Common/Class/BasicUserConfig.php index 68c340e09..0b5d891a6 100644 --- a/gui/baculum/protected/Common/Class/BasicUserConfig.php +++ b/gui/baculum/protected/Common/Class/BasicUserConfig.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2020 Kern Sibbald + * Copyright (C) 2013-2021 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -41,6 +41,11 @@ class BasicUserConfig extends CommonModule { */ const USER_PATTERN = '[a-zA-Z0-9]+'; + /** + * Password allowed characters pattern. + */ + const PASSWORD_PATTERN = '[\S\s]{5,60}'; + /** * Get config file path to store users' parameters. * @return string config path @@ -195,7 +200,6 @@ class BasicUserConfig extends CommonModule { * @return boolean true if users removed successfully, otherwise false */ public function removeUsers(array $usernames) { - $result = false; $all_users = $this->getUsers(); for ($i = 0; $i < count($usernames); $i++) { if (key_exists($usernames[$i], $all_users)) { @@ -225,4 +229,8 @@ class BasicUserConfig extends CommonModule { $result = file_put_contents($this->getConfigPath(), '', LOCK_EX) !== false; return $result; } + + public function validateUsername($username) { + return (preg_match('/^' . self::USER_PATTERN . '$/', $username) === 1); + } } diff --git a/gui/baculum/protected/Common/Class/Errors.php b/gui/baculum/protected/Common/Class/Errors.php index b5537b34c..3ed0823ca 100644 --- a/gui/baculum/protected/Common/Class/Errors.php +++ b/gui/baculum/protected/Common/Class/Errors.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2020 Kern Sibbald + * Copyright (C) 2013-2021 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -247,4 +247,22 @@ class DeviceError extends GenericError { const MSG_ERROR_DEVICE_DRIVE_DOES_NOT_BELONG_TO_AUTOCHANGER = 'Drive does not belong to selected autochanger.'; } +class BasicUserError extends GenericError { + + const ERROR_BASIC_USER_DOES_NOT_EXIST = 140; + const ERROR_BASIC_USER_ALREADY_EXISTS = 141; + const ERROR_BASIC_USER_INVALID_USERNAME = 142; + const ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH = 143; + const ERROR_BASIC_USER_INVALID_CONSOLE = 144; + const ERROR_BASIC_USER_INVALID_DIRECTOR = 145; + const ERROR_BASIC_USER_INVALID_PASSWORD= 146; + + const MSG_ERROR_BASIC_USER_DOES_NOT_EXIST = 'Basic user does not exist.'; + const MSG_ERROR_BASIC_USER_ALREADY_EXISTS = 'Basic user already exists.'; + const MSG_ERROR_BASIC_USER_INVALID_USERNAME = 'Invalid basic user username'; + const MSG_ERROR_BASIC_USER_INVALID_BCONSOLE_CFG_PATH = 'Invalid bconsole config path.'; + const MSG_ERROR_BASIC_USER_INVALID_CONSOLE = 'Invalid Console name.'; + const MSG_ERROR_BASIC_USER_INVALID_DIRECTOR = 'Invalid Director name.'; + const MSG_ERROR_BASIC_USER_INVALID_PASSWORD = 'Invalid password.'; +} ?> diff --git a/gui/baculum/protected/Common/Portlets/NewAuthClient.tpl b/gui/baculum/protected/Common/Portlets/NewAuthClient.tpl index 13fbe95b3..40b34ff14 100644 --- a/gui/baculum/protected/Common/Portlets/NewAuthClient.tpl +++ b/gui/baculum/protected/Common/Portlets/NewAuthClient.tpl @@ -62,7 +62,7 @@ Display="Dynamic" ControlCssClass="invalidate" ControlToValidate="APIBasicPassword" - RegularExpression="[\S\s]{5,60}" + RegularExpression="<%=BasicUserConfig::PASSWORD_PATTERN%>" ValidationGroup="<%=$this->ClientID%>Basic" Text="<%[ Password must be longer than 4 chars. ]%>" /> @@ -96,7 +96,7 @@ Display="Dynamic" ControlCssClass="invalidate" ControlToValidate="RetypeAPIBasicPassword" - RegularExpression="[\S\s]{5,60}" + RegularExpression="<%=BasicUserConfig::PASSWORD_PATTERN%>" ValidationGroup="<%=$this->ClientID%>Basic" Text="<%[ Password must be longer than 4 chars. ]%>" /> -- 2.47.3