Compare commits

...

135 Commits

Author SHA1 Message Date
TIP Automation User
35ff346901 Chg: update image tag in helm values to v2.8.0 2023-01-03 21:56:53 +00:00
TIP Automation User
03b39d9d1c Chg: update image tag in helm values to v2.8.0-RC2 2022-12-16 14:51:54 +00:00
Stephane Bourque
1a15c4744b Merge pull request #103 from Telecominfraproject/main
https://telecominfraproject.atlassian.net/browse/WIFI-11974
2022-12-14 20:53:51 -08:00
Stephane Bourque
0417162858 Merge pull request #102 from Telecominfraproject/WIFI-11974
https://telecominfraproject.atlassian.net/browse/WIFI-11974
2022-12-14 11:52:00 -08:00
stephb9959
75b2b30b67 https://telecominfraproject.atlassian.net/browse/WIFI-11974
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-12-14 11:51:34 -08:00
TIP Automation User
73f96b3ad8 Chg: update image tag in helm values to v2.8.0-RC1 2022-12-13 23:08:41 +00:00
Stephane Bourque
abc06d7953 Merge pull request #101 from Telecominfraproject/WIFI-10877
https://telecominfraproject.atlassian.net/browse/WIFI-10877
2022-12-12 14:34:25 -08:00
stephb9959
7993e7d345 https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-12-12 14:33:46 -08:00
stephb9959
be4549fabb https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-12-12 14:33:36 -08:00
Stephane Bourque
92c141e511 Merge pull request #100 from Telecominfraproject/WIFI-10877
https://telecominfraproject.atlassian.net/browse/WIFI-10877
2022-11-30 22:14:50 -08:00
stephb9959
296713e853 https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-30 22:13:54 -08:00
Stephane Bourque
d6dee68880 Merge pull request #99 from Telecominfraproject/WIFI-10877
https://telecominfraproject.atlassian.net/browse/WIFI-10877
2022-11-30 22:13:38 -08:00
stephb9959
aaffa145ad https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-30 22:12:08 -08:00
Stephane Bourque
c8e894bf79 Merge pull request #98 from Telecominfraproject/WIFI-10877
https://telecominfraproject.atlassian.net/browse/WIFI-10877
2022-11-30 11:54:28 -08:00
stephb9959
766a608e1b https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-30 11:52:44 -08:00
Stephane Bourque
333316d7a9 Merge pull request #97 from Telecominfraproject/WIFI-10877
https://telecominfraproject.atlassian.net/browse/WIFI-10877
2022-11-29 21:37:44 -08:00
stephb9959
6527b45f2f https://telecominfraproject.atlassian.net/browse/WIFI-10877
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-29 21:37:04 -08:00
Dmitry Dunaev
76ef41aefe Merge pull request #96 from Telecominfraproject/feature/wifi-11729--pages-docs
[WIFI-11729] Add: README info
2022-11-29 15:00:38 +03:00
Dmitry Dunaev
7e988c5780 [WIFI-11729] Add: README info
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-11-29 14:59:59 +03:00
Dmitry Dunaev
2080027d7c Merge pull request #95 from Telecominfraproject/feature/wifi-11729--pages-docs
[WIFI-11729] Fix: gh-pages file
2022-11-29 14:37:43 +03:00
Dmitry Dunaev
b8a14e95d8 [WIFI-11729] Fix: gh-pages file
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-11-29 14:35:38 +03:00
Dmitry Dunaev
8966888e6b Merge pull request #94 from Telecominfraproject/feature/wifi-11729--pages-docs
[WIFI-11729] Fix: OpenAPI file loc
2022-11-29 14:33:38 +03:00
Dmitry Dunaev
0ad79b8076 [WIFI-11729] Fix: OpenAPI file loc
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-11-29 14:32:18 +03:00
Dmitry Dunaev
f650a6fde4 Merge pull request #93 from Telecominfraproject/feature/wifi-11729--pages-docs
[WIFI-11729] Add: workflow to generate docs to GitHub pages
2022-11-29 14:28:59 +03:00
Dmitry Dunaev
a6b7057c9b [WIFI-11729] Add: workflow to generate docs to GitHub pages
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-11-29 14:28:32 +03:00
stephb9959
6a1fa01235 https://telecominfraproject.atlassian.net/browse/WIFI-11755
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-27 21:31:44 -08:00
stephb9959
f554e73b91 Merge remote-tracking branch 'origin/main' 2022-11-27 14:34:24 -08:00
stephb9959
2316dca6ce https://telecominfraproject.atlassian.net/browse/WIFI-11755
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-27 14:34:16 -08:00
Johann Hoffmann
2395423832 [WIFI-11419] Patch workflows with regard to deprecated Github actions commands (#92)
* Update checkout action version and replace set-output commands

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix output variable assignment

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-11-25 15:33:04 +01:00
Johann Hoffmann
43363e6854 Set vcpkg to fixed version
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-11-22 14:11:11 +01:00
Johann Hoffmann
2ab3d6a53d Revert "Update checkout action version and replace set-output commands"
This reverts commit 561fc84958.

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-11-22 12:21:00 +01:00
Johann Hoffmann
561fc84958 Update checkout action version and replace set-output commands
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-11-22 12:20:19 +01:00
stephb9959
afbe50b65d https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-21 09:14:19 -08:00
stephb9959
15b5551cd8 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-21 07:40:32 -08:00
stephb9959
717ab7451f https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-18 19:54:19 -08:00
stephb9959
8afba9650b https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-18 07:34:55 -08:00
stephb9959
155d6ba319 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-18 07:24:06 -08:00
stephb9959
66f4742ca5 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-17 21:27:53 -08:00
stephb9959
ad1bc551db https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-16 23:05:32 -08:00
stephb9959
9926b551f5 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-16 12:29:53 -08:00
stephb9959
1dfd7969ea https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-16 10:34:47 -08:00
stephb9959
a62e34fdf8 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-16 10:23:56 -08:00
stephb9959
45deeaea88 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-14 09:52:52 -08:00
stephb9959
c5aadffe1d https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-14 09:17:29 -08:00
stephb9959
d10883b60d https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-13 22:22:51 -08:00
stephb9959
d38db8e05b https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-12 22:28:32 -08:00
stephb9959
8ea43f455c https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-09 22:30:34 -08:00
stephb9959
f653083548 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-09 22:26:41 -08:00
stephb9959
66c50b27bf Merge remote-tracking branch 'origin/main' 2022-11-08 23:09:31 -08:00
stephb9959
351dd650fa https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-08 23:09:23 -08:00
Dmitry Dunaev
8550675c04 Merge pull request #91 from Telecominfraproject/fix/wifi-11490--git-hash
[WIFI-11490] Fix: Get Git hash command in CMakeLists
2022-11-08 14:17:07 +03:00
Dmitry Dunaev
76864c21d7 [WIFI-11490] Fix: Get Git hash command in CMakeLists
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-11-08 13:41:47 +03:00
stephb9959
696ee32ef3 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 21:18:46 -08:00
stephb9959
780d6654fb https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 16:04:24 -08:00
stephb9959
b195763518 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 15:43:31 -08:00
stephb9959
6543f44eab https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:56:01 -08:00
stephb9959
9b5aa5dd5d https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:46:46 -08:00
stephb9959
3062424816 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:44:58 -08:00
stephb9959
41bd759d03 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:40:08 -08:00
stephb9959
a27cd109e8 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:33:21 -08:00
stephb9959
ec03bc6710 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:22:43 -08:00
stephb9959
f00de63289 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 14:07:49 -08:00
stephb9959
becd374124 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 13:56:27 -08:00
stephb9959
89256bb900 https://telecominfraproject.atlassian.net/browse/WIFI-10918
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-07 13:37:06 -08:00
stephb9959
a1634770bc Merge remote-tracking branch 'origin/main' 2022-11-04 10:13:52 -07:00
stephb9959
6db6e51ef3 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-04 10:13:43 -07:00
Stephane Bourque
1ada42bdcb Merge pull request #89 from Telecominfraproject/WIFI-10959-switch-fmtlib-and-awssdk
[WIFI-10959] Switch fmtlib and aws to prebuilt packages in Dockerfiles
2022-11-03 23:26:47 -07:00
Stephane Bourque
6bbcca57ae Merge branch 'main' into WIFI-10959-switch-fmtlib-and-awssdk 2022-11-03 23:26:40 -07:00
stephb9959
447ab2a705 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-03 23:14:48 -07:00
stephb9959
ae251f9d35 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-03 10:27:19 -07:00
stephb9959
729b1e6708 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-03 09:34:43 -07:00
stephb9959
514bb3e622 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-02 22:50:10 -07:00
stephb9959
087265b8b7 Removing project files 2022-11-02 22:45:54 -07:00
stephb9959
ccd5498f19 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-11-02 22:42:06 -07:00
stephb9959
1688f5a39d Merge remote-tracking branch 'origin/main' 2022-10-31 11:19:39 -07:00
stephb9959
1b185515ce https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-31 11:19:29 -07:00
Dmitry Dunaev
3c45f07cee Merge pull request #90 from Telecominfraproject/feature/wifi-9942--sqlite
[WIFI-9942] Add: sqlite package
2022-10-31 12:04:28 +03:00
Dmitry Dunaev
a493c9190e [WIFI-9942] Add: sqlite package
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-31 12:04:07 +03:00
stephb9959
fda8afd90c https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-30 10:15:38 -07:00
stephb9959
a18cb37671 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-29 21:49:01 -07:00
stephb9959
2c85a691bb https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-27 23:25:53 -07:00
stephb9959
e8800782b4 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-27 09:48:59 -07:00
stephb9959
d0e818805a https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-27 09:36:20 -07:00
stephb9959
02ad85ca73 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-26 21:55:37 -07:00
stephb9959
0ca578e9ec https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-26 21:38:41 -07:00
Stephane Bourque
d351522441 https://telecominfraproject.atlassian.net/browse/WIFI-11303
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-26 21:33:11 -07:00
Johann Hoffmann
401419e060 Fix required aws-sdk-cpp feature name
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-10-20 17:59:23 +02:00
Johann Hoffmann
a8b0b46b1a Install AWS SDK and json-schema-validator via vcpkg
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-10-20 17:16:25 +02:00
Dmitry Dunaev
d4fe199b0d Merge pull request #88 from Telecominfraproject/security/wifi-11170--docker-image-version
[WIFI-11170] Chg: upgrade base Debian image
2022-10-11 14:58:07 +03:00
Dmitry Dunaev
52bbf884f9 [WIFI-11170] Chg: upgrade base Debian image
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-11 14:57:54 +03:00
stephb9959
e398d3cf4b Merge remote-tracking branch 'origin/main' 2022-10-04 08:10:32 -07:00
stephb9959
f53cc82df1 https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-04 08:10:24 -07:00
Johann Hoffmann
3f9edc80e0 Add userRole argument to createuser and createuser_v functions
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-10-04 13:15:30 +02:00
Dmitry Dunaev
6ae42fe206 [WIFI-10581] Fix: Helm image to main
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-03 12:11:37 +03:00
Dmitry Dunaev
4539bfb53b Merge pull request #83 from Telecominfraproject/fix/wifi-10581--postgres-client
[WIFI-10581] Add: postgresql-client in Dockerfile
2022-10-03 11:22:33 +03:00
Dmitry Dunaev
dc57a94416 [WIFI-10581] Add: postgresql-client in Dockerfile
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-03 11:22:14 +03:00
stephb9959
6025b7a74e https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-02 23:00:31 -07:00
stephb9959
3fcf6114c0 https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-02 22:36:33 -07:00
stephb9959
de0c1423af Merge remote-tracking branch 'origin/main' 2022-10-02 22:21:37 -07:00
stephb9959
f4984247d2 https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-02 22:21:30 -07:00
stephb9959
e0b80a2640 Merge remote-tracking branch 'origin/main' 2022-10-02 22:09:02 -07:00
stephb9959
f2c36882be https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-10-02 22:08:54 -07:00
stephb9959
3a1e4d66b4 https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-10-02 21:51:32 -07:00
stephb9959
6ea62c12c5 https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-10-02 14:35:59 -07:00
stephb9959
517b46d275 Merge remote-tracking branch 'origin/main' 2022-10-02 14:22:10 -07:00
Stephane Bourque
2503cb842e https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-10-02 14:22:01 -07:00
Stephane Bourque
2878e2aa25 Merge branch 'release/v2.7.0' into main 2022-10-02 11:03:35 -07:00
Stephane Bourque
3b7e6da952 Merge pull request #80 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-10-02 11:00:03 -07:00
Stephane Bourque
bbf1c61ea8 Merge branch 'main' into WIFI-10942 2022-10-02 10:59:56 -07:00
Stephane Bourque
e76fedb207 https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-10-02 10:58:25 -07:00
Stephane Bourque
4ab026b88c Merge pull request #68 from Telecominfraproject/WIFI-10581-switch-images-to-debian-slim
[WIFI-10581] Switch microservice Docker images from Alpine to Debian-slim
2022-10-02 10:52:40 -07:00
TIP Automation User
06267690fc Chg: update image tag in helm values to v2.7.0-RC3 2022-09-30 16:31:27 +00:00
Stephane Bourque
db751e31a3 Merge pull request #79 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-09-30 08:52:49 -07:00
stephb9959
49b8664dc0 https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-09-30 08:44:56 -07:00
TIP Automation User
26e54f8433 Chg: update image tag in helm values to v2.7.0-RC2 2022-09-29 23:27:33 +00:00
jaspreetsachdev
a4ebfdc2e9 Merge pull request #78 from Telecominfraproject/main
Fixes for WIFI-10245 and others
2022-09-29 19:17:40 -04:00
Dmitry Dunaev
7cf7d011bd Merge pull request #77 from Telecominfraproject/feature/wifi-10932--docker-support-http
[WIFI-10932] Add: restapi disable property in docker entrypoint
2022-09-28 17:39:40 +03:00
Dmitry Dunaev
bce53ff61c [WIFI-10932] Add: restapi disable property in docker entrypoint
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-28 17:39:20 +03:00
Dmitry Dunaev
428a2edcdf Merge pull request #76 from Telecominfraproject/feature/wifi-10582--helm-global-cert-secret
[WIFI-10582] Add: functionality to use external existing certificates secret
2022-09-28 17:06:12 +03:00
Dmitry Dunaev
ac897e8a8b [WIFI-10582] Add: functionality to use external existing certificates secret
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-28 13:34:26 +03:00
Stephane Bourque
939869948f Merge pull request #75 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-09-26 13:32:13 -07:00
stephb9959
85a4661914 https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-26 13:31:31 -07:00
Stephane Bourque
adce4a8238 Merge pull request #74 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-09-22 21:57:11 -07:00
stephb9959
180d270f9b https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-22 21:56:42 -07:00
Stephane Bourque
6a44c0a220 Merge pull request #73 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-09-22 20:34:38 -07:00
stephb9959
87c8084c89 https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-22 20:34:15 -07:00
Stephane Bourque
d65d1418a2 Merge pull request #72 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-09-22 13:53:22 -07:00
stephb9959
5bb1a1b68a https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-22 13:52:48 -07:00
Stephane Bourque
003662508e Merge pull request #71 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-09-21 19:47:49 -07:00
stephb9959
bdf577ecbe https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-21 19:47:20 -07:00
TIP Automation User
4b1fbf055f Chg: update image tag in helm values to v2.7.0-RC1 2022-09-16 19:54:50 +00:00
Dmitry Dunaev
8b5c9dd5e9 Merge pull request #70 from Telecominfraproject/feature/wifi-10069--add-wait-postgres-initcontainer
[WIFI-10069] Add: helm - wait-postgres init container
2022-09-02 14:44:45 +03:00
Dmitry Dunaev
02a315ab0d [WIFI-10069] Add: helm - wait-postgres init container
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-02 14:44:27 +03:00
Stephane Bourque
1e4d9ea4e8 Merge pull request #69 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-08-22 08:52:22 -07:00
stephb9959
0b1d7e39eb https://telecominfraproject.atlassian.net/browse/WIFI-10245
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-08-22 08:51:43 -07:00
203 changed files with 16608 additions and 10686 deletions

View File

@@ -27,7 +27,7 @@ jobs:
DOCKER_REGISTRY_USERNAME: ucentral DOCKER_REGISTRY_USERNAME: ucentral
steps: steps:
- name: Checkout actions repo - name: Checkout actions repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
repository: Telecominfraproject/.github repository: Telecominfraproject/.github
path: github path: github
@@ -58,11 +58,11 @@ jobs:
- name: Get base branch name and set as output - name: Get base branch name and set as output
id: get_base_branch id: get_base_branch
run: | run: |
echo ::set-output name=branch::$(echo ${GITHUB_BASE_REF##*/}) echo "branch=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_OUTPUT
echo ::set-output name=owgw_branch::$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g') echo "owgw_branch=$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g')" >> $GITHUB_OUTPUT
- name: Checkout actions repo - name: Checkout actions repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
repository: Telecominfraproject/.github repository: Telecominfraproject/.github
path: github path: github
@@ -87,7 +87,7 @@ jobs:
- docker - docker
steps: steps:
- name: Checkout actions repo - name: Checkout actions repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
repository: Telecominfraproject/.github repository: Telecominfraproject/.github
path: github path: github

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout actions repo - name: Checkout actions repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
repository: Telecominfraproject/.github repository: Telecominfraproject/.github
path: github path: github

38
.github/workflows/openapi-pages.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Update OpenAPI docs on GitHub Pages
on:
push:
paths:
- 'openapi/**'
branches:
- main
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
docsgen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate static HTML page with docs from OpenAPI definition
run: |
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v6.2.1 generate -i https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentralsec/main/openpapi/owsec.yaml -g html2 --skip-validate-spec -o /local/
- name: Update OpenAPI docs
run: |
mkdir -p ~/.ssh
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
echo https://tip-automation:${{ secrets.GIT_PUSH_PAT }}@github.com > ~/.git-credentials
git config --global credential.helper store
git config --global user.email "tip-automation@telecominfraproject.com"
git config --global user.name "TIP Automation User"
git pull
git checkout gh-pages || git checkout -b gh-pages
mv index.html docs/index.html
git add docs
git commit -m'Update OpenAPI docs for GitHub pages'
git push --set-upstream origin gh-pages

View File

@@ -17,7 +17,7 @@ jobs:
HELM_REPO_USERNAME: ucentral HELM_REPO_USERNAME: ucentral
steps: steps:
- name: Checkout uCentral assembly chart repo - name: Checkout uCentral assembly chart repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
path: wlan-cloud-ucentralsec path: wlan-cloud-ucentralsec

21
.idea/.gitignore generated vendored
View File

@@ -1,21 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
/certs/
/logs/
*.csr
*.db
/docker-compose/certs/
/docker-compose/*-data/data/
/docker-compose/*-data/uploads/
/docker-compose/.env
/docker-compose/.env_*
/cmake-build/
*.pem
result.json
token.json

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(owsec VERSION 2.7.0) project(owsec VERSION 2.8.0)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
@@ -32,12 +32,12 @@ endif()
find_package(Git QUIET) find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_RESULT RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_HASH) OUTPUT_VARIABLE GIT_HASH)
if(NOT GIT_RESULT EQUAL "0") if(NOT GIT_RESULT EQUAL "0")
message(FATAL_ERROR "git describe --always --tags failed with ${GIT_RESULT}") message(FATAL_ERROR "git rev-parse --short HEAD failed with ${GIT_RESULT}")
endif() endif()
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}") string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
endif() endif()
@@ -47,6 +47,7 @@ add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
set(BUILD_SHARED_LIBS 1) set(BUILD_SHARED_LIBS 1)
add_definitions(-DTIP_SECURITY_SERVICE="1") add_definitions(-DTIP_SECURITY_SERVICE="1")
add_definitions(-DPOCO_LOG_DEBUG="1")
add_compile_options(-Wall -Wextra) add_compile_options(-Wall -Wextra)
if(ASAN) if(ASAN)
@@ -74,18 +75,63 @@ add_executable( owsec
src/framework/CountryCodes.h src/framework/CountryCodes.h
src/framework/KafkaTopics.h src/framework/KafkaTopics.h
src/framework/MicroService.h src/framework/MicroService.h
src/framework/OpenWifiTypes.h
src/framework/orm.h src/framework/orm.h
src/framework/StorageClass.h src/framework/StorageClass.h
src/framework/ow_constants.h src/framework/MicroServiceErrorHandler.h
src/framework/WebSocketClientNotifications.h src/framework/UI_WebSocketClientServer.cpp
src/framework/UI_WebSocketClientServer.h
src/framework/UI_WebSocketClientNotifications.cpp
src/framework/UI_WebSocketClientNotifications.h
src/framework/utils.h
src/framework/utils.cpp
src/framework/AppServiceRegistry.h
src/framework/SubSystemServer.cpp
src/framework/SubSystemServer.h
src/framework/RESTAPI_utils.h
src/framework/AuthClient.cpp
src/framework/AuthClient.h
src/framework/MicroServiceNames.h
src/framework/MicroServiceFuncs.h
src/framework/OpenAPIRequests.cpp
src/framework/OpenAPIRequests.h
src/framework/MicroServiceFuncs.cpp
src/framework/ALBserver.cpp
src/framework/ALBserver.h
src/framework/KafkaManager.cpp
src/framework/KafkaManager.h
src/framework/RESTAPI_RateLimiter.h
src/framework/WebSocketLogger.h
src/framework/RESTAPI_GenericServerAccounting.h
src/framework/RESTAPI_SystemConfiguration.h
src/framework/CIDR.h
src/framework/RESTAPI_Handler.cpp
src/framework/RESTAPI_Handler.h
src/framework/RESTAPI_ExtServer.h
src/framework/RESTAPI_ExtServer.cpp
src/framework/RESTAPI_IntServer.cpp
src/framework/RESTAPI_IntServer.h
src/framework/RESTAPI_SystemCommand.h
src/framework/RESTAPI_WebSocketServer.h
src/framework/EventBusManager.cpp
src/framework/EventBusManager.h
src/framework/RESTAPI_PartHandler.h
src/framework/MicroService.cpp
src/framework/MicroServiceExtra.h
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.cpp
src/RESTObjects/RESTAPI_CertObjects.cpp src/RESTObjects/RESTAPI_CertObjects.h
src/RESTObjects/RESTAPI_OWLSobjects.cpp src/RESTObjects/RESTAPI_OWLSobjects.h
src/RESTObjects/RESTAPI_ProvObjects.cpp src/RESTObjects/RESTAPI_ProvObjects.h
src/RESTObjects/RESTAPI_AnalyticsObjects.cpp src/RESTObjects/RESTAPI_AnalyticsObjects.h
src/RESTObjects/RESTAPI_SubObjects.cpp src/RESTObjects/RESTAPI_SubObjects.h
src/seclibs/qrcode/qrcodegen.hpp src/seclibs/qrcode/qrcodegen.cpp src/seclibs/qrcode/qrcodegen.hpp src/seclibs/qrcode/qrcodegen.cpp
src/seclibs/cpptotp/bytes.cpp src/seclibs/cpptotp/bytes.h src/seclibs/cpptotp/bytes.cpp src/seclibs/cpptotp/bytes.h
src/seclibs/cpptotp/otp.cpp src/seclibs/cpptotp/otp.h src/seclibs/cpptotp/otp.cpp src/seclibs/cpptotp/otp.h
src/seclibs/cpptotp/sha1.cpp src/seclibs/cpptotp/sha1.h src/seclibs/cpptotp/sha1.cpp src/seclibs/cpptotp/sha1.h
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
src/RESTObjects/RESTAPI_ProvObjects.cpp src/RESTObjects/RESTAPI_ProvObjects.h
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.cpp
src/RESTAPI/RESTAPI_oauth2_handler.h src/RESTAPI/RESTAPI_oauth2_handler.cpp src/RESTAPI/RESTAPI_oauth2_handler.h src/RESTAPI/RESTAPI_oauth2_handler.cpp
src/RESTAPI/RESTAPI_users_handler.cpp src/RESTAPI/RESTAPI_users_handler.h src/RESTAPI/RESTAPI_users_handler.cpp src/RESTAPI/RESTAPI_users_handler.h
src/RESTAPI/RESTAPI_user_handler.cpp src/RESTAPI/RESTAPI_user_handler.h src/RESTAPI/RESTAPI_user_handler.cpp src/RESTAPI/RESTAPI_user_handler.h
@@ -117,14 +163,19 @@ add_executable( owsec
src/SMS_provider_twilio.cpp src/SMS_provider_twilio.h src/SMS_provider_twilio.cpp src/SMS_provider_twilio.h
src/ActionLinkManager.cpp src/ActionLinkManager.h src/ActionLinkManager.cpp src/ActionLinkManager.h
src/ACLProcessor.h src/ACLProcessor.h
src/framework/OpenWifiTypes.h
src/storage/orm_users.cpp src/storage/orm_users.h src/storage/orm_users.cpp src/storage/orm_users.h
src/storage/orm_tokens.cpp src/storage/orm_tokens.h src/storage/orm_tokens.cpp src/storage/orm_tokens.h
src/storage/orm_preferences.cpp src/storage/orm_preferences.h src/storage/orm_preferences.cpp src/storage/orm_preferences.h
src/storage/orm_actionLinks.cpp src/storage/orm_actionLinks.h src/storage/orm_actionLinks.cpp src/storage/orm_actionLinks.h
src/storage/orm_avatar.cpp src/storage/orm_avatar.h src/storage/orm_avatar.cpp src/storage/orm_avatar.h
src/SpecialUserHelpers.h src/SpecialUserHelpers.h
src/RESTAPI/RESTAPI_db_helpers.h src/storage/orm_logins.cpp src/storage/orm_logins.h src/RESTAPI/RESTAPI_totp_handler.cpp src/RESTAPI/RESTAPI_totp_handler.h src/TotpCache.h src/RESTAPI/RESTAPI_subtotp_handler.cpp src/RESTAPI/RESTAPI_subtotp_handler.h src/RESTAPI/RESTAPI_signup_handler.cpp src/RESTAPI/RESTAPI_signup_handler.h src/MessagingTemplates.cpp src/MessagingTemplates.h) src/RESTAPI/RESTAPI_db_helpers.h src/storage/orm_logins.cpp src/storage/orm_logins.h
src/RESTAPI/RESTAPI_totp_handler.cpp
src/RESTAPI/RESTAPI_totp_handler.h
src/TotpCache.h
src/RESTAPI/RESTAPI_subtotp_handler.cpp src/RESTAPI/RESTAPI_subtotp_handler.h
src/RESTAPI/RESTAPI_signup_handler.cpp src/RESTAPI/RESTAPI_signup_handler.h
src/MessagingTemplates.cpp src/MessagingTemplates.h src/RESTAPI/RESTAPI_apiKey_handler.cpp src/RESTAPI/RESTAPI_apiKey_handler.h src/storage/orm_apikeys.cpp src/storage/orm_apikeys.h src/RESTAPI/RESTAPI_validate_apikey.cpp src/RESTAPI/RESTAPI_validate_apikey.h)
if(NOT SMALL_BUILD) if(NOT SMALL_BUILD)
target_link_libraries(owsec PUBLIC target_link_libraries(owsec PUBLIC
@@ -138,4 +189,4 @@ if(NOT SMALL_BUILD)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
target_link_libraries(owsec PUBLIC PocoJSON) target_link_libraries(owsec PUBLIC PocoJSON)
endif() endif()
endif() endif()

View File

@@ -1,17 +1,14 @@
ARG DEBIAN_VERSION=11.4-slim ARG DEBIAN_VERSION=11.5-slim
ARG POCO_VERSION=poco-tip-v1 ARG POCO_VERSION=poco-tip-v2
ARG FMTLIB_VERSION=9.0.0
ARG CPPKAFKA_VERSION=tip-v1 ARG CPPKAFKA_VERSION=tip-v1
ARG JSON_VALIDATOR_VERSION=2.1.0
ARG AWS_SDK_VERSION=1.9.315
FROM debian:$DEBIAN_VERSION AS build-base FROM debian:$DEBIAN_VERSION AS build-base
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && apt-get install --no-install-recommends -y \
make cmake g++ git \ make cmake g++ git curl zip unzip pkg-config \
unixodbc-dev libpq-dev libmariadb-dev libmariadbclient-dev-compat \ libpq-dev libmariadb-dev libmariadbclient-dev-compat \
librdkafka-dev libboost-all-dev libssl-dev \ librdkafka-dev libboost-all-dev libssl-dev \
zlib1g-dev nlohmann-json3-dev ca-certificates libcurl4-openssl-dev zlib1g-dev ca-certificates libcurl4-openssl-dev libfmt-dev
FROM build-base AS poco-build FROM build-base AS poco-build
@@ -27,20 +24,6 @@ RUN cmake ..
RUN cmake --build . --config Release -j8 RUN cmake --build . --config Release -j8
RUN cmake --build . --target install RUN cmake --build . --target install
FROM build-base AS fmtlib-build
ARG FMTLIB_VERSION
ADD https://api.github.com/repos/fmtlib/fmt/git/refs/tags/${FMTLIB_VERSION} version.json
RUN git clone https://github.com/fmtlib/fmt --branch ${FMTLIB_VERSION} /fmtlib
WORKDIR /fmtlib
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake ..
RUN make
RUN make install
FROM build-base AS cppkafka-build FROM build-base AS cppkafka-build
ARG CPPKAFKA_VERSION ARG CPPKAFKA_VERSION
@@ -55,62 +38,30 @@ RUN cmake ..
RUN cmake --build . --config Release -j8 RUN cmake --build . --config Release -j8
RUN cmake --build . --target install RUN cmake --build . --target install
FROM build-base AS json-schema-validator-build
ARG JSON_VALIDATOR_VERSION
ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/tags/${JSON_VALIDATOR_VERSION} version.json
RUN git clone https://github.com/pboettch/json-schema-validator --branch ${JSON_VALIDATOR_VERSION} /json-schema-validator
WORKDIR /json-schema-validator
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake ..
RUN make
RUN make install
FROM build-base AS aws-sdk-cpp-build
ARG AWS_SDK_VERSION
ADD https://api.github.com/repos/aws/aws-sdk-cpp/git/refs/tags/${AWS_SDK_VERSION} version.json
RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp --branch ${AWS_SDK_VERSION} /aws-sdk-cpp
WORKDIR /aws-sdk-cpp
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake .. -DBUILD_ONLY="sns;s3" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-Wno-error=stringop-overflow -Wno-error=uninitialized" \
-DAUTORUN_UNIT_TESTS=OFF
RUN cmake --build . --config Release -j8
RUN cmake --build . --target install
FROM build-base AS owsec-build FROM build-base AS owsec-build
ADD CMakeLists.txt build /owsec/ ADD CMakeLists.txt build /owsec/
ADD overlays /owsec/overlays
ADD cmake /owsec/cmake ADD cmake /owsec/cmake
ADD src /owsec/src ADD src /owsec/src
ADD .git /owsec/.git ADD .git /owsec/.git
ARG VCPKG_VERSION=2022.11.14
RUN git clone --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg && \
./vcpkg/bootstrap-vcpkg.sh && \
mkdir /vcpkg/custom-triplets && \
cp /vcpkg/triplets/x64-linux.cmake /vcpkg/custom-triplets/x64-linux.cmake && \
sed -i 's/set(VCPKG_LIBRARY.*/set(VCPKG_LIBRARY_LINKAGE dynamic)/g' /vcpkg/custom-triplets/x64-linux.cmake && \
./vcpkg/vcpkg install aws-sdk-cpp[sns]:x64-linux json-schema-validator:x64-linux --overlay-triplets=/vcpkg/custom-triplets --overlay-ports=/owsec/overlays
COPY --from=poco-build /usr/local/include /usr/local/include COPY --from=poco-build /usr/local/include /usr/local/include
COPY --from=poco-build /usr/local/lib /usr/local/lib COPY --from=poco-build /usr/local/lib /usr/local/lib
COPY --from=cppkafka-build /usr/local/include /usr/local/include COPY --from=cppkafka-build /usr/local/include /usr/local/include
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
COPY --from=json-schema-validator-build /usr/local/include /usr/local/include
COPY --from=json-schema-validator-build /usr/local/lib /usr/local/lib
COPY --from=aws-sdk-cpp-build /usr/local/include /usr/local/include
COPY --from=aws-sdk-cpp-build /usr/local/lib /usr/local/lib
COPY --from=fmtlib-build /usr/local/include /usr/local/include
COPY --from=fmtlib-build /usr/local/lib /usr/local/lib
WORKDIR /owsec WORKDIR /owsec
RUN mkdir cmake-build RUN mkdir cmake-build
WORKDIR /owsec/cmake-build WORKDIR /owsec/cmake-build
RUN cmake .. \ RUN cmake -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake ..
-Dcrypto_LIBRARY=/usr/lib/libcrypto.so \
-DBUILD_SHARED_LIBS=ON
RUN cmake --build . --config Release -j8 RUN cmake --build . --config Release -j8
FROM debian:$DEBIAN_VERSION FROM debian:$DEBIAN_VERSION
@@ -127,7 +78,7 @@ RUN mkdir -p "$OWSEC_ROOT" "$OWSEC_CONFIG" && \
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && apt-get install --no-install-recommends -y \
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \ librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
libmariadb-dev-compat libpq5 unixodbc libmariadb-dev-compat libpq5 postgresql-client libfmt7
COPY readiness_check /readiness_check COPY readiness_check /readiness_check
COPY test_scripts/curl/cli /cli COPY test_scripts/curl/cli /cli
@@ -141,11 +92,9 @@ RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentr
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt -O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
COPY --from=owsec-build /owsec/cmake-build/owsec /openwifi/owsec COPY --from=owsec-build /owsec/cmake-build/owsec /openwifi/owsec
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/* /usr/local/lib COPY --from=owsec-build /vcpkg/installed/x64-linux/lib/ /usr/local/lib/
COPY --from=poco-build /poco/cmake-build/lib/* /usr/local/lib COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/ /usr/local/lib/
COPY --from=aws-sdk-cpp-build /aws-sdk-cpp/cmake-build/aws-cpp-sdk-core/libaws-cpp-sdk-core.so /usr/local/lib COPY --from=poco-build /poco/cmake-build/lib/ /usr/local/lib/
COPY --from=aws-sdk-cpp-build /aws-sdk-cpp/cmake-build/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so /usr/local/lib
COPY --from=aws-sdk-cpp-build /aws-sdk-cpp/cmake-build/aws-cpp-sdk-sns/libaws-cpp-sdk-sns.so /usr/local/lib
RUN ldconfig RUN ldconfig

View File

@@ -16,6 +16,10 @@ into your own systems. If all you need it to access the uCentralGW for example (
The CLI for the [uCentralGW](https://github.com/telecominfraproject/wlan-cloud-ucentralgw/blob/main/test_scripts/curl/cli) has a very good example of this. The CLI for the [uCentralGW](https://github.com/telecominfraproject/wlan-cloud-ucentralgw/blob/main/test_scripts/curl/cli) has a very good example of this.
Look for the `setgateway` function. Look for the `setgateway` function.
You may get static page with OpenAPI docs generated from the definition on [GitHub Page](https://telecominfraproject.github.io/wlan-cloud-ucentralsec/).
Also you may use [Swagger UI](https://petstore.swagger.io/#/) with OpenAPI definition file raw link (i.e. [latest version file](https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentralsec/main/openpapi/owsec.yaml)) to get interactive docs page.
## Firewall Considerations ## Firewall Considerations
The entire uCentral systems uses several MicroServices. In order for the whole system to work, you should provide the following port The entire uCentral systems uses several MicroServices. In order for the whole system to work, you should provide the following port
access: access:
@@ -264,4 +268,4 @@ on any other app that support the TOTP protocol. You should include the followin
totp.issuer = OrgName totp.issuer = OrgName
``` ```
It is very important that you not use spaces in your OrgName. It is very important that you not use spaces in your OrgName.

2
build
View File

@@ -1 +1 @@
8 41

View File

@@ -23,6 +23,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17001"} \ SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17001"} \
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16001"} \ SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16001"} \
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \ SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \
SERVICE_KEY=${SERVICE_KEY:-"\$OWSEC_ROOT/certs/restapi-key.pem"} \ SERVICE_KEY=${SERVICE_KEY:-"\$OWSEC_ROOT/certs/restapi-key.pem"} \
SERVICE_KEY_PASSWORD=${SERVICE_KEY_PASSWORD:-"mypassword"} \ SERVICE_KEY_PASSWORD=${SERVICE_KEY_PASSWORD:-"mypassword"} \
SMSSENDER_ENABLED=${SMSSENDER_ENABLED:-"false"} \ SMSSENDER_ENABLED=${SMSSENDER_ENABLED:-"false"} \

2
helm/.gitignore vendored
View File

@@ -1 +1,3 @@
*.swp *.swp
Chart.lock
charts/

View File

@@ -70,8 +70,8 @@ The following table lists the configurable parameters of the chart and their def
| persistence.size | string | Defines PV size | `'10Gi'` | | persistence.size | string | Defines PV size | `'10Gi'` |
| public_env_variables | hash | Defines list of environment variables to be passed to the Security | | | public_env_variables | hash | Defines list of environment variables to be passed to the Security | |
| configProperties | hash | Configuration properties that should be passed to the application in `owsec.properties`. May be passed by key in set (i.e. `configProperties."rtty\.token"`) | | | configProperties | hash | Configuration properties that should be passed to the application in `owsec.properties`. May be passed by key in set (i.e. `configProperties."rtty\.token"`) | |
| certs | hash | Defines files (keys and certificates) that should be passed to the Security (PEM format is adviced to be used) (see `volumes.owsec` on where it is mounted) | | | existingCertsSecret | string | Existing Kubernetes secret containing all required certificates and private keys for microservice operation. If set, certificates from `certs` key are ignored | `""` |
| certs | hash | Defines files (keys and certificates) that should be passed to the Gateway (PEM format is adviced to be used) (see `volumes.owsec` on where it is mounted). If `existingCertsSecret` is set, certificates passed this way will not be used. | |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

View File

@@ -1,4 +1,5 @@
{{- $root := . -}} {{- $root := . -}}
{{- $storageType := index .Values.configProperties "storage.type" -}}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -46,6 +47,39 @@ spec:
- -timeout - -timeout
- 600s - 600s
{{- if eq $storageType "postgresql" }}
- name: wait-postgres
image: "{{ .Values.images.owsec.repository }}:{{ .Values.images.owsec.tag }}"
imagePullPolicy: {{ .Values.images.owsec.pullPolicy }}
command:
- /wait-for-postgres.sh
- {{ index .Values.configProperties "storage.type.postgresql.host" }}
- echo
- "PostgreSQL is ready"
env:
- name: KUBERNETES_DEPLOYED
value: "{{ now }}"
{{- range $key, $value := .Values.public_env_variables }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.secret_env_variables }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ include "owsec.fullname" $root }}-env
key: {{ $key }}
{{- end }}
volumeMounts:
{{- range .Values.volumes.owsec }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- end }}
containers: containers:
- name: owsec - name: owsec

View File

@@ -9,7 +9,7 @@ fullnameOverride: ""
images: images:
owsec: owsec:
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owsec repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owsec
tag: main tag: v2.8.0
pullPolicy: Always pullPolicy: Always
# regcred: # regcred:
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io # registry: tip-tip-wlan-cloud-ucentral.jfrog.io
@@ -71,7 +71,7 @@ volumes:
mountPath: /owsec-data/certs mountPath: /owsec-data/certs
volumeDefinition: | volumeDefinition: |
secret: secret:
secretName: {{ include "owsec.fullname" . }}-certs secretName: {{ if .Values.existingCertsSecret }}{{ .Values.existingCertsSecret }}{{ else }}{{ include "owsec.fullname" . }}-certs{{ end }}
# Change this if you want to use another volume type # Change this if you want to use another volume type
- name: persist - name: persist
mountPath: /owsec-data/persist mountPath: /owsec-data/persist
@@ -228,6 +228,9 @@ configProperties:
storage.type.mysql.username: stephb storage.type.mysql.username: stephb
storage.type.mysql.password: snoopy99 storage.type.mysql.password: snoopy99
# NOTE: List of required certificates may be found in "certs" key. Alternative way to pass required certificates is to create external secret with all required certificates and set secret name in "existingCertsSecret" key. Details may be found in https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/main/chart#tldr
existingCertsSecret: ""
certs: certs:
# restapi-ca.pem: "" # restapi-ca.pem: ""
# restapi-cert.pem: "" # restapi-cert.pem: ""

View File

@@ -17,6 +17,7 @@ servers:
security: security:
- bearerAuth: [] - bearerAuth: []
- ApiKeyAuth: [] - ApiKeyAuth: []
- ApiToken: []
components: components:
securitySchemes: securitySchemes:
@@ -28,6 +29,10 @@ components:
type: http type: http
scheme: bearer scheme: bearer
bearerFormat: JWT bearerFormat: JWT
ApiToken:
type: apiKey
in: header
name: X-API-TOKEN
responses: responses:
NotFound: NotFound:
@@ -164,18 +169,61 @@ components:
aclTemplate: aclTemplate:
$ref: '#/components/schemas/AclTemplate' $ref: '#/components/schemas/AclTemplate'
ApiKeyCreationRequest: ApiKeyAccessRight:
type: object type: object
properties: properties:
service:
type: string
access:
type: string
enum:
- read
- modify
- create
- delete
- noaccess
ApiKeyAccessRightList:
type: object
properties:
acls:
type: array
items:
$ref: '#/components/schemas/ApiKeyAccessRight'
ApiKeyEntry:
type: object
properties:
id:
type: string
format: uuid
userUuid:
type: string
format: uuid
name: name:
type: string type: string
description: description:
type: string type: string
apiKey:
type: string
salt:
type: string
expiresOn: expiresOn:
type: integer type: integer
format: int64 format: int64
lastUse:
type: integer
format: int64
rights: rights:
$ref: '#/components/schemas/AclTemplate' $ref: '#/components/schemas/ApiKeyAccessRightList'
ApiKeyEntryList:
type: object
properties:
apiKeys:
type: array
items:
$ref: '#/components/schemas/ApiKeyEntry'
ApiKeyCreationAnswer: ApiKeyCreationAnswer:
type: object type: object
@@ -194,7 +242,7 @@ components:
apiKey: apiKey:
type: string type: string
rights: rights:
$ref: '#/components/schemas/AclTemplate' $ref: '#/components/schemas/ApiKeyAccessRights'
AclTemplate: AclTemplate:
type: object type: object
@@ -894,7 +942,7 @@ paths:
/systemEndpoints: /systemEndpoints:
get: get:
tags: tags:
- Authentication - System Commands
summary: Retrieve the system layout. summary: Retrieve the system layout.
operationId: getSystemInfo operationId: getSystemInfo
responses: responses:
@@ -1348,7 +1396,7 @@ paths:
/email: /email:
post: post:
tags: tags:
- Email - Messaging
summary: Send test email with the system. summary: Send test email with the system.
operationId: Send a test email operationId: Send a test email
requestBody: requestBody:
@@ -1379,7 +1427,7 @@ paths:
/sms: /sms:
post: post:
tags: tags:
- Email - Messaging
summary: Send test email with the system. summary: Send test email with the system.
operationId: Send a test SMS operationId: Send a test SMS
parameters: parameters:
@@ -1634,7 +1682,103 @@ paths:
404: 404:
$ref: '#/components/responses/NotFound' $ref: '#/components/responses/NotFound'
/apiKey/{uuid}:
get:
tags:
- API Tokens
summary: Retrieve all the APIKeys for a given user UUID
operationId: getApiKeyList
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
responses:
200:
$ref: '#/components/schemas/ApiKeyEntryList'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
delete:
tags:
- API Tokens
summary: Retrieve all the APIKeys for a given user UUID
operationId: deleteApiKey
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
- in: query
name: keyUuid
schema:
type: string
required: true
responses:
200:
$ref: '#/components/responses/Success'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
post:
tags:
- API Tokens
summary: Retrieve all the APIKeys for a given user UUID
operationId: createApiKey
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyEntry'
responses:
200:
$ref: '#/components/schemas/ApiKeyEntry'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
put:
tags:
- API Tokens
summary: Retrieve all the APIKeys for a given user UUID
operationId: modifyApiKey
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
- in: query
name: name
schema:
type: string
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyEntry'
responses:
200:
$ref: '#/components/schemas/ApiKeyEntry'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
######################################################################################### #########################################################################################
## ##
@@ -1732,6 +1876,26 @@ paths:
404: 404:
$ref: '#/components/responses/NotFound' $ref: '#/components/responses/NotFound'
/validateApiKey:
get:
tags:
- Security
summary: Allows an application to validate an API Key.
operationId: validateApiKey
parameters:
- in: query
name: token
schema:
type: string
required: true
responses:
200:
$ref: '#/components/schemas/TokenValidationResult'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/system: /system:
post: post:
tags: tags:

View File

@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

4
overlays/curl/vcpkg.json Normal file
View File

@@ -0,0 +1,4 @@
{
"name": "curl",
"version-string": "7.74.0-1.3+deb11u3"
}

View File

@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

View File

@@ -0,0 +1,4 @@
{
"name": "openssl",
"version-string": "1.1.1n-0+deb11u3"
}

View File

@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

4
overlays/zlib/vcpkg.json Normal file
View File

@@ -0,0 +1,4 @@
{
"name": "zlib",
"version-string": "1:1.2.11.dfsg-2+deb11u2"
}

View File

@@ -36,6 +36,7 @@ openwifi.system.data = $OWSEC_ROOT/data
openwifi.system.uri.private = https://localhost:17001 openwifi.system.uri.private = https://localhost:17001
openwifi.system.uri.public = https://local.dpaas.arilia.com:16001 openwifi.system.uri.public = https://local.dpaas.arilia.com:16001
openwifi.system.uri.ui = https://ucentral-ui.arilia.com openwifi.system.uri.ui = https://ucentral-ui.arilia.com
openwifi.security.restapi.disable = false
openwifi.system.commandchannel = /tmp/app.ucentralsec openwifi.system.commandchannel = /tmp/app.ucentralsec
openwifi.service.key = $OWSEC_ROOT/certs/restapi-key.pem openwifi.service.key = $OWSEC_ROOT/certs/restapi-key.pem
openwifi.service.key.password = mypassword openwifi.service.key.password = mypassword
@@ -132,4 +133,4 @@ storage.type.mysql.connectiontimeout = 60
######################################################################## ########################################################################
logging.type = file logging.type = file
logging.path = $OWSEC_ROOT/logs logging.path = $OWSEC_ROOT/logs
logging.level = debug logging.level = debug

View File

@@ -36,6 +36,7 @@ openwifi.system.data = ${SYSTEM_DATA}
openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE} openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE}
openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC} openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
openwifi.system.uri.ui = ${SYSTEM_URI_UI} openwifi.system.uri.ui = ${SYSTEM_URI_UI}
openwifi.security.restapi.disable = ${SECURITY_RESTAPI_DISABLE}
openwifi.system.commandchannel = /tmp/app.ucentralsec openwifi.system.commandchannel = /tmp/app.ucentralsec
openwifi.service.key = ${SERVICE_KEY} openwifi.service.key = ${SERVICE_KEY}
openwifi.service.key.password = ${SERVICE_KEY_PASSWORD} openwifi.service.key.password = ${SERVICE_KEY_PASSWORD}

View File

@@ -32,53 +32,102 @@ namespace OpenWifi {
*/ */
static inline bool Can( const SecurityObjects::UserInfo & User, const SecurityObjects::UserInfo & Target, ACL_OPS Op) { static inline bool Can( const SecurityObjects::UserInfo & User, const SecurityObjects::UserInfo & Target, ACL_OPS Op) {
// rule 0 switch(Op) {
if(User.id == Target.id && User.userRole == SecurityObjects::SUBSCRIBER && Op == DELETE) case DELETE: {
return true; // can a user delete themselves - yes - only if not root. We do not want a system to end up rootless
if(User.id==Target.id) {
return User.userRole != SecurityObjects::ROOT;
}
// Root can delete anyone
switch (User.userRole) {
case SecurityObjects::ROOT:
return true;
case SecurityObjects::ADMIN:
return Target.userRole!=SecurityObjects::ROOT && Target.userRole!=SecurityObjects::PARTNER;
case SecurityObjects::SUBSCRIBER:
return User.id==Target.id;
case SecurityObjects::CSR:
return false;
case SecurityObjects::SYSTEM:
return Target.userRole!=SecurityObjects::ROOT && Target.userRole!=SecurityObjects::PARTNER;
case SecurityObjects::INSTALLER:
return User.id==Target.id;
case SecurityObjects::NOC:
return Target.userRole==SecurityObjects::NOC;
case SecurityObjects::ACCOUNTING:
return Target.userRole==SecurityObjects::ACCOUNTING;
case SecurityObjects::PARTNER:
return Target.userRole!=SecurityObjects::ROOT;
default:
return false;
}
}
break;
// rule 1 case READ: {
if(User.id == Target.id && Op==DELETE) return User.userRole == SecurityObjects::ROOT ||
return false; User.userRole == SecurityObjects::ADMIN ||
User.userRole == SecurityObjects::PARTNER;
}
break;
// rule 2 case CREATE: {
if(User.userRole==SecurityObjects::ROOT) switch(User.userRole) {
return true; case SecurityObjects::ROOT:
return true;
case SecurityObjects::ADMIN:
return Target.userRole!=SecurityObjects::ROOT &&
Target.userRole!=SecurityObjects::PARTNER;
case SecurityObjects::SUBSCRIBER:
return false;
case SecurityObjects::CSR:
return Target.userRole==SecurityObjects::CSR;
case SecurityObjects::SYSTEM:
return Target.userRole!=SecurityObjects::ROOT && Target.userRole!=SecurityObjects::PARTNER;
case SecurityObjects::INSTALLER:
return Target.userRole==SecurityObjects::INSTALLER;
case SecurityObjects::NOC:
return Target.userRole==SecurityObjects::NOC;
case SecurityObjects::ACCOUNTING:
return Target.userRole==SecurityObjects::ACCOUNTING;
case SecurityObjects::PARTNER:
return Target.userRole!=SecurityObjects::ROOT;
default:
return false;
}
}
break;
// rule 3 case MODIFY: {
if(User.id == Target.id) switch(User.userRole) {
return true; case SecurityObjects::ROOT:
return true;
// rule 4 case SecurityObjects::ADMIN:
if(Target.userRole==SecurityObjects::ROOT && Op!=READ) return Target.userRole!=SecurityObjects::ROOT &&
return false; Target.userRole!=SecurityObjects::PARTNER;
case SecurityObjects::SUBSCRIBER:
if(Op==CREATE) { return User.id==Target.id;
if(User.userRole==SecurityObjects::ROOT) case SecurityObjects::CSR:
return true; return Target.userRole==SecurityObjects::CSR;
if(User.userRole==SecurityObjects::PARTNER && (Target.userRole==SecurityObjects::ADMIN || case SecurityObjects::SYSTEM:
Target.userRole==SecurityObjects::SUBSCRIBER || return Target.userRole!=SecurityObjects::ROOT &&
Target.userRole==SecurityObjects::CSR || Target.userRole!=SecurityObjects::PARTNER;
Target.userRole==SecurityObjects::INSTALLER || case SecurityObjects::INSTALLER:
Target.userRole==SecurityObjects::NOC || return Target.userRole==SecurityObjects::INSTALLER;
Target.userRole==SecurityObjects::ACCOUNTING)) case SecurityObjects::NOC:
return true; return Target.userRole==SecurityObjects::NOC;
if(User.userRole==SecurityObjects::ADMIN && case SecurityObjects::ACCOUNTING:
(Target.userRole==SecurityObjects::ADMIN || return Target.userRole==SecurityObjects::ACCOUNTING;
Target.userRole==SecurityObjects::SUBSCRIBER || case SecurityObjects::PARTNER:
Target.userRole==SecurityObjects::CSR || return Target.userRole!=SecurityObjects::ROOT;
Target.userRole==SecurityObjects::INSTALLER || default:
Target.userRole==SecurityObjects::NOC || return false;
Target.userRole==SecurityObjects::ACCOUNTING)) }
return true; }
if(User.userRole==SecurityObjects::ACCOUNTING && break;
(Target.userRole==SecurityObjects::SUBSCRIBER || default:
Target.userRole==SecurityObjects::INSTALLER || return false;
Target.userRole==SecurityObjects::CSR))
return true;
return false;
} }
return true;
} }
private: private:

View File

@@ -6,21 +6,26 @@
#include "StorageService.h" #include "StorageService.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "MessagingTemplates.h" #include "MessagingTemplates.h"
#include "framework/utils.h"
#include "fmt/format.h"
namespace OpenWifi { namespace OpenWifi {
int ActionLinkManager::Start() { int ActionLinkManager::Start() {
poco_information(Logger(),"Starting...");
if(!Running_) if(!Running_)
Thr_.start(*this); Thr_.start(*this);
return 0; return 0;
} }
void ActionLinkManager::Stop() { void ActionLinkManager::Stop() {
poco_information(Logger(),"Stopping...");
if(Running_) { if(Running_) {
Running_ = false; Running_ = false;
Thr_.wakeUp(); Thr_.wakeUp();
Thr_.join(); Thr_.join();
} }
poco_information(Logger(),"Stopped...");
} }
void ActionLinkManager::run() { void ActionLinkManager::run() {
@@ -63,7 +68,7 @@ namespace OpenWifi {
switch(i.action) { switch(i.action) {
case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: { case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: {
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::FORGOT_PASSWORD)) { if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::FORGOT_PASSWORD)) {
Logger().information(fmt::format("Send password reset link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send password reset link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }
@@ -71,7 +76,7 @@ namespace OpenWifi {
case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: { case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: {
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_VERIFICATION)) { if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_VERIFICATION)) {
Logger().information(fmt::format("Send email verification link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send email verification link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }
@@ -79,7 +84,7 @@ namespace OpenWifi {
case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: { case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: {
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_INVITATION)) { if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_INVITATION)) {
Logger().information(fmt::format("Send new subscriber email invitation link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send new subscriber email invitation link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }
@@ -88,7 +93,7 @@ namespace OpenWifi {
case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: { case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: {
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":"); auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
if(AuthService::SendEmailToSubUser(i.id, UInfo.email,MessagingTemplates::SUB_FORGOT_PASSWORD, Signup.count()==1 ? "" : Signup[0])) { if(AuthService::SendEmailToSubUser(i.id, UInfo.email,MessagingTemplates::SUB_FORGOT_PASSWORD, Signup.count()==1 ? "" : Signup[0])) {
Logger().information(fmt::format("Send subscriber password reset link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send subscriber password reset link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }
@@ -97,7 +102,7 @@ namespace OpenWifi {
case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: { case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: {
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":"); auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) { if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) {
Logger().information(fmt::format("Send subscriber email verification link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send subscriber email verification link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }
@@ -105,8 +110,8 @@ namespace OpenWifi {
case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: { case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: {
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":"); auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SIGNUP_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) { if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SUB_SIGNUP_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) {
Logger().information(fmt::format("Send new subscriber email verification link to {}",UInfo.email)); poco_information(Logger(),fmt::format("Send new subscriber email verification link to {}",UInfo.email));
} }
StorageService()->ActionLinksDB().SentAction(i.id); StorageService()->ActionLinksDB().SentAction(i.id);
} }

View File

@@ -2,10 +2,9 @@
// Created by stephane bourque on 2021-11-08. // Created by stephane bourque on 2021-11-08.
// //
#ifndef OWSEC_ACTIONLINKMANAGER_H #pragma once
#define OWSEC_ACTIONLINKMANAGER_H
#include "framework/MicroService.h" #include "framework/SubSystemServer.h"
namespace OpenWifi { namespace OpenWifi {
@@ -33,4 +32,3 @@ namespace OpenWifi {
inline ActionLinkManager * ActionLinkManager() { return ActionLinkManager::instance(); } inline ActionLinkManager * ActionLinkManager() { return ActionLinkManager::instance(); }
} }
#endif //OWSEC_ACTIONLINKMANAGER_H

View File

@@ -8,15 +8,17 @@
#include <ctime> #include <ctime>
#include "framework/KafkaManager.h"
#include "framework/KafkaTopics.h"
#include "Poco/Net/OAuth20Credentials.h" #include "Poco/Net/OAuth20Credentials.h"
#include "Poco/JWT/Token.h" #include "Poco/JWT/Token.h"
#include "Poco/JWT/Signer.h" #include "Poco/JWT/Signer.h"
#include "Poco/StringTokenizer.h" #include "Poco/StringTokenizer.h"
#include "framework/MicroService.h"
#include "StorageService.h" #include "StorageService.h"
#include "AuthService.h" #include "AuthService.h"
#include "framework/KafkaTopics.h" #include "framework/MicroServiceFuncs.h"
#include "SMTPMailerService.h" #include "SMTPMailerService.h"
#include "MFAServer.h" #include "MFAServer.h"
@@ -43,27 +45,32 @@ namespace OpenWifi {
return 1; // some compilers complain... return 1; // some compilers complain...
} }
static const std::string DefaultPassword_8_u_l_n_1{"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\\{\\}\\(\\)~_\\+\\|\\\\\\[\\]\\;\\:\\<\\>\\.\\,\\/\\?\\\"\\'\\`\\=#?!@$%^&*-]).{8,}$"}; #if defined(TIP_CERT_SERVICE)
static const std::string DefaultPasswordRule{"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\\{\\}\\(\\)~_\\+\\|\\\\\\[\\]\\;\\:\\<\\>\\.\\,\\/\\?\\\"\\'\\`\\=#?!@$%^&*-]).{12,}$"};
#else
static const std::string DefaultPasswordRule{"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\\{\\}\\(\\)~_\\+\\|\\\\\\[\\]\\;\\:\\<\\>\\.\\,\\/\\?\\\"\\'\\`\\=#?!@$%^&*-]).{8,}$"};
#endif
int AuthService::Start() { int AuthService::Start() {
Logger().notice("Starting..."); poco_information(Logger(),"Starting...");
TokenAging_ = (uint64_t) MicroService::instance().ConfigGetInt("authentication.token.ageing", 30 * 24 * 60 * 60); TokenAging_ = (uint64_t) MicroServiceConfigGetInt("authentication.token.ageing", 30 * 24 * 60 * 60);
RefreshTokenLifeSpan_ = (uint64_t) MicroService::instance().ConfigGetInt("authentication.refresh_token.lifespan", 90 * 24 * 60 * 600); RefreshTokenLifeSpan_ = (uint64_t) MicroServiceConfigGetInt("authentication.refresh_token.lifespan", 90 * 24 * 60 * 600);
HowManyOldPassword_ = MicroService::instance().ConfigGetInt("authentication.oldpasswords", 5); HowManyOldPassword_ = MicroServiceConfigGetInt("authentication.oldpasswords", 5);
AccessPolicy_ = MicroService::instance().ConfigPath("openwifi.document.policy.access", "/wwwassets/access_policy.html"); AccessPolicy_ = MicroServiceConfigGetString("openwifi.document.policy.access", "/wwwassets/access_policy.html");
PasswordPolicy_ = MicroService::instance().ConfigPath("openwifi.document.policy.password", "/wwwassets/password_policy.html"); PasswordPolicy_ = MicroServiceConfigGetString("openwifi.document.policy.password", "/wwwassets/password_policy.html");
PasswordValidation_ = PasswordValidationStr_ = MicroService::instance().ConfigGetString("authentication.validation.expression",DefaultPassword_8_u_l_n_1); PasswordValidation_ = PasswordValidationStr_ = MicroServiceConfigGetString("authentication.validation.expression",DefaultPasswordRule);
SubPasswordValidation_ = SubPasswordValidationStr_ = MicroService::instance().ConfigGetString("subscriber.validation.expression",DefaultPassword_8_u_l_n_1); SubPasswordValidation_ = SubPasswordValidationStr_ = MicroServiceConfigGetString("subscriber.validation.expression",DefaultPasswordRule);
SubAccessPolicy_ = MicroService::instance().ConfigPath("subscriber.policy.access", "/wwwassets/access_policy.html"); SubAccessPolicy_ = MicroServiceConfigGetString("subscriber.policy.access", "/wwwassets/access_policy.html");
SubPasswordPolicy_ = MicroService::instance().ConfigPath("subscriber.policy.password", "/wwwassets/password_policy.html"); SubPasswordPolicy_ = MicroServiceConfigGetString("subscriber.policy.password", "/wwwassets/password_policy.html");
return 0; return 0;
} }
void AuthService::Stop() { void AuthService::Stop() {
Logger().notice("Stopping..."); poco_information(Logger(),"Stopping...");
poco_information(Logger(),"Stopped...");
} }
bool AuthService::RefreshUserToken(Poco::Net::HTTPServerRequest & Request, const std::string & RefreshToken, SecurityObjects::UserInfoAndPolicy & UI) { bool AuthService::RefreshUserToken(Poco::Net::HTTPServerRequest & Request, const std::string & RefreshToken, SecurityObjects::UserInfoAndPolicy & UI) {
@@ -81,7 +88,7 @@ namespace OpenWifi {
uint64_t RevocationDate=0; uint64_t RevocationDate=0;
std::string UserId; std::string UserId;
if(StorageService()->UserTokenDB().GetToken(CallToken, UI.webtoken, UserId, RevocationDate) && UI.webtoken.refresh_token_==RefreshToken) { if(StorageService()->UserTokenDB().GetToken(CallToken, UI.webtoken, UserId, RevocationDate) && UI.webtoken.refresh_token_==RefreshToken) {
auto now = OpenWifi::Now(); auto now = Utils::Now();
// Create a new token // Create a new token
auto NewToken = GenerateTokenHMAC( UI.webtoken.access_token_, CUSTOM); auto NewToken = GenerateTokenHMAC( UI.webtoken.access_token_, CUSTOM);
@@ -119,7 +126,7 @@ namespace OpenWifi {
uint64_t RevocationDate=0; uint64_t RevocationDate=0;
std::string UserId; std::string UserId;
if(StorageService()->SubTokenDB().GetToken(CallToken, UI.webtoken, UserId, RevocationDate) && UI.webtoken.refresh_token_==RefreshToken) { if(StorageService()->SubTokenDB().GetToken(CallToken, UI.webtoken, UserId, RevocationDate) && UI.webtoken.refresh_token_==RefreshToken) {
auto now = OpenWifi::Now(); auto now = Utils::Now();
// Create a new token // Create a new token
auto NewToken = GenerateTokenHMAC( UI.webtoken.access_token_, CUSTOM); auto NewToken = GenerateTokenHMAC( UI.webtoken.access_token_, CUSTOM);
@@ -142,54 +149,73 @@ namespace OpenWifi {
return false; return false;
} }
bool AuthService::IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string & SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired ) [[nodiscard]] bool AuthService::IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired) {
{ // std::lock_guard Guard(Mutex_);
std::lock_guard Guard(Mutex_); std::string CallToken{SessionToken};
Expired = false; Expired = false;
try { try {
std::string CallToken;
Poco::Net::OAuth20Credentials Auth(Request);
if (Auth.getScheme() == "Bearer") {
CallToken = Auth.getBearerToken();
}
if(CallToken.empty()) {
return false;
}
SecurityObjects::WebToken WT; SecurityObjects::WebToken WT;
uint64_t RevocationDate=0; uint64_t RevocationDate=0;
std::string UserId; std::string UserId;
if(StorageService()->UserTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) { if(StorageService()->UserTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0) {
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false; return false;
auto now=OpenWifi::Now(); }
auto now=Utils::Now();
Expired = (WT.created_ + WT.expires_in_) < now; Expired = (WT.created_ + WT.expires_in_) < now;
if(StorageService()->UserDB().GetUserById(UserId,UInfo.userinfo)) { if(StorageService()->UserDB().GetUserById(UserId,UInfo.userinfo)) {
UInfo.webtoken = WT; UInfo.webtoken = WT;
SessionToken = CallToken; poco_debug(Logger(), fmt::format("TokenValidation success for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return true; return true;
} }
} }
return false; } catch(const Poco::Exception &E) {
} catch(const Poco::Exception &E) { Logger().log(E);
Logger().log(E); }
} poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false; return false;
} }
bool AuthService::IsSubAuthorized(Poco::Net::HTTPServerRequest & Request, std::string & SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired ) bool AuthService::IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string & SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired )
{ {
std::lock_guard Guard(Mutex_); // std::lock_guard Guard(Mutex_);
std::string CallToken;
Expired = false;
try {
Poco::Net::OAuth20Credentials Auth(Request);
if (Auth.getScheme() == "Bearer") {
CallToken = Auth.getBearerToken();
}
if (CallToken.empty()) {
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false;
}
SessionToken = CallToken;
return IsAuthorized(SessionToken, UInfo, TID, Expired);
} catch(const Poco::Exception &E) {
Logger().log(E);
}
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false;
}
bool AuthService::IsSubAuthorized(Poco::Net::HTTPServerRequest & Request, std::string & SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired )
{
// std::lock_guard Guard(Mutex_);
std::string CallToken;
Expired = false; Expired = false;
try { try {
std::string CallToken;
Poco::Net::OAuth20Credentials Auth(Request); Poco::Net::OAuth20Credentials Auth(Request);
if (Auth.getScheme() == "Bearer") { if (Auth.getScheme() == "Bearer") {
CallToken = Auth.getBearerToken(); CallToken = Auth.getBearerToken();
} }
if(CallToken.empty()) { if(CallToken.empty()) {
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false; return false;
} }
@@ -197,20 +223,23 @@ namespace OpenWifi {
uint64_t RevocationDate=0; uint64_t RevocationDate=0;
std::string UserId; std::string UserId;
if(StorageService()->SubTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) { if(StorageService()->SubTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0) {
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false; return false;
auto now=OpenWifi::Now(); }
auto now=Utils::Now();
Expired = (WT.created_ + WT.expires_in_) < now; Expired = (WT.created_ + WT.expires_in_) < now;
if(StorageService()->SubDB().GetUserById(UserId,UInfo.userinfo)) { if(StorageService()->SubDB().GetUserById(UserId,UInfo.userinfo)) {
UInfo.webtoken = WT; UInfo.webtoken = WT;
SessionToken = CallToken; SessionToken = CallToken;
poco_debug(Logger(), fmt::format("TokenValidation success for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return true; return true;
} }
} }
return false;
} catch(const Poco::Exception &E) { } catch(const Poco::Exception &E) {
Logger().log(E); Logger().log(E);
} }
poco_debug(Logger(), fmt::format("TokenValidation failed for TID={} Token={}", TID, Utils::SanitizeToken(CallToken)));
return false; return false;
} }
@@ -247,11 +276,11 @@ namespace OpenWifi {
if(KafkaManager()->Enabled()) { if(KafkaManager()->Enabled()) {
Poco::JSON::Object Obj; Poco::JSON::Object Obj;
Obj.set("event", "remove-token"); Obj.set("event", "remove-token");
Obj.set("id", MicroService::instance().ID()); Obj.set("id", MicroServiceID());
Obj.set("token", token); Obj.set("token", token);
std::stringstream ResultText; std::stringstream ResultText;
Poco::JSON::Stringifier::stringify(Obj, ResultText); Poco::JSON::Stringifier::stringify(Obj, ResultText);
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroService::instance().PrivateEndPoint(), KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
ResultText.str(), ResultText.str(),
false); false);
} }
@@ -285,7 +314,7 @@ namespace OpenWifi {
} }
[[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, [[maybe_unused]] ACCESS_TYPE Type) { [[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, [[maybe_unused]] ACCESS_TYPE Type) {
std::string Identity(UserName + ":" + fmt::format("{}",OpenWifi::Now()) + ":" + std::to_string(rand())); std::string Identity(UserName + ":" + fmt::format("{}",Utils::Now()) + ":" + std::to_string(rand()));
HMAC_.update(Identity); HMAC_.update(Identity);
return Poco::DigestEngine::digestToHex(HMAC_.digest()); return Poco::DigestEngine::digestToHex(HMAC_.digest());
} }
@@ -305,7 +334,7 @@ namespace OpenWifi {
T.payload().set("identity", Identity); T.payload().set("identity", Identity);
T.setIssuedAt(Poco::Timestamp()); T.setIssuedAt(Poco::Timestamp());
T.setExpiration(Poco::Timestamp() + (long long)TokenAging_); T.setExpiration(Poco::Timestamp() + (long long)TokenAging_);
std::string JWT = MicroService::instance().Sign(T,Poco::JWT::Signer::ALGO_RS256); std::string JWT = MicroServiceSign(T,Poco::JWT::Signer::ALGO_RS256);
return JWT; return JWT;
} }
@@ -501,14 +530,14 @@ namespace OpenWifi {
UInfo.webtoken.errorCode = 1; UInfo.webtoken.errorCode = 1;
return PASSWORD_ALREADY_USED; return PASSWORD_ALREADY_USED;
} }
UInfo.userinfo.lastPasswordChange = OpenWifi::Now(); UInfo.userinfo.lastPasswordChange = Utils::Now();
UInfo.userinfo.changePassword = false; UInfo.userinfo.changePassword = false;
UInfo.userinfo.modified = OpenWifi::Now(); UInfo.userinfo.modified = Utils::Now();
StorageService()->UserDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo); StorageService()->UserDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo);
} }
// so we have a good password, password up date has taken place if need be, now generate the token. // so we have a good password, password up date has taken place if need be, now generate the token.
UInfo.userinfo.lastLogin=OpenWifi::Now(); UInfo.userinfo.lastLogin=Utils::Now();
StorageService()->UserDB().SetLastLogin(UInfo.userinfo.id); StorageService()->UserDB().SetLastLogin(UInfo.userinfo.id);
CreateToken(UserName, UInfo ); CreateToken(UserName, UInfo );
@@ -546,14 +575,14 @@ namespace OpenWifi {
UInfo.webtoken.errorCode = 1; UInfo.webtoken.errorCode = 1;
return PASSWORD_ALREADY_USED; return PASSWORD_ALREADY_USED;
} }
UInfo.userinfo.lastPasswordChange = OpenWifi::Now(); UInfo.userinfo.lastPasswordChange = Utils::Now();
UInfo.userinfo.changePassword = false; UInfo.userinfo.changePassword = false;
UInfo.userinfo.modified = OpenWifi::Now(); UInfo.userinfo.modified = Utils::Now();
StorageService()->SubDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo); StorageService()->SubDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo);
} }
// so we have a good password, password update has taken place if need be, now generate the token. // so we have a good password, password update has taken place if need be, now generate the token.
UInfo.userinfo.lastLogin=OpenWifi::Now(); UInfo.userinfo.lastLogin=Utils::Now();
StorageService()->SubDB().SetLastLogin(UInfo.userinfo.id); StorageService()->SubDB().SetLastLogin(UInfo.userinfo.id);
CreateSubToken(UserName, UInfo ); CreateSubToken(UserName, UInfo );
@@ -571,14 +600,14 @@ namespace OpenWifi {
Attrs[LOGO] = AuthService::GetLogoAssetURI(); Attrs[LOGO] = AuthService::GetLogoAssetURI();
Attrs[SUBJECT] = "Login validation code"; Attrs[SUBJECT] = "Login validation code";
Attrs[CHALLENGE_CODE] = Challenge; Attrs[CHALLENGE_CODE] = Challenge;
return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::VERIFICATION_CODE), Attrs); return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::VERIFICATION_CODE), Attrs, false);
} else { } else {
MessageAttributes Attrs; MessageAttributes Attrs;
Attrs[RECIPIENT_EMAIL] = UInfo.userinfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.userinfo.email;
Attrs[LOGO] = AuthService::GetLogoAssetURI(); Attrs[LOGO] = AuthService::GetSubLogoAssetURI();
Attrs[SUBJECT] = "Login validation code"; Attrs[SUBJECT] = "Login validation code";
Attrs[CHALLENGE_CODE] = Challenge; Attrs[CHALLENGE_CODE] = Challenge;
return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_VERIFICATION_CODE,OperatorParts[0]), Attrs); return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_VERIFICATION_CODE,OperatorParts[0]), Attrs, true );
} }
} }
@@ -593,9 +622,9 @@ namespace OpenWifi {
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetLogoAssetURI();
Attrs[SUBJECT] = "Password reset link"; Attrs[SUBJECT] = "Password reset link";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=password_reset&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=password_reset&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=password_reset&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=password_reset&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::FORGOT_PASSWORD), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::FORGOT_PASSWORD), Attrs, false);
} }
break; break;
@@ -604,9 +633,9 @@ namespace OpenWifi {
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetLogoAssetURI();
Attrs[SUBJECT] = "e-mail Address Verification"; Attrs[SUBJECT] = "e-mail Address Verification";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=email_verification&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=email_verification&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_verification&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_VERIFICATION), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_VERIFICATION), Attrs, false);
UInfo.waitingForEmailCheck = true; UInfo.waitingForEmailCheck = true;
} }
break; break;
@@ -616,9 +645,9 @@ namespace OpenWifi {
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetLogoAssetURI();
Attrs[SUBJECT] = "e-mail Invitation"; Attrs[SUBJECT] = "e-mail Invitation";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=email_invitation&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=email_invitation&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_invitation&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_invitation&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_INVITATION), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_INVITATION), Attrs, false);
UInfo.waitingForEmailCheck = true; UInfo.waitingForEmailCheck = true;
} }
break; break;
@@ -640,34 +669,34 @@ namespace OpenWifi {
case MessagingTemplates::SUB_FORGOT_PASSWORD: { case MessagingTemplates::SUB_FORGOT_PASSWORD: {
MessageAttributes Attrs; MessageAttributes Attrs;
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetSubLogoAssetURI();
Attrs[SUBJECT] = "Password reset link"; Attrs[SUBJECT] = "Password reset link";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=sub_password_reset&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=sub_password_reset&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_password_reset&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_password_reset&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD, OperatorName), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD, OperatorName), Attrs, true);
} }
break; break;
case MessagingTemplates::SUB_EMAIL_VERIFICATION: { case MessagingTemplates::SUB_EMAIL_VERIFICATION: {
MessageAttributes Attrs; MessageAttributes Attrs;
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetSubLogoAssetURI();
Attrs[SUBJECT] = "e-mail Address Verification"; Attrs[SUBJECT] = "e-mail Address Verification";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=sub_email_verification&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=sub_email_verification&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_email_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_email_verification&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION, OperatorName), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION, OperatorName), Attrs, true);
UInfo.waitingForEmailCheck = true; UInfo.waitingForEmailCheck = true;
} }
break; break;
case MessagingTemplates::SIGNUP_VERIFICATION: { case MessagingTemplates::SUB_SIGNUP_VERIFICATION: {
MessageAttributes Attrs; MessageAttributes Attrs;
Attrs[RECIPIENT_EMAIL] = UInfo.email; Attrs[RECIPIENT_EMAIL] = UInfo.email;
Attrs[LOGO] = GetLogoAssetURI(); Attrs[LOGO] = GetSubLogoAssetURI();
Attrs[SUBJECT] = "Signup e-mail Address Verification"; Attrs[SUBJECT] = "Signup e-mail Address Verification";
Attrs[ACTION_LINK] = MicroService::instance().GetPublicAPIEndPoint() + "/actionLink?action=signup_verification&id=" + LinkId ; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=signup_verification&id=" + LinkId ;
Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=signup_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=signup_verification&id=" + LinkId ;
SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SIGNUP_VERIFICATION, OperatorName), Attrs); SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_SIGNUP_VERIFICATION, OperatorName), Attrs, true);
UInfo.waitingForEmailCheck = true; UInfo.waitingForEmailCheck = true;
} }
break; break;
@@ -685,8 +714,8 @@ namespace OpenWifi {
A.action = OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL; A.action = OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL;
A.userId = UInfo.id; A.userId = UInfo.id;
A.id = MicroService::CreateUUID(); A.id = MicroServiceCreateUUID();
A.created = OpenWifi::Now(); A.created = Utils::Now();
A.expires = A.created + 24*60*60; A.expires = A.created + 24*60*60;
A.userAction = true; A.userAction = true;
StorageService()->ActionLinksDB().CreateAction(A); StorageService()->ActionLinksDB().CreateAction(A);
@@ -700,8 +729,8 @@ namespace OpenWifi {
A.action = OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL; A.action = OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL;
A.userId = UInfo.id; A.userId = UInfo.id;
A.id = MicroService::CreateUUID(); A.id = MicroServiceCreateUUID();
A.created = OpenWifi::Now(); A.created = Utils::Now();
A.expires = A.created + 24*60*60; A.expires = A.created + 24*60*60;
A.userAction = false; A.userAction = false;
StorageService()->ActionLinksDB().CreateAction(A); StorageService()->ActionLinksDB().CreateAction(A);
@@ -721,14 +750,13 @@ namespace OpenWifi {
if(StorageService()->UserTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) { if(StorageService()->UserTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < OpenWifi::Now(); Expired = (WT.created_ + WT.expires_in_) < Utils::Now();
if(StorageService()->UserDB().GetUserById(UserId,UserInfo)) { if(StorageService()->UserDB().GetUserById(UserId,UserInfo)) {
WebToken = WT; WebToken = WT;
return true; return true;
} }
return false;
} }
return IsValidSubToken(Token, WebToken, UserInfo, Expired); return false;
} }
bool AuthService::IsValidSubToken(const std::string &Token, SecurityObjects::WebToken &WebToken, SecurityObjects::UserInfo &UserInfo, bool & Expired) { bool AuthService::IsValidSubToken(const std::string &Token, SecurityObjects::WebToken &WebToken, SecurityObjects::UserInfo &UserInfo, bool & Expired) {
@@ -741,12 +769,34 @@ namespace OpenWifi {
if(StorageService()->SubTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) { if(StorageService()->SubTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < OpenWifi::Now(); Expired = (WT.created_ + WT.expires_in_) < Utils::Now();
if(StorageService()->SubDB().GetUserById(UserId,UserInfo)) { if(StorageService()->SubDB().GetUserById(UserId,UserInfo)) {
WebToken = WT; WebToken = WT;
return true; return true;
} }
return false; }
return false;
}
bool AuthService::IsValidApiKey(const std::string &ApiKey, SecurityObjects::WebToken &WebToken,
SecurityObjects::UserInfo &UserInfo, bool &Expired, std::uint64_t &expiresOn) {
std::lock_guard G(Mutex_);
std::string UserId;
SecurityObjects::WebToken WT;
SecurityObjects::ApiKeyEntry ApiKeyEntry;
if(StorageService()->ApiKeyDB().GetRecord("apiKey", ApiKey, ApiKeyEntry)) {
expiresOn = ApiKeyEntry.expiresOn;
Expired = ApiKeyEntry.expiresOn < Utils::Now();
if(Expired)
return false;
if(StorageService()->UserDB().GetUserById(ApiKeyEntry.userUuid,UserInfo)) {
WebToken = WT;
ApiKeyEntry.lastUse = Utils::Now();
StorageService()->ApiKeyDB().UpdateRecord("id", ApiKeyEntry.id, ApiKeyEntry);
return true;
}
} }
return false; return false;
} }

View File

@@ -6,11 +6,11 @@
// Arilia Wireless Inc. // Arilia Wireless Inc.
// //
#ifndef UCENTRAL_UAUTHSERVICE_H #pragma once
#define UCENTRAL_UAUTHSERVICE_H
#include <regex> #include <regex>
#include "framework/SubSystemServer.h"
#include "Poco/JSON/Object.h" #include "Poco/JSON/Object.h"
#include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h" #include "Poco/Net/HTTPServerResponse.h"
@@ -20,7 +20,9 @@
#include "Poco/HMACEngine.h" #include "Poco/HMACEngine.h"
#include "Poco/ExpireLRUCache.h" #include "Poco/ExpireLRUCache.h"
#include "framework/MicroService.h" #include "framework/MicroServiceFuncs.h"
#include "framework/ow_constants.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "MessagingTemplates.h" #include "MessagingTemplates.h"
@@ -48,15 +50,18 @@ namespace OpenWifi{
int Start() override; int Start() override;
void Stop() override; void Stop() override;
[[nodiscard]] bool IsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired); [[nodiscard]] bool IsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired);
[[nodiscard]] bool IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired);
[[nodiscard]] UNAUTHORIZED_REASON Authorize( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired ); [[nodiscard]] UNAUTHORIZED_REASON Authorize( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired );
void CreateToken(const std::string & UserName, SecurityObjects::UserInfoAndPolicy &UInfo); void CreateToken(const std::string & UserName, SecurityObjects::UserInfoAndPolicy &UInfo);
[[nodiscard]] bool SetPassword(const std::string &Password, SecurityObjects::UserInfo & UInfo); [[nodiscard]] bool SetPassword(const std::string &Password, SecurityObjects::UserInfo & UInfo);
[[nodiscard]] const std:: string & PasswordValidationExpression() const { return PasswordValidationStr_;}; [[nodiscard]] const std:: string & PasswordValidationExpression() const { return PasswordValidationStr_;};
void Logout(const std::string &token, bool EraseFromCache=true); void Logout(const std::string &token, bool EraseFromCache=true);
[[nodiscard]] bool IsSubAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired); [[nodiscard]] bool IsSubAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired);
[[nodiscard]] UNAUTHORIZED_REASON AuthorizeSub( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired ); [[nodiscard]] UNAUTHORIZED_REASON AuthorizeSub( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired );
void CreateSubToken(const std::string & UserName, SecurityObjects::UserInfoAndPolicy &UInfo); void CreateSubToken(const std::string & UserName, SecurityObjects::UserInfoAndPolicy &UInfo);
[[nodiscard]] bool SetSubPassword(const std::string &Password, SecurityObjects::UserInfo & UInfo); [[nodiscard]] bool SetSubPassword(const std::string &Password, SecurityObjects::UserInfo & UInfo);
[[nodiscard]] const std:: string & SubPasswordValidationExpression() const { return PasswordValidationStr_;}; [[nodiscard]] const std:: string & SubPasswordValidationExpression() const { return PasswordValidationStr_;};
@@ -72,6 +77,7 @@ namespace OpenWifi{
[[nodiscard]] std::string GenerateTokenJWT(const std::string & UserName, ACCESS_TYPE Type); [[nodiscard]] std::string GenerateTokenJWT(const std::string & UserName, ACCESS_TYPE Type);
[[nodiscard]] std::string GenerateTokenHMAC(const std::string & UserName, ACCESS_TYPE Type); [[nodiscard]] std::string GenerateTokenHMAC(const std::string & UserName, ACCESS_TYPE Type);
[[nodiscard]] bool IsValidApiKey(const std::string &ApiKey, SecurityObjects::WebToken &WebToken, SecurityObjects::UserInfo &UserInfo, bool & Expired, std::uint64_t & expiresOn);
[[nodiscard]] std::string ComputeNewPasswordHash(const std::string &UserName, const std::string &Password); [[nodiscard]] std::string ComputeNewPasswordHash(const std::string &UserName, const std::string &Password);
[[nodiscard]] bool ValidatePasswordHash(const std::string & UserName, const std::string & Password, const std::string &StoredPassword); [[nodiscard]] bool ValidatePasswordHash(const std::string & UserName, const std::string & Password, const std::string &StoredPassword);
[[nodiscard]] bool ValidateSubPasswordHash(const std::string & UserName, const std::string & Password, const std::string &StoredPassword); [[nodiscard]] bool ValidateSubPasswordHash(const std::string & UserName, const std::string & Password, const std::string &StoredPassword);
@@ -97,11 +103,19 @@ namespace OpenWifi{
void RevokeSubToken(std::string & Token); void RevokeSubToken(std::string & Token);
[[nodiscard]] static inline const std::string GetLogoAssetURI() { [[nodiscard]] static inline const std::string GetLogoAssetURI() {
return MicroService::instance().PublicEndPoint() + "/wwwassets/the_logo.png"; return MicroServicePublicEndPoint() + "/wwwassets/logo.png";
} }
[[nodiscard]] static inline const std::string GetLogoAssetFileName() { [[nodiscard]] static inline const std::string GetLogoAssetFileName() {
return MicroService::instance().WWWAssetsDir() + "/the_logo.png"; return MicroServiceWWWAssetsDir() + "/logo.png";
}
[[nodiscard]] static inline const std::string GetSubLogoAssetURI() {
return MicroServicePublicEndPoint() + "/wwwassets/sub_logo.png";
}
[[nodiscard]] static inline const std::string GetSubLogoAssetFileName() {
return MicroServiceWWWAssetsDir() + "/sub_logo.png";
} }
inline const std::string & GetPasswordPolicy() const { return PasswordPolicy_; } inline const std::string & GetPasswordPolicy() const { return PasswordPolicy_; }
@@ -155,13 +169,12 @@ namespace OpenWifi{
inline auto AuthService() { return AuthService::instance(); } inline auto AuthService() { return AuthService::instance(); }
[[nodiscard]] inline bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo , bool & Expired, bool Sub ) { [[nodiscard]] inline bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo , std::uint64_t TID, bool & Expired, bool Sub ) {
if(Sub) if(Sub)
return AuthService()->IsSubAuthorized(Request, SessionToken, UInfo, Expired ); return AuthService()->IsSubAuthorized(Request, SessionToken, UInfo, TID, Expired );
else else
return AuthService()->IsAuthorized(Request, SessionToken, UInfo, Expired ); return AuthService()->IsAuthorized(Request, SessionToken, UInfo, TID, Expired );
} }
} // end of namespace } // end of namespace
#endif //UCENTRAL_UAUTHSERVICE_H

View File

@@ -26,6 +26,8 @@
#include "SMSSender.h" #include "SMSSender.h"
#include "ActionLinkManager.h" #include "ActionLinkManager.h"
#include "TotpCache.h" #include "TotpCache.h"
#include "framework/RESTAPI_RateLimiter.h"
#include "framework/UI_WebSocketClientServer.h"
namespace OpenWifi { namespace OpenWifi {
class Daemon *Daemon::instance_ = nullptr; class Daemon *Daemon::instance_ = nullptr;
@@ -44,7 +46,8 @@ namespace OpenWifi {
SMTPMailerService(), SMTPMailerService(),
RESTAPI_RateLimiter(), RESTAPI_RateLimiter(),
TotpCache(), TotpCache(),
AuthService() AuthService(),
UI_WebSocketClientServer()
}); });
} }
return instance_; return instance_;
@@ -53,6 +56,10 @@ namespace OpenWifi {
void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) { void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) {
AssetDir_ = MicroService::instance().ConfigPath("openwifi.restapi.wwwassets"); AssetDir_ = MicroService::instance().ConfigPath("openwifi.restapi.wwwassets");
} }
void DaemonPostInitialization(Poco::Util::Application &self) {
Daemon()->PostInitialization(self);
}
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {

View File

@@ -2,14 +2,16 @@
// Created by stephane bourque on 2021-06-10. // Created by stephane bourque on 2021-06-10.
// //
#ifndef UCENTRALSEC_DAEMON_H #pragma once
#define UCENTRALSEC_DAEMON_H
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <vector> #include <vector>
#include <set> #include <set>
#include "framework/MicroServiceNames.h"
#include "framework/MicroService.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/ServerApplication.h" #include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
@@ -20,7 +22,6 @@
#include "Poco/Crypto/CipherFactory.h" #include "Poco/Crypto/CipherFactory.h"
#include "Poco/Crypto/Cipher.h" #include "Poco/Crypto/Cipher.h"
#include "framework/MicroService.h"
namespace OpenWifi { namespace OpenWifi {
@@ -49,9 +50,6 @@ namespace OpenWifi {
}; };
inline Daemon * Daemon() { return Daemon::instance(); } inline Daemon * Daemon() { return Daemon::instance(); }
inline void DaemonPostInitialization(Poco::Util::Application &self) { void DaemonPostInitialization(Poco::Util::Application &self);
Daemon()->PostInitialization(self);
}
} }
#endif //UCENTRALSEC_DAEMON_H

View File

@@ -5,10 +5,12 @@
#include "MFAServer.h" #include "MFAServer.h"
#include "SMSSender.h" #include "SMSSender.h"
#include "SMTPMailerService.h" #include "SMTPMailerService.h"
#include "framework/MicroService.h"
#include "AuthService.h" #include "AuthService.h"
#include "TotpCache.h" #include "TotpCache.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
namespace OpenWifi { namespace OpenWifi {
int MFAServer::Start() { int MFAServer::Start() {
@@ -27,8 +29,8 @@ namespace OpenWifi {
return false; return false;
std::string Challenge = MakeChallenge(); std::string Challenge = MakeChallenge();
std::string uuid = MicroService::CreateUUID(); std::string uuid = MicroServiceCreateUUID();
uint64_t Created = OpenWifi::Now(); uint64_t Created = Utils::Now();
ChallengeStart.set("uuid",uuid); ChallengeStart.set("uuid",uuid);
ChallengeStart.set("created", Created); ChallengeStart.set("created", Created);
@@ -102,7 +104,7 @@ namespace OpenWifi {
void MFAServer::CleanCache() { void MFAServer::CleanCache() {
// it is assumed that you have locked Cache_ at this point. // it is assumed that you have locked Cache_ at this point.
uint64_t Now = OpenWifi::Now(); uint64_t Now = Utils::Now();
for(auto i=begin(Cache_);i!=end(Cache_);) { for(auto i=begin(Cache_);i!=end(Cache_);) {
if((Now-i->second.Created)>300) { if((Now-i->second.Created)>300) {
i = Cache_.erase(i); i = Cache_.erase(i);

View File

@@ -4,9 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h"
#include "Poco/JSON/Object.h" #include "Poco/JSON/Object.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "framework/SubSystemServer.h"
#include "framework/MicroServiceFuncs.h"
#include "fmt/format.h"
namespace OpenWifi { namespace OpenWifi {
@@ -46,7 +49,7 @@ namespace OpenWifi {
static bool SendChallenge(const SecurityObjects::UserInfoAndPolicy &UInfo, const std::string &Method, const std::string &Challenge); static bool SendChallenge(const SecurityObjects::UserInfoAndPolicy &UInfo, const std::string &Method, const std::string &Challenge);
static inline std::string MakeChallenge() { static inline std::string MakeChallenge() {
return fmt::format("{0:06}" , MicroService::instance().Random(1,999999) ); return fmt::format("{0:06}" , MicroServiceRandom(1,999999) );
} }
private: private:

View File

@@ -19,7 +19,7 @@ namespace OpenWifi {
enum EMAIL_REASON { enum EMAIL_REASON {
FORGOT_PASSWORD = 0, FORGOT_PASSWORD = 0,
EMAIL_VERIFICATION, EMAIL_VERIFICATION,
SIGNUP_VERIFICATION, SUB_SIGNUP_VERIFICATION,
EMAIL_INVITATION, EMAIL_INVITATION,
VERIFICATION_CODE, VERIFICATION_CODE,
SUB_FORGOT_PASSWORD, SUB_FORGOT_PASSWORD,
@@ -37,7 +37,7 @@ namespace OpenWifi {
switch (r) { switch (r) {
case FORGOT_PASSWORD: return AddOperator(EmailTemplateNames[FORGOT_PASSWORD],OperatorName); case FORGOT_PASSWORD: return AddOperator(EmailTemplateNames[FORGOT_PASSWORD],OperatorName);
case EMAIL_VERIFICATION: return AddOperator(EmailTemplateNames[EMAIL_VERIFICATION],OperatorName); case EMAIL_VERIFICATION: return AddOperator(EmailTemplateNames[EMAIL_VERIFICATION],OperatorName);
case SIGNUP_VERIFICATION: return AddOperator(EmailTemplateNames[SIGNUP_VERIFICATION],OperatorName); case SUB_SIGNUP_VERIFICATION: return AddOperator(EmailTemplateNames[SUB_SIGNUP_VERIFICATION],OperatorName);
case EMAIL_INVITATION: return AddOperator(EmailTemplateNames[EMAIL_INVITATION],OperatorName); case EMAIL_INVITATION: return AddOperator(EmailTemplateNames[EMAIL_INVITATION],OperatorName);
case VERIFICATION_CODE: return AddOperator(EmailTemplateNames[VERIFICATION_CODE],OperatorName); case VERIFICATION_CODE: return AddOperator(EmailTemplateNames[VERIFICATION_CODE],OperatorName);
case SUB_FORGOT_PASSWORD: return AddOperator(EmailTemplateNames[SUB_FORGOT_PASSWORD],OperatorName); case SUB_FORGOT_PASSWORD: return AddOperator(EmailTemplateNames[SUB_FORGOT_PASSWORD],OperatorName);
@@ -49,18 +49,18 @@ namespace OpenWifi {
} }
static std::string Logo(const std::string &OperatorName = "" ) { static std::string Logo(const std::string &OperatorName = "" ) {
return AddOperator("logo.jpg", OperatorName); return AddOperator("logo.png", OperatorName);
} }
static std::string SubLogo(const std::string &OperatorName = "" ) { static std::string SubLogo(const std::string &OperatorName = "" ) {
return AddOperator("sub_logo.jpg", OperatorName); return AddOperator("sub_logo.png", OperatorName);
} }
private: private:
inline const static std::vector<std::string> EmailTemplateNames = { inline const static std::vector<std::string> EmailTemplateNames = {
"password_reset", "password_reset",
"email_verification", "email_verification",
"signup_verification", "sub_signup_verification",
"email_invitation", "email_invitation",
"verification_code", "verification_code",
"sub_password_reset", "sub_password_reset",

View File

@@ -7,7 +7,9 @@
#include "RESTAPI_action_links.h" #include "RESTAPI_action_links.h"
#include "StorageService.h" #include "StorageService.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_PartHandler.h"
#include "framework/OpenAPIRequests.h"
#include "Daemon.h" #include "Daemon.h"
namespace OpenWifi { namespace OpenWifi {
@@ -60,7 +62,7 @@ namespace OpenWifi {
void RESTAPI_action_links::DoNewSubVerification(SecurityObjects::ActionLink &Link) { void RESTAPI_action_links::DoNewSubVerification(SecurityObjects::ActionLink &Link) {
Logger_.information(fmt::format("REQUEST-SUB-SIGNUP({}): For ID={}", Request->clientAddress().toString(), Link.userId)); Logger_.information(fmt::format("REQUEST-SUB-SIGNUP({}): For ID={}", Request->clientAddress().toString(), Link.userId));
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_signup_verification.html"};
Types::StringPairVec FormVars{ {"UUID", Link.id}, Types::StringPairVec FormVars{ {"UUID", Link.id},
{"PASSWORD_VALIDATION", AuthService()->PasswordValidationExpression()}}; {"PASSWORD_VALIDATION", AuthService()->PasswordValidationExpression()}};
SendHTMLFileBack(FormFile,FormVars); SendHTMLFileBack(FormFile,FormVars);
@@ -159,7 +161,7 @@ namespace OpenWifi {
} }
if(Password1!=Password2 || !AuthService()->ValidateSubPassword(Password1)) { if(Password1!=Password2 || !AuthService()->ValidateSubPassword(Password1)) {
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset_error.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_password_reset_error.html"};
Types::StringPairVec FormVars{ {"UUID", Id}, Types::StringPairVec FormVars{ {"UUID", Id},
{"ERROR_TEXT", "For some reason, the passwords entered do not match or they do not comply with" {"ERROR_TEXT", "For some reason, the passwords entered do not match or they do not comply with"
" accepted password creation restrictions. Please consult our on-line help" " accepted password creation restrictions. Please consult our on-line help"
@@ -171,14 +173,14 @@ namespace OpenWifi {
SecurityObjects::UserInfo UInfo; SecurityObjects::UserInfo UInfo;
bool Found = StorageService()->SubDB().GetUserById(Link.userId,UInfo); bool Found = StorageService()->SubDB().GetUserById(Link.userId,UInfo);
if(!Found) { if(!Found) {
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification_error.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_signup_verification_error.html"};
Types::StringPairVec FormVars{ {"UUID", Id}, Types::StringPairVec FormVars{ {"UUID", Id},
{"ERROR_TEXT", "This request does not contain a valid user ID. Please contact your system administrator."}}; {"ERROR_TEXT", "This request does not contain a valid user ID. Please contact your system administrator."}};
return SendHTMLFileBack(FormFile,FormVars); return SendHTMLFileBack(FormFile,FormVars);
} }
if(UInfo.blackListed || UInfo.suspended) { if(UInfo.blackListed || UInfo.suspended) {
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification_error.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_signup_verification_error.html"};
Types::StringPairVec FormVars{ {"UUID", Id}, Types::StringPairVec FormVars{ {"UUID", Id},
{"ERROR_TEXT", "Please contact our system administrators. We have identified an error in your account that must be resolved first."}}; {"ERROR_TEXT", "Please contact our system administrators. We have identified an error in your account that must be resolved first."}};
return SendHTMLFileBack(FormFile,FormVars); return SendHTMLFileBack(FormFile,FormVars);
@@ -186,7 +188,7 @@ namespace OpenWifi {
bool GoodPassword = AuthService()->SetSubPassword(Password1,UInfo); bool GoodPassword = AuthService()->SetSubPassword(Password1,UInfo);
if(!GoodPassword) { if(!GoodPassword) {
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification_error.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_signup_verification_error.html"};
Types::StringPairVec FormVars{ {"UUID", Id}, Types::StringPairVec FormVars{ {"UUID", Id},
{"ERROR_TEXT", "You cannot reuse one of your recent passwords."}}; {"ERROR_TEXT", "You cannot reuse one of your recent passwords."}};
return SendHTMLFileBack(FormFile,FormVars); return SendHTMLFileBack(FormFile,FormVars);
@@ -200,7 +202,7 @@ namespace OpenWifi {
StorageService()->SubDB().UpdateUserInfo(UInfo.email,Link.userId,UInfo); StorageService()->SubDB().UpdateUserInfo(UInfo.email,Link.userId,UInfo);
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification_success.html"}; Poco::File FormFile{ Daemon()->AssetDir() + "/sub_signup_verification_success.html"};
Types::StringPairVec FormVars{ {"UUID", Id}, Types::StringPairVec FormVars{ {"UUID", Id},
{"USERNAME", UInfo.email} }; {"USERNAME", UInfo.email} };
StorageService()->ActionLinksDB().CompleteAction(Id); StorageService()->ActionLinksDB().CompleteAction(Id);

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_action_links : public RESTAPIHandler { class RESTAPI_action_links : public RESTAPIHandler {
public: public:
RESTAPI_action_links(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_action_links(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -0,0 +1,158 @@
//
// Created by stephane bourque on 2022-11-04.
//
#include "RESTAPI_apiKey_handler.h"
#include "RESTAPI/RESTAPI_db_helpers.h"
namespace OpenWifi {
void RESTAPI_apiKey_handler::DoGet() {
std::string user_uuid = GetBinding("uuid","");
if(user_uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
if(user_uuid!=UserInfo_.userinfo.id && UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
SecurityObjects::ApiKeyEntryList List;
if(DB_.GetRecords(0,500, List.apiKeys, fmt::format(" userUuid='{}' ", user_uuid))) {
for(auto &key:List.apiKeys) {
Sanitize(UserInfo_, key);
}
Poco::JSON::Object Answer;
List.to_json(Answer);
return ReturnObject(Answer);
}
return NotFound();
}
void RESTAPI_apiKey_handler::DoDelete() {
std::string user_uuid = GetBinding("uuid","");
if(user_uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
if(user_uuid!=UserInfo_.userinfo.id && UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
if(user_uuid!=UserInfo_.userinfo.id) {
if(!StorageService()->UserDB().Exists("id",user_uuid)) {
return NotFound();
}
}
std::string ApiKeyId= GetParameter("keyUuid","");
if(ApiKeyId.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
SecurityObjects::ApiKeyEntry ApiKey;
if(StorageService()->ApiKeyDB().GetRecord("id",ApiKeyId,ApiKey)) {
if(ApiKey.userUuid==user_uuid) {
AuthService()->RemoveTokenSystemWide(ApiKey.apiKey);
DB_.DeleteRecord("id", ApiKeyId);
return OK();
}
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
return NotFound();
}
void RESTAPI_apiKey_handler::DoPost() {
std::string user_uuid = GetBinding("uuid","");
if(user_uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
if(user_uuid!=UserInfo_.userinfo.id && UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
if(user_uuid!=UserInfo_.userinfo.id) {
// Must verify if the user exists
if(!StorageService()->UserDB().Exists("id",user_uuid)) {
return BadRequest(RESTAPI::Errors::UserMustExist);
}
}
SecurityObjects::ApiKeyEntry NewKey;
if(!NewKey.from_json(ParsedBody_)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
NewKey.lastUse = 0 ;
if(!Utils::IsAlphaNumeric(NewKey.name) || NewKey.name.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
Poco::toLowerInPlace(NewKey.name);
NewKey.userUuid = user_uuid;
if(NewKey.expiresOn < Utils::Now()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
// does a key of that name already exit for this user?
SecurityObjects::ApiKeyEntryList ExistingList;
if(DB_.GetRecords(0,500, ExistingList.apiKeys, fmt::format(" userUuid='{}' ", user_uuid))) {
if(std::find_if(ExistingList.apiKeys.begin(),ExistingList.apiKeys.end(), [NewKey](const SecurityObjects::ApiKeyEntry &E) -> bool {
return E.name==NewKey.name;
})!=ExistingList.apiKeys.end()) {
return BadRequest(RESTAPI::Errors::ApiKeyNameAlreadyExists);
}
}
if(ExistingList.apiKeys.size()>=10) {
return BadRequest(RESTAPI::Errors::TooManyApiKeys);
}
NewKey.id = MicroServiceCreateUUID();
NewKey.userUuid = user_uuid;
NewKey.salt = std::to_string(Utils::Now());
NewKey.apiKey = Utils::ComputeHash(NewKey.salt, UserInfo_.userinfo.id, UserInfo_.webtoken.access_token_ );
NewKey.created = Utils::Now();
if(DB_.CreateRecord(NewKey)) {
Poco::JSON::Object Answer;
NewKey.to_json(Answer);
return ReturnObject(Answer);
}
return BadRequest(RESTAPI::Errors::RecordNotCreated);
}
void RESTAPI_apiKey_handler::DoPut() {
std::string user_uuid = GetBinding("uuid","");
if(user_uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
if(user_uuid!=UserInfo_.userinfo.id && UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
SecurityObjects::ApiKeyEntry NewKey;
if(!NewKey.from_json(ParsedBody_)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
SecurityObjects::ApiKeyEntry ExistingKey;
if(!DB_.GetRecord("id",NewKey.id,ExistingKey)) {
return BadRequest(RESTAPI::Errors::ApiKeyDoesNotExist);
}
if(ExistingKey.userUuid!=user_uuid) {
return BadRequest(RESTAPI::Errors::MissingUserID);
}
AssignIfPresent(ParsedBody_,"description",ExistingKey.description);
if(DB_.UpdateRecord("id",ExistingKey.id,ExistingKey)) {
Poco::JSON::Object Answer;
ExistingKey.to_json(Answer);
return ReturnObject(Answer);
}
BadRequest(RESTAPI::Errors::RecordNotUpdated);
}
}

View File

@@ -0,0 +1,34 @@
//
// Created by stephane bourque on 2022-11-04.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_apiKey_handler : public RESTAPIHandler {
public:
RESTAPI_apiKey_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_PUT,
Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_DELETE,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
TransactionId,
Internal) {}
static auto PathName() { return std::list<std::string>{"/api/v1/apiKey/{uuid}"}; };
private:
ApiKeyDB &DB_=StorageService()->ApiKeyDB();
void DoGet() final;
void DoPut() final;
void DoPost() final;
void DoDelete() final;
};
}

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "../framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_asset_server : public RESTAPIHandler { class RESTAPI_asset_server : public RESTAPIHandler {
public: public:
RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_POST, {Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -8,7 +8,8 @@
#include "RESTAPI_avatar_handler.h" #include "RESTAPI_avatar_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "Poco/Net/HTMLForm.h" #include "Poco/Net/HTMLForm.h"
#include "framework/MicroService.h" #include "Poco/CountingStream.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
@@ -34,7 +35,7 @@ namespace OpenWifi {
Poco::Net::HTMLForm form(*Request, Request->stream(), partHandler); Poco::Net::HTMLForm form(*Request, Request->stream(), partHandler);
Poco::JSON::Object Answer; Poco::JSON::Object Answer;
if (!partHandler.Name().empty() && partHandler.Length()< MicroService::instance().ConfigGetInt("openwifi.avatar.maxsize",2000000)) { if (!partHandler.Name().empty() && partHandler.Length()< MicroServiceConfigGetInt("openwifi.avatar.maxsize",2000000)) {
Answer.set(RESTAPI::Protocol::AVATARID, Id); Answer.set(RESTAPI::Protocol::AVATARID, Id);
Answer.set(RESTAPI::Protocol::ERRORCODE, 0); Answer.set(RESTAPI::Protocol::ERRORCODE, 0);
Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType())); Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType()));

View File

@@ -3,7 +3,8 @@
// //
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
#include "Poco/Net/PartHandler.h"
namespace OpenWifi { namespace OpenWifi {
@@ -32,7 +33,7 @@ namespace OpenWifi {
class RESTAPI_avatar_handler : public RESTAPIHandler { class RESTAPI_avatar_handler : public RESTAPIHandler {
public: public:
RESTAPI_avatar_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_avatar_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,
@@ -48,6 +49,5 @@ namespace OpenWifi {
void DoPost() final; void DoPost() final;
void DoDelete() final; void DoDelete() final;
void DoPut() final {}; void DoPut() final {};
}; };
} }

View File

@@ -14,4 +14,7 @@ namespace OpenWifi {
U.oauthType.clear(); U.oauthType.clear();
} }
inline void Sanitize([[maybe_unused]] const SecurityObjects::UserInfoAndPolicy &User, SecurityObjects::ApiKeyEntry & U) {
U.salt.clear();
}
} }

View File

@@ -3,14 +3,10 @@
// //
#include "RESTAPI_email_handler.h" #include "RESTAPI_email_handler.h"
#include "Poco/Exception.h"
#include "Poco/JSON/Parser.h" #include "Poco/JSON/Parser.h"
#include "SMTPMailerService.h" #include "SMTPMailerService.h"
#include "framework/ow_constants.h" #include "framework/ow_constants.h"
#include "framework/MicroService.h"
namespace OpenWifi { namespace OpenWifi {
void RESTAPI_email_handler::DoPost() { void RESTAPI_email_handler::DoPost() {
@@ -28,7 +24,7 @@ namespace OpenWifi {
Attrs[SUBJECT] = Obj->get("subject").toString(); Attrs[SUBJECT] = Obj->get("subject").toString();
Attrs[TEXT] = Obj->get("text").toString(); Attrs[TEXT] = Obj->get("text").toString();
Attrs[SENDER] = Obj->get("from").toString(); Attrs[SENDER] = Obj->get("from").toString();
if(SMTPMailerService()->SendMessage(Recipient, "password_reset.txt", Attrs)) { if(SMTPMailerService()->SendMessage(Recipient, "password_reset.txt", Attrs, false)) {
return OK(); return OK();
} }
return ReturnStatus(Poco::Net::HTTPResponse::HTTP_SERVICE_UNAVAILABLE); return ReturnStatus(Poco::Net::HTTPResponse::HTTP_SERVICE_UNAVAILABLE);

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_email_handler : public RESTAPIHandler { class RESTAPI_email_handler : public RESTAPIHandler {
public: public:
RESTAPI_email_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_email_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_OPTIONS}, Poco::Net::HTTPRequest::HTTP_OPTIONS},

View File

@@ -12,10 +12,11 @@
#include "RESTAPI_oauth2_handler.h" #include "RESTAPI_oauth2_handler.h"
#include "MFAServer.h" #include "MFAServer.h"
#include "framework/ow_constants.h" #include "framework/ow_constants.h"
#include "framework/MicroService.h"
#include "StorageService.h" #include "StorageService.h"
#include "RESTAPI_db_helpers.h" #include "RESTAPI_db_helpers.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
void RESTAPI_oauth2_handler::DoGet() { void RESTAPI_oauth2_handler::DoGet() {
@@ -99,7 +100,7 @@ namespace OpenWifi {
SecurityObjects::ActionLink NewLink; SecurityObjects::ActionLink NewLink;
NewLink.action = OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD; NewLink.action = OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD;
NewLink.id = MicroService::CreateUUID(); NewLink.id = MicroServiceCreateUUID();
NewLink.userId = UInfo1.id; NewLink.userId = UInfo1.id;
NewLink.created = OpenWifi::Now(); NewLink.created = OpenWifi::Now();
NewLink.expires = NewLink.created + (24*60*60); NewLink.expires = NewLink.created + (24*60*60);

View File

@@ -7,12 +7,12 @@
// //
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_oauth2_handler : public RESTAPIHandler { class RESTAPI_oauth2_handler : public RESTAPIHandler {
public: public:
RESTAPI_oauth2_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_oauth2_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_DELETE, Poco::Net::HTTPRequest::HTTP_DELETE,

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_preferences : public RESTAPIHandler { class RESTAPI_preferences : public RESTAPIHandler {
public: public:
RESTAPI_preferences(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_preferences(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -2,8 +2,6 @@
// Created by stephane bourque on 2021-10-23. // Created by stephane bourque on 2021-10-23.
// //
#include "framework/MicroService.h"
#include "RESTAPI/RESTAPI_oauth2_handler.h" #include "RESTAPI/RESTAPI_oauth2_handler.h"
#include "RESTAPI/RESTAPI_user_handler.h" #include "RESTAPI/RESTAPI_user_handler.h"
#include "RESTAPI/RESTAPI_users_handler.h" #include "RESTAPI/RESTAPI_users_handler.h"
@@ -25,11 +23,16 @@
#include "RESTAPI/RESTAPI_totp_handler.h" #include "RESTAPI/RESTAPI_totp_handler.h"
#include "RESTAPI/RESTAPI_subtotp_handler.h" #include "RESTAPI/RESTAPI_subtotp_handler.h"
#include "RESTAPI/RESTAPI_signup_handler.h" #include "RESTAPI/RESTAPI_signup_handler.h"
#include "RESTAPI/RESTAPI_apiKey_handler.h"
#include "RESTAPI/RESTAPI_validate_apikey.h"
#include "framework/RESTAPI_SystemCommand.h"
#include "framework/RESTAPI_WebSocketServer.h"
namespace OpenWifi { namespace OpenWifi {
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings, Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
Poco::Logger & L, RESTAPI_GenericServer & S, Poco::Logger & L, RESTAPI_GenericServerAccounting & S,
uint64_t TransactionId) { uint64_t TransactionId) {
return RESTAPI_Router< return RESTAPI_Router<
RESTAPI_oauth2_handler, RESTAPI_oauth2_handler,
@@ -53,12 +56,15 @@ namespace OpenWifi {
RESTAPI_subtotp_handler, RESTAPI_subtotp_handler,
RESTAPI_signup_handler, RESTAPI_signup_handler,
RESTAPI_validate_sub_token_handler, RESTAPI_validate_sub_token_handler,
RESTAPI_validate_token_handler RESTAPI_validate_token_handler,
RESTAPI_validate_apikey,
RESTAPI_webSocketServer,
RESTAPI_apiKey_handler
>(Path, Bindings, L, S,TransactionId); >(Path, Bindings, L, S,TransactionId);
} }
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings, Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) { Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t TransactionId) {
return RESTAPI_Router_I< return RESTAPI_Router_I<
RESTAPI_oauth2_handler, RESTAPI_oauth2_handler,
@@ -82,6 +88,7 @@ namespace OpenWifi {
RESTAPI_subtotp_handler, RESTAPI_subtotp_handler,
RESTAPI_validate_sub_token_handler, RESTAPI_validate_sub_token_handler,
RESTAPI_validate_token_handler, RESTAPI_validate_token_handler,
RESTAPI_validate_apikey,
RESTAPI_signup_handler RESTAPI_signup_handler
>(Path, Bindings, L, S, TransactionId); >(Path, Bindings, L, S, TransactionId);
} }

View File

@@ -5,6 +5,7 @@
#include "RESTAPI_signup_handler.h" #include "RESTAPI_signup_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "framework/MicroServiceFuncs.h"
#define __DBG__ std::cout << __LINE__ << std::endl; #define __DBG__ std::cout << __LINE__ << std::endl;
namespace OpenWifi { namespace OpenWifi {
@@ -43,7 +44,7 @@ namespace OpenWifi {
NewSub.name = UserName; NewSub.name = UserName;
NewSub.modified = OpenWifi::Now(); NewSub.modified = OpenWifi::Now();
NewSub.creationDate = OpenWifi::Now(); NewSub.creationDate = OpenWifi::Now();
NewSub.id = MicroService::instance().CreateUUID(); NewSub.id = MicroServiceCreateUUID();
NewSub.email = UserName; NewSub.email = UserName;
NewSub.userRole = SecurityObjects::SUBSCRIBER; NewSub.userRole = SecurityObjects::SUBSCRIBER;
NewSub.changePassword = true; NewSub.changePassword = true;
@@ -55,7 +56,7 @@ namespace OpenWifi {
SecurityObjects::ActionLink NewLink; SecurityObjects::ActionLink NewLink;
NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP; NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP;
NewLink.id = MicroService::CreateUUID(); NewLink.id = MicroServiceCreateUUID();
NewLink.userId = NewSub.id; NewLink.userId = NewSub.id;
NewLink.created = OpenWifi::Now(); NewLink.created = OpenWifi::Now();
NewLink.expires = NewLink.created + (1*60*60); // 1 hour NewLink.expires = NewLink.created + (1*60*60); // 1 hour

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_signup_handler : public RESTAPIHandler { class RESTAPI_signup_handler : public RESTAPIHandler {
public: public:
RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal) RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_POST, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -5,7 +5,6 @@
#include "RESTAPI_sms_handler.h" #include "RESTAPI_sms_handler.h"
#include "SMSSender.h" #include "SMSSender.h"
#include "framework/ow_constants.h" #include "framework/ow_constants.h"
#include "framework/MicroService.h"
namespace OpenWifi { namespace OpenWifi {

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_sms_handler : public RESTAPIHandler { class RESTAPI_sms_handler : public RESTAPIHandler {
public: public:
RESTAPI_sms_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_sms_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_OPTIONS}, Poco::Net::HTTPRequest::HTTP_OPTIONS},

View File

@@ -8,7 +8,8 @@
#include "RESTAPI_subavatar_handler.h" #include "RESTAPI_subavatar_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "Poco/Net/HTMLForm.h" #include "Poco/Net/HTMLForm.h"
#include "framework/MicroService.h" #include "Poco/CountingStream.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
@@ -34,7 +35,7 @@ namespace OpenWifi {
Poco::Net::HTMLForm form(*Request, Request->stream(), partHandler); Poco::Net::HTMLForm form(*Request, Request->stream(), partHandler);
Poco::JSON::Object Answer; Poco::JSON::Object Answer;
if (!partHandler.Name().empty() && partHandler.Length()< MicroService::instance().ConfigGetInt("openwifi.avatar.maxsize",2000000)) { if (!partHandler.Name().empty() && partHandler.Length()< MicroServiceConfigGetInt("openwifi.avatar.maxsize",2000000)) {
Answer.set(RESTAPI::Protocol::AVATARID, Id); Answer.set(RESTAPI::Protocol::AVATARID, Id);
Answer.set(RESTAPI::Protocol::ERRORCODE, 0); Answer.set(RESTAPI::Protocol::ERRORCODE, 0);
Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType())); Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType()));

View File

@@ -3,7 +3,8 @@
// //
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
#include "Poco/Net/PartHandler.h"
namespace OpenWifi { namespace OpenWifi {
@@ -32,7 +33,7 @@ namespace OpenWifi {
class RESTAPI_subavatar_handler : public RESTAPIHandler { class RESTAPI_subavatar_handler : public RESTAPIHandler {
public: public:
RESTAPI_subavatar_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_subavatar_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -5,6 +5,7 @@
#include "RESTAPI_submfa_handler.h" #include "RESTAPI_submfa_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "SMSSender.h" #include "SMSSender.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
@@ -64,7 +65,7 @@ namespace OpenWifi {
MFC.sms = MFC.sms; MFC.sms = MFC.sms;
MFC.type = "email"; MFC.type = "email";
MFC.email = UserInfo_.userinfo.email; MFC.email = UserInfo_.userinfo.email;
MFC.id = MicroService::instance().CreateUUID(); MFC.id = MicroServiceCreateUUID();
Poco::JSON::Object Answer; Poco::JSON::Object Answer;
MFC.to_json(Answer); MFC.to_json(Answer);
@@ -116,7 +117,7 @@ namespace OpenWifi {
MFC.sms = MFC.sms; MFC.sms = MFC.sms;
MFC.type = "sms"; MFC.type = "sms";
MFC.email = UserInfo_.userinfo.email; MFC.email = UserInfo_.userinfo.email;
MFC.id = MicroService::instance().CreateUUID(); MFC.id = MicroServiceCreateUUID();
Poco::JSON::Object Answer; Poco::JSON::Object Answer;
MFC.to_json(Answer); MFC.to_json(Answer);

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_submfa_handler : public RESTAPIHandler { class RESTAPI_submfa_handler : public RESTAPIHandler {
public: public:
RESTAPI_submfa_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_submfa_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_PUT, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_PUT,
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -5,7 +5,6 @@
#include "RESTAPI_suboauth2_handler.h" #include "RESTAPI_suboauth2_handler.h"
#include "AuthService.h" #include "AuthService.h"
#include "MFAServer.h" #include "MFAServer.h"
#include "framework/MicroService.h"
#include "StorageService.h" #include "StorageService.h"
#include "RESTAPI/RESTAPI_db_helpers.h" #include "RESTAPI/RESTAPI_db_helpers.h"
@@ -87,7 +86,7 @@ namespace OpenWifi {
SecurityObjects::ActionLink NewLink; SecurityObjects::ActionLink NewLink;
NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD; NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD;
NewLink.id = MicroService::CreateUUID(); NewLink.id = MicroServiceCreateUUID();
NewLink.userId = UInfo1.id; NewLink.userId = UInfo1.id;
NewLink.created = OpenWifi::Now(); NewLink.created = OpenWifi::Now();
NewLink.expires = NewLink.created + (24*60*60); NewLink.expires = NewLink.created + (24*60*60);

View File

@@ -3,12 +3,12 @@
// //
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_suboauth2_handler : public RESTAPIHandler { class RESTAPI_suboauth2_handler : public RESTAPIHandler {
public: public:
RESTAPI_suboauth2_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_suboauth2_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_DELETE, Poco::Net::HTTPRequest::HTTP_DELETE,

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_subpreferences : public RESTAPIHandler { class RESTAPI_subpreferences : public RESTAPIHandler {
public: public:
RESTAPI_subpreferences(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_subpreferences(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{ std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -5,6 +5,7 @@
#include "RESTAPI_subtotp_handler.h" #include "RESTAPI_subtotp_handler.h"
#include "TotpCache.h" #include "TotpCache.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {

View File

@@ -2,12 +2,12 @@
// Created by stephane bourque on 2022-01-31. // Created by stephane bourque on 2022-01-31.
// //
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_subtotp_handler : public RESTAPIHandler { class RESTAPI_subtotp_handler : public RESTAPIHandler {
public: public:
RESTAPI_subtotp_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_subtotp_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{ {

View File

@@ -13,6 +13,8 @@
#include "MFAServer.h" #include "MFAServer.h"
#include "TotpCache.h" #include "TotpCache.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
void RESTAPI_subuser_handler::DoGet() { void RESTAPI_subuser_handler::DoGet() {
@@ -183,7 +185,7 @@ namespace OpenWifi {
SecurityObjects::ActionLink NewLink; SecurityObjects::ActionLink NewLink;
NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD; NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD;
NewLink.id = MicroService::CreateUUID(); NewLink.id = MicroServiceCreateUUID();
NewLink.userId = Existing.id; NewLink.userId = Existing.id;
NewLink.created = OpenWifi::Now(); NewLink.created = OpenWifi::Now();
NewLink.expires = NewLink.created + (24*60*60); NewLink.expires = NewLink.created + (24*60*60);

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_subuser_handler : public RESTAPIHandler { class RESTAPI_subuser_handler : public RESTAPIHandler {
public: public:
RESTAPI_subuser_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_subuser_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_POST, {Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -4,7 +4,6 @@
#include "RESTAPI_subusers_handler.h" #include "RESTAPI_subusers_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "framework/MicroService.h"
#include "RESTAPI/RESTAPI_db_helpers.h" #include "RESTAPI/RESTAPI_db_helpers.h"
namespace OpenWifi { namespace OpenWifi {

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_subusers_handler : public RESTAPIHandler { class RESTAPI_subusers_handler : public RESTAPIHandler {
public: public:
RESTAPI_subusers_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_subusers_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_GET, {Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -4,11 +4,12 @@
#include "RESTAPI_system_endpoints_handler.h" #include "RESTAPI_system_endpoints_handler.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
void RESTAPI_system_endpoints_handler::DoGet() { void RESTAPI_system_endpoints_handler::DoGet() {
auto Services = MicroService::instance().GetServices(); auto Services = MicroServiceGetServices();
SecurityObjects::SystemEndpointList L; SecurityObjects::SystemEndpointList L;
for(const auto &i:Services) { for(const auto &i:Services) {
SecurityObjects::SystemEndpoint S{ SecurityObjects::SystemEndpoint S{

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "../framework/MicroService.h" #include "../framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_system_endpoints_handler : public RESTAPIHandler { class RESTAPI_system_endpoints_handler : public RESTAPIHandler {
public: public:
RESTAPI_system_endpoints_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_system_endpoints_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET, std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS}, Poco::Net::HTTPRequest::HTTP_OPTIONS},

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_totp_handler : public RESTAPIHandler { class RESTAPI_totp_handler : public RESTAPIHandler {
public: public:
RESTAPI_totp_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_totp_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{ {

View File

@@ -12,6 +12,7 @@
#include "RESTAPI/RESTAPI_db_helpers.h" #include "RESTAPI/RESTAPI_db_helpers.h"
#include "MFAServer.h" #include "MFAServer.h"
#include "TotpCache.h" #include "TotpCache.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
@@ -65,6 +66,7 @@ namespace OpenWifi {
StorageService()->AvatarDB().DeleteAvatar(UserInfo_.userinfo.email,Id); StorageService()->AvatarDB().DeleteAvatar(UserInfo_.userinfo.email,Id);
StorageService()->PreferencesDB().DeletePreferences(UserInfo_.userinfo.email,Id); StorageService()->PreferencesDB().DeletePreferences(UserInfo_.userinfo.email,Id);
StorageService()->UserTokenDB().RevokeAllTokens(Id); StorageService()->UserTokenDB().RevokeAllTokens(Id);
StorageService()->ApiKeyDB().RemoveAllApiKeys(Id);
Logger_.information(fmt::format("User '{}' deleted by '{}'.",Id,UserInfo_.userinfo.email)); Logger_.information(fmt::format("User '{}' deleted by '{}'.",Id,UserInfo_.userinfo.email));
OK(); OK();
} }
@@ -191,7 +193,7 @@ namespace OpenWifi {
SecurityObjects::ActionLink NewLink; SecurityObjects::ActionLink NewLink;
NewLink.action = OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD; NewLink.action = OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD;
NewLink.id = MicroService::CreateUUID(); NewLink.id = MicroServiceCreateUUID();
NewLink.userId = Existing.id; NewLink.userId = Existing.id;
NewLink.created = OpenWifi::Now(); NewLink.created = OpenWifi::Now();
NewLink.expires = NewLink.created + (24*60*60); NewLink.expires = NewLink.created + (24*60*60);

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_user_handler : public RESTAPIHandler { class RESTAPI_user_handler : public RESTAPIHandler {
public: public:
RESTAPI_user_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_user_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_POST, {Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -4,7 +4,6 @@
#include "RESTAPI_users_handler.h" #include "RESTAPI_users_handler.h"
#include "StorageService.h" #include "StorageService.h"
#include "framework/MicroService.h"
#include "RESTAPI/RESTAPI_db_helpers.h" #include "RESTAPI/RESTAPI_db_helpers.h"
namespace OpenWifi { namespace OpenWifi {

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_users_handler : public RESTAPIHandler { class RESTAPI_users_handler : public RESTAPIHandler {
public: public:
RESTAPI_users_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_users_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_GET, {Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -0,0 +1,31 @@
//
// Created by stephane bourque on 2022-11-07.
//
#include "RESTAPI_validate_apikey.h"
#include "AuthService.h"
namespace OpenWifi {
void RESTAPI_validate_apikey::DoGet() {
Poco::URI URI(Request->getURI());
auto Parameters = URI.getQueryParameters();
for(auto const &i:Parameters) {
if (i.first == "apikey") {
// can we find this token?
SecurityObjects::UserInfoAndPolicy SecObj;
bool Expired = false;
std::uint64_t expiresOn=0;
if (AuthService()->IsValidApiKey(i.second, SecObj.webtoken, SecObj.userinfo, Expired, expiresOn)) {
Poco::JSON::Object Answer;
SecObj.to_json(Answer);
Answer.set("expiresOn", expiresOn);
return ReturnObject(Answer);
}
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
}
return NotFound();
}
} // OpenWifi

View File

@@ -0,0 +1,27 @@
//
// Created by stephane bourque on 2022-11-07.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
namespace OpenWifi {
class RESTAPI_validate_apikey : public RESTAPIHandler {
public:
RESTAPI_validate_apikey(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
TransactionId,
Internal) {};
static auto PathName() { return std::list<std::string>{"/api/v1/validateApiKey"}; };
void DoGet() final;
void DoPost() final {};
void DoDelete() final {};
void DoPut() final {};
};
}

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_validate_sub_token_handler : public RESTAPIHandler { class RESTAPI_validate_sub_token_handler : public RESTAPIHandler {
public: public:
RESTAPI_validate_sub_token_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_validate_sub_token_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_GET, {Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -4,12 +4,12 @@
#pragma once #pragma once
#include "framework/MicroService.h" #include "framework/RESTAPI_Handler.h"
namespace OpenWifi { namespace OpenWifi {
class RESTAPI_validate_token_handler : public RESTAPIHandler { class RESTAPI_validate_token_handler : public RESTAPIHandler {
public: public:
RESTAPI_validate_token_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal) RESTAPI_validate_token_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L, : RESTAPIHandler(bindings, L,
std::vector<std::string> std::vector<std::string>
{Poco::Net::HTTPRequest::HTTP_GET, {Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -4,7 +4,7 @@
#include "RESTAPI_AnalyticsObjects.h" #include "RESTAPI_AnalyticsObjects.h"
#include "RESTAPI_ProvObjects.h" #include "RESTAPI_ProvObjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;

View File

@@ -5,6 +5,7 @@
#pragma once #pragma once
#include "RESTAPI_ProvObjects.h" #include "RESTAPI_ProvObjects.h"
#include "framework/utils.h"
#include <vector> #include <vector>
namespace OpenWifi { namespace OpenWifi {
@@ -375,7 +376,7 @@ namespace OpenWifi {
}; };
struct WifiClientHistory { struct WifiClientHistory {
uint64_t timestamp=OpenWifi::Now(); uint64_t timestamp=Utils::Now();
std::string station_id; std::string station_id;
std::string bssid; std::string bssid;
std::string ssid; std::string ssid;

View File

@@ -3,7 +3,7 @@
// //
#include "RESTAPI_CertObjects.h" #include "RESTAPI_CertObjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;
@@ -154,6 +154,7 @@ namespace OpenWifi::CertObjects {
field_to_json(Obj,"submitted", submitted); field_to_json(Obj,"submitted", submitted);
field_to_json(Obj,"started", started); field_to_json(Obj,"started", started);
field_to_json(Obj,"completed", completed); field_to_json(Obj,"completed", completed);
field_to_json(Obj,"requesterUsername", requesterUsername);
} }
bool JobEntry::from_json(const Poco::JSON::Object::Ptr &Obj) { bool JobEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -171,6 +172,7 @@ namespace OpenWifi::CertObjects {
field_from_json(Obj,"submitted", submitted); field_from_json(Obj,"submitted", submitted);
field_from_json(Obj,"started", started); field_from_json(Obj,"started", started);
field_from_json(Obj,"completed", completed); field_from_json(Obj,"completed", completed);
field_from_json(Obj,"requesterUsername", requesterUsername);
return true; return true;
} catch (...) { } catch (...) {
} }

View File

@@ -91,6 +91,7 @@ namespace OpenWifi::CertObjects {
uint64_t submitted=0; uint64_t submitted=0;
uint64_t started=0; uint64_t started=0;
uint64_t completed=0; uint64_t completed=0;
std::string requesterUsername;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -3,7 +3,8 @@
// //
#include "RESTAPI_FMSObjects.h" #include "RESTAPI_FMSObjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;
@@ -233,7 +234,7 @@ namespace OpenWifi::FMSObjects {
UnknownFirmwares_.clear(); UnknownFirmwares_.clear();
totalSecondsOld_.clear(); totalSecondsOld_.clear();
numberOfDevices = 0 ; numberOfDevices = 0 ;
snapshot = OpenWifi::Now(); snapshot = Utils::Now();
} }
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) { bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {

View File

@@ -11,12 +11,13 @@
#include "Daemon.h" #include "Daemon.h"
#ifdef TIP_GATEWAY_SERVICE #ifdef TIP_GATEWAY_SERVICE
#include "DeviceRegistry.h" #include "AP_WS_Server.h"
#include "CapabilitiesCache.h" #include "CapabilitiesCache.h"
#endif #endif
#include "RESTAPI_GWobjects.h" #include "RESTAPI_GWobjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;
@@ -49,6 +50,10 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"entity", entity); field_to_json(Obj,"entity", entity);
field_to_json(Obj,"modified", modified); field_to_json(Obj,"modified", modified);
field_to_json(Obj,"locale", locale); field_to_json(Obj,"locale", locale);
field_to_json(Obj,"restrictedDevice", restrictedDevice);
field_to_json(Obj,"pendingConfiguration", pendingConfiguration);
field_to_json(Obj,"pendingConfigurationCmd", pendingConfigurationCmd);
field_to_json(Obj,"restrictionDetails", restrictionDetails);
} }
void Device::to_json_with_status(Poco::JSON::Object &Obj) const { void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
@@ -57,7 +62,7 @@ namespace OpenWifi::GWObjects {
#ifdef TIP_GATEWAY_SERVICE #ifdef TIP_GATEWAY_SERVICE
ConnectionState ConState; ConnectionState ConState;
if (DeviceRegistry()->GetState(SerialNumber, ConState)) { if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
ConState.to_json(Obj); ConState.to_json(Obj);
} else { } else {
field_to_json(Obj,"ipAddress", ""); field_to_json(Obj,"ipAddress", "");
@@ -69,6 +74,7 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"verifiedCertificate", "NO_CERTIFICATE"); field_to_json(Obj,"verifiedCertificate", "NO_CERTIFICATE");
field_to_json(Obj,"associations_2G", (uint64_t) 0); field_to_json(Obj,"associations_2G", (uint64_t) 0);
field_to_json(Obj,"associations_5G", (uint64_t) 0); field_to_json(Obj,"associations_5G", (uint64_t) 0);
field_to_json(Obj,"associations_6G", (uint64_t) 0);
} }
#endif #endif
} }
@@ -88,6 +94,10 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"subscriber", subscriber); field_from_json(Obj,"subscriber", subscriber);
field_from_json(Obj,"entity", entity); field_from_json(Obj,"entity", entity);
field_from_json(Obj,"locale", locale); field_from_json(Obj,"locale", locale);
field_from_json(Obj,"restrictedDevice", restrictedDevice);
field_from_json(Obj,"pendingConfiguration", pendingConfiguration);
field_from_json(Obj,"pendingConfigurationCmd", pendingConfigurationCmd);
field_from_json(Obj,"restrictionDetails", restrictionDetails);
return true; return true;
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
} }
@@ -198,11 +208,17 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"lastContact", LastContact); field_to_json(Obj,"lastContact", LastContact);
field_to_json(Obj,"associations_2G", Associations_2G); field_to_json(Obj,"associations_2G", Associations_2G);
field_to_json(Obj,"associations_5G", Associations_5G); field_to_json(Obj,"associations_5G", Associations_5G);
field_to_json(Obj,"associations_6G", Associations_6G);
field_to_json(Obj,"webSocketClients", webSocketClients); field_to_json(Obj,"webSocketClients", webSocketClients);
field_to_json(Obj,"websocketPackets", websocketPackets); field_to_json(Obj,"websocketPackets", websocketPackets);
field_to_json(Obj,"kafkaClients", kafkaClients); field_to_json(Obj,"kafkaClients", kafkaClients);
field_to_json(Obj,"kafkaPackets", kafkaPackets); field_to_json(Obj,"kafkaPackets", kafkaPackets);
field_to_json(Obj,"locale", locale); field_to_json(Obj,"locale", locale);
field_to_json(Obj,"started", started);
field_to_json(Obj,"sessionId", sessionId);
field_to_json(Obj,"connectionCompletionTime", connectionCompletionTime);
field_to_json(Obj,"totalConnectionTime", Utils::Now() - started);
field_to_json(Obj,"certificateExpiryDate", certificateExpiryDate);
switch(VerifiedCertificate) { switch(VerifiedCertificate) {
case NO_CERTIFICATE: case NO_CERTIFICATE:
@@ -218,6 +234,23 @@ namespace OpenWifi::GWObjects {
} }
} }
void DeviceConnectionStatistics::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"averageConnectionTime", averageConnectionTime);
field_to_json(Obj,"connectedDevices", connectedDevices );
field_to_json(Obj,"connectingDevices", connectingDevices );
}
bool DeviceConnectionStatistics::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"averageConnectionTime", averageConnectionTime);
field_from_json(Obj,"connectedDevices", connectedDevices );
field_from_json(Obj,"connectingDevices", connectingDevices );
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void RttySessionDetails::to_json(Poco::JSON::Object &Obj) const { void RttySessionDetails::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber", SerialNumber); field_to_json(Obj,"serialNumber", SerialNumber);
field_to_json(Obj,"server", Server); field_to_json(Obj,"server", Server);
@@ -264,7 +297,7 @@ namespace OpenWifi::GWObjects {
lastContact.clear(); lastContact.clear();
associations.clear(); associations.clear();
numberOfDevices = 0 ; numberOfDevices = 0 ;
snapshot = OpenWifi::Now(); snapshot = Utils::Now();
} }
void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{ void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{
@@ -276,9 +309,12 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"serialNumber",serialNumber); field_to_json(Obj,"serialNumber",serialNumber);
field_to_json(Obj,"timeout",timeout); field_to_json(Obj,"timeout",timeout);
field_to_json(Obj,"type",type); field_to_json(Obj,"type",type);
field_to_json(Obj,"script",script);
field_to_json(Obj,"scriptId",scriptId); field_to_json(Obj,"scriptId",scriptId);
field_to_json(Obj,"script",script);
field_to_json(Obj,"when",when); field_to_json(Obj,"when",when);
field_to_json(Obj,"signature", signature);
field_to_json(Obj,"deferred", deferred);
field_to_json(Obj,"uri", uri);
} }
bool ScriptRequest::from_json(const Poco::JSON::Object::Ptr &Obj) { bool ScriptRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -289,11 +325,13 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"script",script); field_from_json(Obj,"script",script);
field_from_json(Obj,"scriptId",scriptId); field_from_json(Obj,"scriptId",scriptId);
field_from_json(Obj,"when",when); field_from_json(Obj,"when",when);
field_from_json(Obj,"signature", signature);
field_from_json(Obj,"deferred", deferred);
field_from_json(Obj,"uri", uri);
return true; return true;
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
} }
return false; return false;
} }
void RadiusProxyPoolList::to_json(Poco::JSON::Object &Obj) const { void RadiusProxyPoolList::to_json(Poco::JSON::Object &Obj) const {
@@ -314,6 +352,8 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"description",description); field_to_json(Obj,"description",description);
field_to_json(Obj,"authConfig",authConfig); field_to_json(Obj,"authConfig",authConfig);
field_to_json(Obj,"acctConfig",acctConfig); field_to_json(Obj,"acctConfig",acctConfig);
field_to_json(Obj,"coaConfig",coaConfig);
field_to_json(Obj,"useByDefault",useByDefault);
} }
bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) { bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -322,6 +362,8 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"description",description); field_from_json(Obj,"description",description);
field_from_json(Obj,"authConfig",authConfig); field_from_json(Obj,"authConfig",authConfig);
field_from_json(Obj,"acctConfig",acctConfig); field_from_json(Obj,"acctConfig",acctConfig);
field_from_json(Obj,"coaConfig",coaConfig);
field_from_json(Obj,"useByDefault",useByDefault);
return true; return true;
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
} }
@@ -329,7 +371,7 @@ namespace OpenWifi::GWObjects {
} }
void RadiusProxyServerConfig::to_json(Poco::JSON::Object &Obj) const { void RadiusProxyServerConfig::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"policy",strategy); field_to_json(Obj,"strategy",strategy);
field_to_json(Obj,"monitor",monitor); field_to_json(Obj,"monitor",monitor);
field_to_json(Obj,"monitorMethod",monitorMethod); field_to_json(Obj,"monitorMethod",monitorMethod);
field_to_json(Obj,"methodParameters",methodParameters); field_to_json(Obj,"methodParameters",methodParameters);
@@ -338,7 +380,7 @@ namespace OpenWifi::GWObjects {
bool RadiusProxyServerConfig::from_json(const Poco::JSON::Object::Ptr &Obj) { bool RadiusProxyServerConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
try { try {
field_from_json(Obj,"policy",strategy); field_from_json(Obj,"strategy",strategy);
field_from_json(Obj,"monitor",monitor); field_from_json(Obj,"monitor",monitor);
field_from_json(Obj,"monitorMethod",monitorMethod); field_from_json(Obj,"monitorMethod",monitorMethod);
field_from_json(Obj,"methodParameters",methodParameters); field_from_json(Obj,"methodParameters",methodParameters);
@@ -354,6 +396,17 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"ip",ip); field_to_json(Obj,"ip",ip);
field_to_json(Obj,"port",port); field_to_json(Obj,"port",port);
field_to_json(Obj,"weight",weight); field_to_json(Obj,"weight",weight);
field_to_json(Obj,"secret",secret);
field_to_json(Obj,"certificate",certificate);
field_to_json(Obj,"radsec",radsec);
field_to_json(Obj,"allowSelfSigned",allowSelfSigned);
field_to_json(Obj,"radsecPort",radsecPort);
field_to_json(Obj,"radsecSecret",radsecSecret);
field_to_json(Obj,"radsecCacerts",radsecCacerts);
field_to_json(Obj,"radsecCert",radsecCert);
field_to_json(Obj,"radsecKey",radsecKey);
field_to_json(Obj,"radsecRealms",radsecRealms);
field_to_json(Obj,"ignore",ignore);
} }
bool RadiusProxyServerEntry::from_json(const Poco::JSON::Object::Ptr &Obj) { bool RadiusProxyServerEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -362,10 +415,133 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"ip",ip); field_from_json(Obj,"ip",ip);
field_from_json(Obj,"port",port); field_from_json(Obj,"port",port);
field_from_json(Obj,"weight",weight); field_from_json(Obj,"weight",weight);
field_from_json(Obj,"secret",secret);
field_from_json(Obj,"certificate",certificate);
field_from_json(Obj,"radsec",radsec);
field_from_json(Obj,"allowSelfSigned",allowSelfSigned);
field_from_json(Obj,"radsecSecret",radsecSecret);
field_from_json(Obj,"radsecPort",radsecPort);
field_from_json(Obj,"radsecCacerts",radsecCacerts);
field_from_json(Obj,"radsecCert",radsecCert);
field_from_json(Obj,"radsecKey",radsecKey);
field_from_json(Obj,"radsecRealms",radsecRealms);
field_from_json(Obj,"ignore",ignore);
return true; return true;
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
} }
return false; return false;
} }
void ScriptEntry::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"id", id);
field_to_json(Obj,"name", name);
field_to_json(Obj,"description", description);
field_to_json(Obj,"uri", uri);
field_to_json(Obj,"content", content);
field_to_json(Obj,"version", version);
field_to_json(Obj,"type", type);
field_to_json(Obj,"created", created);
field_to_json(Obj,"modified", modified);
field_to_json(Obj,"author", author);
field_to_json(Obj,"restricted", restricted);
field_to_json(Obj,"deferred", deferred);
field_to_json(Obj,"timeout", timeout);
field_to_json(Obj,"defaultUploadURI", defaultUploadURI);
}
bool ScriptEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"id", id);
field_from_json(Obj,"name", name);
field_from_json(Obj,"description", description);
field_from_json(Obj,"uri", uri);
field_from_json(Obj,"content", content);
field_from_json(Obj,"version", version);
field_from_json(Obj,"type", type);
field_from_json(Obj,"created", created);
field_from_json(Obj,"modified", modified);
field_from_json(Obj,"author", author);
field_from_json(Obj,"restricted", restricted);
field_from_json(Obj,"deferred", deferred);
field_from_json(Obj,"timeout", timeout);
field_from_json(Obj,"defaultUploadURI", defaultUploadURI);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void ScriptEntryList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"scripts",scripts);
}
bool ScriptEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"scripts",scripts);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"vendor", vendor);
field_to_json(Obj,"algo", algo);
}
bool DeviceRestrictionsKeyInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"vendor", vendor);
field_from_json(Obj,"algo", algo);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void DeviceRestrictions::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"dfs", dfs);
field_to_json(Obj,"ssh", ssh);
field_to_json(Obj,"rtty", rtty);
field_to_json(Obj,"tty", tty);
field_to_json(Obj,"developer", developer);
field_to_json(Obj,"upgrade", upgrade);
field_to_json(Obj,"commands", commands);
field_to_json(Obj,"country", country);
field_to_json(Obj,"key_info", key_info);
}
bool DeviceRestrictions::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"dfs", dfs);
field_from_json(Obj,"ssh", ssh);
field_from_json(Obj,"rtty", rtty);
field_from_json(Obj,"tty", tty);
field_from_json(Obj,"developer", developer);
field_from_json(Obj,"upgrade", upgrade);
field_from_json(Obj,"commands", commands);
field_from_json(Obj,"country", country);
field_from_json(Obj,"key_info", key_info);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
bool DeviceRestrictionsKeyInfo::operator!=(const OpenWifi::GWObjects::DeviceRestrictionsKeyInfo &T) const {
return (T.algo!=algo) || (T.vendor!=vendor);
}
bool DeviceRestrictions::operator!=(const OpenWifi::GWObjects::DeviceRestrictions &T) const {
return ( (T.dfs!=dfs) ||
(T.rtty!=rtty) ||
(T.upgrade!=upgrade) ||
(T.commands != commands) ||
(T.developer != developer) ||
(T.ssh !=ssh) ||
(T.key_info != key_info) ||
(T.country != country) );
}
} }

View File

@@ -28,19 +28,52 @@ namespace OpenWifi::GWObjects {
uint64_t TX = 0, RX = 0; uint64_t TX = 0, RX = 0;
uint64_t Associations_2G=0; uint64_t Associations_2G=0;
uint64_t Associations_5G=0; uint64_t Associations_5G=0;
uint64_t Associations_6G=0;
bool Connected = false; bool Connected = false;
uint64_t LastContact=0; uint64_t LastContact=0;
std::string Firmware; std::string Firmware;
CertificateValidation VerifiedCertificate = NO_CERTIFICATE; CertificateValidation VerifiedCertificate = NO_CERTIFICATE;
std::string Compatible; std::string Compatible;
uint64_t kafkaClients=0; uint64_t kafkaClients=0;
uint64_t webSocketClients=0; uint64_t webSocketClients=0;
uint64_t kafkaPackets=0; uint64_t kafkaPackets=0;
uint64_t websocketPackets=0; uint64_t websocketPackets=0;
std::string locale; std::string locale;
uint64_t started=0;
uint64_t sessionId=0;
double connectionCompletionTime=0.0;
std::uint64_t certificateExpiryDate=0;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
}; };
struct DeviceRestrictionsKeyInfo {
std::string vendor;
std::string algo;
bool operator !=(const DeviceRestrictionsKeyInfo &b) const;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct DeviceRestrictions {
bool dfs = false;
bool ssh = false;
bool rtty = false;
bool tty = false;
bool developer = false;
bool upgrade = false;
bool commands = false;
std::vector<std::string> country;
DeviceRestrictionsKeyInfo key_info;
bool operator !=(const DeviceRestrictions &D) const;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct Device { struct Device {
std::string SerialNumber; std::string SerialNumber;
std::string DeviceType; std::string DeviceType;
@@ -64,6 +97,10 @@ namespace OpenWifi::GWObjects {
std::string entity; std::string entity;
uint64_t modified=0; uint64_t modified=0;
std::string locale; std::string locale;
bool restrictedDevice=false;
std::string pendingConfiguration;
std::string pendingConfigurationCmd;
DeviceRestrictions restrictionDetails;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
void to_json_with_status(Poco::JSON::Object &Obj) const; void to_json_with_status(Poco::JSON::Object &Obj) const;
@@ -71,6 +108,15 @@ namespace OpenWifi::GWObjects {
void Print() const; void Print() const;
}; };
struct DeviceConnectionStatistics {
std::uint64_t connectedDevices = 0;
std::uint64_t averageConnectionTime = 0;
std::uint64_t connectingDevices = 0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct Statistics { struct Statistics {
std::string SerialNumber; std::string SerialNumber;
uint64_t UUID = 0 ; uint64_t UUID = 0 ;
@@ -200,13 +246,44 @@ namespace OpenWifi::GWObjects {
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
}; };
struct ScriptEntry {
std::string id;
std::string name;
std::string description;
std::string uri;
std::string content;
std::string version;
std::string type;
std::uint64_t created;
std::uint64_t modified;
std::string author;
Types::StringVec restricted;
bool deferred=false;
std::uint64_t timeout=30;
std::string defaultUploadURI;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ScriptEntryList {
std::vector<ScriptEntry> scripts;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ScriptRequest { struct ScriptRequest {
uint64_t timeout=30;
std::string serialNumber; std::string serialNumber;
uint64_t timeout=30;
std::string type; std::string type;
std::string script; std::string script;
std::string scriptId; std::string scriptId;
uint64_t when=0; std::uint64_t when;
std::string signature;
bool deferred;
std::string uri;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
}; };
@@ -216,6 +293,17 @@ namespace OpenWifi::GWObjects {
std::string ip; std::string ip;
uint16_t port=0; uint16_t port=0;
uint64_t weight=0; uint64_t weight=0;
std::string secret;
std::string certificate;
bool radsec=false;
bool allowSelfSigned=false;
uint16_t radsecPort=2083;
std::string radsecSecret;
std::string radsecKey;
std::string radsecCert;
std::vector<std::string> radsecCacerts;
std::vector<std::string> radsecRealms;
bool ignore=false;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -237,6 +325,8 @@ namespace OpenWifi::GWObjects {
std::string description; std::string description;
RadiusProxyServerConfig authConfig; RadiusProxyServerConfig authConfig;
RadiusProxyServerConfig acctConfig; RadiusProxyServerConfig acctConfig;
RadiusProxyServerConfig coaConfig;
bool useByDefault=false;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -248,4 +338,5 @@ namespace OpenWifi::GWObjects {
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
}; };
} }

View File

@@ -2,7 +2,7 @@
// Created by stephane bourque on 2021-08-31. // Created by stephane bourque on 2021-08-31.
// //
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;

View File

@@ -8,7 +8,9 @@
#include "RESTAPI_ProvObjects.h" #include "RESTAPI_ProvObjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;
@@ -600,6 +602,7 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj, "devClass",devClass); field_to_json( Obj, "devClass",devClass);
field_to_json( Obj, "locale",locale); field_to_json( Obj, "locale",locale);
field_to_json( Obj, "realMacAddress",realMacAddress); field_to_json( Obj, "realMacAddress",realMacAddress);
field_to_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
} }
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) { bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -621,6 +624,7 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"devClass",devClass); field_from_json( Obj,"devClass",devClass);
field_from_json( Obj,"locale",locale); field_from_json( Obj,"locale",locale);
field_from_json( Obj,"realMacAddress",realMacAddress); field_from_json( Obj,"realMacAddress",realMacAddress);
field_from_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
return true; return true;
} catch(...) { } catch(...) {
@@ -1091,7 +1095,7 @@ namespace OpenWifi::ProvObjects {
} }
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) { bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = OpenWifi::Now(); uint64_t Now = Utils::Now();
if(O->has("name")) if(O->has("name"))
I.name = O->get("name").toString(); I.name = O->get("name").toString();
@@ -1112,7 +1116,7 @@ namespace OpenWifi::ProvObjects {
} }
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) { bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = OpenWifi::Now(); uint64_t Now = Utils::Now();
if(O->has("name")) if(O->has("name"))
I.name = O->get("name").toString(); I.name = O->get("name").toString();
@@ -1130,14 +1134,14 @@ namespace OpenWifi::ProvObjects {
} }
I.notes = N; I.notes = N;
I.modified = I.created = Now; I.modified = I.created = Now;
I.id = MicroService::CreateUUID(); I.id = MicroServiceCreateUUID();
return true; return true;
} }
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) { bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
I.modified = I.created = OpenWifi::Now(); I.modified = I.created = Utils::Now();
I.id = MicroService::CreateUUID(); I.id = MicroServiceCreateUUID();
return true; return true;
} }
@@ -1159,5 +1163,82 @@ namespace OpenWifi::ProvObjects {
return false; return false;
} }
void RRMAlgorithmDetails::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"name",name);
field_to_json(Obj,"parameters",parameters);
}
bool RRMAlgorithmDetails::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"name",name);
field_from_json(Obj,"parameters",parameters);
return true;
} catch(...) {
}
return false;
}
void RRMDetails::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"vendor",vendor);
field_to_json(Obj,"schedule",schedule);
field_to_json(Obj,"algorithms",algorithms);
}
bool RRMDetails::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"vendor",vendor);
field_from_json(Obj,"schedule",schedule);
field_from_json(Obj,"algorithms",algorithms);
return true;
} catch(...) {
}
return false;
}
void ConfigurationOverride::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"source",source);
field_to_json(Obj,"reason",reason);
field_to_json(Obj,"parameterName",parameterName);
field_to_json(Obj,"parameterType",parameterType);
field_to_json(Obj,"parameterValue",parameterValue);
field_to_json(Obj,"modified",modified);
}
bool ConfigurationOverride::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"source",source);
field_from_json(Obj,"reason",reason);
field_from_json(Obj,"parameterName",parameterName);
field_from_json(Obj,"parameterType",parameterType);
field_from_json(Obj,"parameterValue",parameterValue);
field_from_json(Obj,"modified",modified);
return true;
} catch(...) {
}
return false;
}
void ConfigurationOverrideList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber",serialNumber);
field_to_json(Obj,"managementPolicy",managementPolicy);
field_to_json(Obj,"overrides",overrides);
}
bool ConfigurationOverrideList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"serialNumber",serialNumber);
field_from_json(Obj,"managementPolicy",managementPolicy);
field_from_json(Obj,"overrides",overrides);
return true;
} catch(...) {
}
return false;
}
} }

View File

@@ -8,8 +8,7 @@
#pragma once #pragma once
#include <string> #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "RESTAPI_SecurityObjects.h"
namespace OpenWifi::ProvObjects { namespace OpenWifi::ProvObjects {
@@ -62,6 +61,21 @@ namespace OpenWifi::ProvObjects {
}; };
typedef std::vector<ManagementPolicy> ManagementPolicyVec; typedef std::vector<ManagementPolicy> ManagementPolicyVec;
struct RRMAlgorithmDetails {
std::string name;
std::string parameters;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct RRMDetails {
std::string vendor;
std::string schedule;
std::vector<RRMAlgorithmDetails> algorithms;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct DeviceRules { struct DeviceRules {
std::string rcOnly{"inherit"}; std::string rcOnly{"inherit"};
std::string rrm{"inherit"}; std::string rrm{"inherit"};
@@ -414,6 +428,7 @@ namespace OpenWifi::ProvObjects {
std::string devClass; std::string devClass;
std::string locale; std::string locale;
std::string realMacAddress; std::string realMacAddress;
bool doNotAllowOverrides=false;
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -679,6 +694,27 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
}; };
struct ConfigurationOverride {
std::string source;
std::string reason;
std::string parameterName;
std::string parameterType;
std::string parameterValue;
std::uint64_t modified;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ConfigurationOverrideList {
std::string serialNumber;
Types::UUID_t managementPolicy;
std::vector<ConfigurationOverride> overrides;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I); bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I); bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I); bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I);

View File

@@ -9,7 +9,7 @@
#include "Poco/JSON/Parser.h" #include "Poco/JSON/Parser.h"
#include "Poco/JSON/Stringifier.h" #include "Poco/JSON/Stringifier.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h" #include "RESTAPI_SecurityObjects.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
@@ -433,7 +433,7 @@ namespace OpenWifi::SecurityObjects {
SecurityObjects::NoteInfoVec NIV; SecurityObjects::NoteInfoVec NIV;
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString()); NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
for(auto const &i:NIV) { for(auto const &i:NIV) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note}; SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
Notes.push_back(ii); Notes.push_back(ii);
} }
} }
@@ -446,7 +446,7 @@ namespace OpenWifi::SecurityObjects {
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) { bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
for(auto const &i:NewNotes) { for(auto const &i:NewNotes) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note}; SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
ExistingNotes.push_back(ii); ExistingNotes.push_back(ii);
} }
return true; return true;
@@ -619,5 +619,80 @@ namespace OpenWifi::SecurityObjects {
field_to_json(Obj,"login",login); field_to_json(Obj,"login",login);
field_to_json(Obj,"logout",logout); field_to_json(Obj,"logout",logout);
} }
void ApiKeyAccessRight::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "service", service);
field_to_json(Obj, "access", access);
}
bool ApiKeyAccessRight::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "service", service);
field_from_json(Obj, "access", access);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyAccessRightList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "acls", acls);
}
bool ApiKeyAccessRightList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "acls", acls);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyEntry::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "id", id);
field_to_json(Obj, "userUuid", userUuid);
field_to_json(Obj, "name", name);
field_to_json(Obj, "apiKey", apiKey);
field_to_json(Obj, "salt", salt);
field_to_json(Obj, "description", description);
field_to_json(Obj, "expiresOn", expiresOn);
field_to_json(Obj, "rights", rights);
field_to_json(Obj, "lastUse", lastUse);
}
bool ApiKeyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "id", id);
field_from_json(Obj, "userUuid", userUuid);
field_from_json(Obj, "name", name);
field_from_json(Obj, "apiKey", apiKey);
field_from_json(Obj, "salt", salt);
field_from_json(Obj, "description", description);
field_from_json(Obj, "expiresOn", expiresOn);
field_from_json(Obj, "rights", rights);
field_from_json(Obj, "lastUse", lastUse);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyEntryList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "apiKeys", apiKeys);
}
bool ApiKeyEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "apiKeys", apiKeys);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
} }

View File

@@ -14,6 +14,7 @@
#include "Poco/JSON/Object.h" #include "Poco/JSON/Object.h"
#include "Poco/Data/LOB.h" #include "Poco/Data/LOB.h"
#include "Poco/Data/LOBStream.h" #include "Poco/Data/LOBStream.h"
#include "framework/utils.h"
namespace OpenWifi { namespace OpenWifi {
uint64_t Now(); uint64_t Now();
@@ -62,7 +63,7 @@ namespace OpenWifi {
std::string UserTypeToString(USER_ROLE U); std::string UserTypeToString(USER_ROLE U);
struct NoteInfo { struct NoteInfo {
uint64_t created=0; // = OpenWifi::Now(); uint64_t created=0; // = Utils::Now();
std::string createdBy; std::string createdBy;
std::string note; std::string note;
@@ -101,7 +102,7 @@ namespace OpenWifi {
std::string uuid; std::string uuid;
std::string question; std::string question;
std::string method; std::string method;
uint64_t created = OpenWifi::Now(); uint64_t created = Utils::Now();
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -264,7 +265,7 @@ namespace OpenWifi {
std::string locale; std::string locale;
std::string message; std::string message;
uint64_t sent=0; uint64_t sent=0;
uint64_t created=OpenWifi::Now(); uint64_t created=Utils::Now();
uint64_t expires=0; uint64_t expires=0;
uint64_t completed=0; uint64_t completed=0;
uint64_t canceled=0; uint64_t canceled=0;
@@ -324,5 +325,44 @@ namespace OpenWifi {
void to_json(Poco::JSON::Object &Obj) const; void to_json(Poco::JSON::Object &Obj) const;
}; };
struct ApiKeyAccessRight {
std::string service;
std::string access;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyAccessRightList {
std::vector<ApiKeyAccessRight> acls;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyEntry {
Types::UUID_t id;
Types::UUID_t userUuid;
std::string name;
std::string description;
std::string apiKey;
std::string salt;
std::uint64_t created;
std::uint64_t expiresOn=0;
ApiKeyAccessRightList rights;
std::uint64_t lastUse=0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyEntryList {
std::vector<ApiKeyEntry> apiKeys;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
} }
} }

View File

@@ -3,12 +3,11 @@
// //
#include "RESTAPI_SubObjects.h" #include "RESTAPI_SubObjects.h"
#include "framework/MicroService.h" #include "framework/RESTAPI_utils.h"
using OpenWifi::RESTAPI_utils::field_to_json; using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json; using OpenWifi::RESTAPI_utils::field_from_json;
namespace OpenWifi::SubObjects { namespace OpenWifi::SubObjects {
void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const { void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const {

View File

@@ -2,23 +2,18 @@
// Created by stephane bourque on 2021-10-09. // Created by stephane bourque on 2021-10-09.
// //
#include <aws/sns/SNSClient.h>
#include <aws/sns/model/PublishRequest.h>
#include <aws/sns/model/PublishResult.h>
#include <aws/sns/model/GetSMSAttributesRequest.h>
#include "MFAServer.h" #include "MFAServer.h"
#include "SMS_provider_aws.h" #include "SMS_provider_aws.h"
#include "SMS_provider_twilio.h" #include "SMS_provider_twilio.h"
#include "SMSSender.h" #include "SMSSender.h"
#include "framework/MicroService.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
int SMSSender::Start() { int SMSSender::Start() {
Enabled_ = MicroService::instance().ConfigGetBool("smssender.enabled",false); Enabled_ = MicroServiceConfigGetBool("smssender.enabled",false);
if(Enabled_) { if(Enabled_) {
Provider_ = MicroService::instance().ConfigGetString("smssender.provider","aws"); Provider_ = MicroServiceConfigGetString("smssender.provider","aws");
if(Provider_=="aws") { if(Provider_=="aws") {
ProviderImpl_ = std::make_unique<SMS_provider_aws>(Logger()); ProviderImpl_ = std::make_unique<SMS_provider_aws>(Logger());
} else if(Provider_=="twilio") { } else if(Provider_=="twilio") {
@@ -85,7 +80,7 @@ namespace OpenWifi {
bool SMSSender::Send(const std::string &PhoneNumber, const std::string &Message) { bool SMSSender::Send(const std::string &PhoneNumber, const std::string &Message) {
if(!Enabled_) { if(!Enabled_) {
Logger().information("SMS has not been enabled. Messages cannot be sent."); poco_information(Logger(),"SMS has not been enabled. Messages cannot be sent.");
return false; return false;
} }
return ProviderImpl_->Send(PhoneNumber,Message); return ProviderImpl_->Send(PhoneNumber,Message);

View File

@@ -2,14 +2,13 @@
// Created by stephane bourque on 2021-10-09. // Created by stephane bourque on 2021-10-09.
// //
#ifndef OWSEC_SMSSENDER_H #pragma once
#define OWSEC_SMSSENDER_H
#include <aws/core/Aws.h> #include <aws/core/Aws.h>
#include <aws/s3/S3Client.h> #include <aws/s3/S3Client.h>
#include <aws/core/auth/AWSCredentials.h> #include <aws/core/auth/AWSCredentials.h>
#include "framework/MicroService.h" #include "framework/SubSystemServer.h"
#include "SMS_provider.h" #include "SMS_provider.h"
namespace OpenWifi { namespace OpenWifi {
@@ -54,6 +53,3 @@ namespace OpenWifi {
inline SMSSender * SMSSender() { return SMSSender::instance(); } inline SMSSender * SMSSender() { return SMSSender::instance(); }
} }
#endif //OWSEC_SMSSENDER_H

View File

@@ -2,22 +2,23 @@
// Created by stephane bourque on 2021-10-15. // Created by stephane bourque on 2021-10-15.
// //
#include "SMS_provider_aws.h"
#include <aws/sns/SNSClient.h> #include <aws/sns/SNSClient.h>
#include <aws/sns/model/PublishRequest.h> #include <aws/sns/model/PublishRequest.h>
#include <aws/sns/model/PublishResult.h> #include <aws/sns/model/PublishResult.h>
#include "framework/MicroService.h" #include "framework/MicroServiceFuncs.h"
#include "SMS_provider_aws.h" #include "fmt/format.h"
namespace OpenWifi { namespace OpenWifi {
bool SMS_provider_aws::Initialize() { bool SMS_provider_aws::Initialize() {
SecretKey_ = MicroService::instance().ConfigGetString("smssender.aws.secretkey",""); SecretKey_ = MicroServiceConfigGetString("smssender.aws.secretkey","");
AccessKey_ = MicroService::instance().ConfigGetString("smssender.aws.accesskey",""); AccessKey_ = MicroServiceConfigGetString("smssender.aws.accesskey","");
Region_ = MicroService::instance().ConfigGetString("smssender.aws.region",""); Region_ = MicroServiceConfigGetString("smssender.aws.region","");
if(SecretKey_.empty() || AccessKey_.empty() || Region_.empty()) { if(SecretKey_.empty() || AccessKey_.empty() || Region_.empty()) {
Logger().debug("SMSSender is disabled. Please provide key, secret, and region."); poco_debug(Logger(),"SMSSender is disabled. Please provide key, secret, and region.");
return false; return false;
} }
Running_=true; Running_=true;
@@ -51,16 +52,16 @@ namespace OpenWifi {
auto psms_out = sns.Publish(psms_req); auto psms_out = sns.Publish(psms_req);
if (psms_out.IsSuccess()) { if (psms_out.IsSuccess()) {
Logger().debug(fmt::format("SMS sent to {}",PhoneNumber)); poco_debug(Logger(),fmt::format("SMS sent to {}",PhoneNumber));
return true; return true;
} }
std::string ErrMsg{psms_out.GetError().GetMessage()}; std::string ErrMsg{psms_out.GetError().GetMessage()};
Logger().debug(fmt::format("SMS NOT sent to {}: {}",PhoneNumber, ErrMsg)); poco_debug(Logger(),fmt::format("SMS NOT sent to {}: {}",PhoneNumber, ErrMsg));
return false; return false;
} catch (...) { } catch (...) {
} }
Logger().debug(fmt::format("SMS NOT sent to {}: failure in SMS service",PhoneNumber)); poco_debug(Logger(),fmt::format("SMS NOT sent to {}: failure in SMS service",PhoneNumber));
return false; return false;
} }

View File

@@ -2,8 +2,7 @@
// Created by stephane bourque on 2021-10-15. // Created by stephane bourque on 2021-10-15.
// //
#ifndef OWSEC_SMS_PROVIDER_AWS_H #pragma once
#define OWSEC_SMS_PROVIDER_AWS_H
#include <aws/core/Aws.h> #include <aws/core/Aws.h>
#include <aws/s3/S3Client.h> #include <aws/s3/S3Client.h>
@@ -32,5 +31,3 @@ namespace OpenWifi {
Aws::Auth::AWSCredentials AwsCreds_; Aws::Auth::AWSCredentials AwsCreds_;
}; };
} }
#endif //OWSEC_SMS_PROVIDER_AWS_H

View File

@@ -9,16 +9,18 @@
#include "Poco/Net/HTMLForm.h" #include "Poco/Net/HTMLForm.h"
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTTPResponse.h"
#include "framework/MicroService.h"
#include "framework/MicroServiceFuncs.h"
#include "fmt/format.h"
namespace OpenWifi { namespace OpenWifi {
bool SMS_provider_twilio::Initialize() { bool SMS_provider_twilio::Initialize() {
Sid_ = MicroService::instance().ConfigGetString("smssender.twilio.sid",""); Sid_ = MicroServiceConfigGetString("smssender.twilio.sid","");
Token_ = MicroService::instance().ConfigGetString("smssender.twilio.token",""); Token_ = MicroServiceConfigGetString("smssender.twilio.token","");
PhoneNumber_ = MicroService::instance().ConfigGetString("smssender.twilio.phonenumber",""); PhoneNumber_ = MicroServiceConfigGetString("smssender.twilio.phonenumber","");
if(Sid_.empty() || Token_.empty() || PhoneNumber_.empty()) { if(Sid_.empty() || Token_.empty() || PhoneNumber_.empty()) {
Logger().debug("SMSSender is disabled. Please provide SID, TOKEN, and PHONE NUMBER."); poco_debug(Logger(),"SMSSender is disabled. Please provide SID, TOKEN, and PHONE NUMBER.");
return false; return false;
} }
Running_=true; Running_=true;
@@ -64,12 +66,12 @@ namespace OpenWifi {
std::istream& rs = session.receiveResponse(res); std::istream& rs = session.receiveResponse(res);
if(res.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) { if(res.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
Logger().information(fmt::format("Message sent to {}", PhoneNumber)); poco_information(Logger(),fmt::format("Message sent to {}", PhoneNumber));
return true; return true;
} else { } else {
std::ostringstream os; std::ostringstream os;
Poco::StreamCopier::copyStream(rs,os); Poco::StreamCopier::copyStream(rs,os);
Logger().information(fmt::format("Message was not to {}: Error:{}", PhoneNumber, os.str())); poco_information(Logger(),fmt::format("Message was not to {}: Error:{}", PhoneNumber, os.str()));
return false; return false;
} }
} }

View File

@@ -1,8 +1,6 @@
// //
// Created by stephane bourque on 2021-06-17. // Created by stephane bourque on 2021-06-17.
// //
#include <iostream>
#include <fstream>
#include "Poco/Net/MailMessage.h" #include "Poco/Net/MailMessage.h"
#include "Poco/Net/MailRecipient.h" #include "Poco/Net/MailRecipient.h"
@@ -15,26 +13,29 @@
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "SMTPMailerService.h" #include "SMTPMailerService.h"
#include "framework/MicroService.h"
#include "AuthService.h" #include "AuthService.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
#include "fmt/format.h"
namespace OpenWifi { namespace OpenWifi {
void SMTPMailerService::LoadMyConfig() { void SMTPMailerService::LoadMyConfig() {
Enabled_ = MicroService::instance().ConfigGetBool("mailer.enabled",false); Enabled_ = MicroServiceConfigGetBool("mailer.enabled",false);
if(Enabled_) { if(Enabled_) {
MailHost_ = MicroService::instance().ConfigGetString("mailer.hostname"); MailHost_ = MicroServiceConfigGetString("mailer.hostname","");
SenderLoginUserName_ = MicroService::instance().ConfigGetString("mailer.username"); SenderLoginUserName_ = MicroServiceConfigGetString("mailer.username","");
SenderLoginPassword_ = MicroService::instance().ConfigGetString("mailer.password"); SenderLoginPassword_ = MicroServiceConfigGetString("mailer.password","");
Sender_ = MicroService::instance().ConfigGetString("mailer.sender"); Sender_ = MicroServiceConfigGetString("mailer.sender","");
LoginMethod_ = MicroService::instance().ConfigGetString("mailer.loginmethod"); LoginMethod_ = MicroServiceConfigGetString("mailer.loginmethod","");
MailHostPort_ = MicroService::instance().ConfigGetInt("mailer.port"); MailHostPort_ = MicroServiceConfigGetInt("mailer.port", 587);
TemplateDir_ = MicroService::instance().ConfigPath("mailer.templates", MicroService::instance().DataDir()); TemplateDir_ = MicroServiceConfigPath("mailer.templates", MicroServiceDataDirectory());
MailRetry_ = MicroService::instance().ConfigGetInt("mailer.retry",2*60); MailRetry_ = MicroServiceConfigGetInt("mailer.retry",2*60);
MailAbandon_ = MicroService::instance().ConfigGetInt("mailer.abandon",2*60*60); MailAbandon_ = MicroServiceConfigGetInt("mailer.abandon",2*60*60);
UseHTML_ = MicroService::instance().ConfigGetBool("mailer.html",false); UseHTML_ = MicroServiceConfigGetBool("mailer.html",false);
Enabled_ = (!MailHost_.empty() && !SenderLoginPassword_.empty() && !SenderLoginUserName_.empty()); Enabled_ = (!MailHost_.empty() && !SenderLoginPassword_.empty() && !SenderLoginUserName_.empty());
EmailLogo_ = TemplateDir_ + "/" + MicroService::instance().ConfigGetString("mailer.logo","logo.jpg"); EmailLogo_ = TemplateDir_ + "/" + MicroServiceConfigGetString("mailer.logo","logo.png");
} }
} }
@@ -51,18 +52,19 @@ namespace OpenWifi {
} }
void SMTPMailerService::reinitialize([[maybe_unused]] Poco::Util::Application &self) { void SMTPMailerService::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
MicroService::instance().LoadConfigurationFile(); MicroServiceLoadConfigurationFile();
Logger().information("Reinitializing."); poco_information(Logger(),"Reinitializing.");
LoadMyConfig(); LoadMyConfig();
} }
bool SMTPMailerService::SendMessage([[maybe_unused]] const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs) { bool SMTPMailerService::SendMessage([[maybe_unused]] const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs, bool Subscriber) {
std::lock_guard G(Mutex_); std::lock_guard G(Mutex_);
PendingMessages_.push_back(MessageEvent{.Posted= OpenWifi::Now(), PendingMessages_.push_back(MessageEvent{.Posted= OpenWifi::Now(),
.LastTry=0, .LastTry=0,
.Sent=0, .Sent=0,
.TemplateName=Name, .TemplateName=Name,
.Attrs=Attrs}); .Attrs=Attrs,
.Subscriber=Subscriber});
return true; return true;
} }
@@ -88,21 +90,21 @@ namespace OpenWifi {
if((i->LastTry==0 || (now-i->LastTry)>MailRetry_)) { if((i->LastTry==0 || (now-i->LastTry)>MailRetry_)) {
switch(SendIt(*i)) { switch(SendIt(*i)) {
case MessageSendStatus::msg_sent: { case MessageSendStatus::msg_sent: {
Logger().information(fmt::format("Attempting to deliver for mail '{}'.", Recipient)); poco_information(Logger(),fmt::format("Attempting to deliver for mail '{}'.", Recipient));
i = Messages_.erase(i); i = Messages_.erase(i);
} break; } break;
case MessageSendStatus::msg_not_sent_but_resend: { case MessageSendStatus::msg_not_sent_but_resend: {
Logger().information(fmt::format("Mail for '{}' was not. We will retry later.", Recipient)); poco_information(Logger(),fmt::format("Mail for '{}' was not. We will retry later.", Recipient));
i->LastTry = now; i->LastTry = now;
++i; ++i;
} break; } break;
case MessageSendStatus::msg_not_sent_but_do_not_resend: { case MessageSendStatus::msg_not_sent_but_do_not_resend: {
Logger().information(fmt::format("Mail for '{}' will not be sent. Check email address", Recipient)); poco_information(Logger(),fmt::format("Mail for '{}' will not be sent. Check email address", Recipient));
i = Messages_.erase(i); i = Messages_.erase(i);
} break; } break;
} }
} else if ((now-i->Posted)>MailAbandon_) { } else if ((now-i->Posted)>MailAbandon_) {
Logger().information(fmt::format("Mail for '{}' has timed out and will not be sent.", Recipient)); poco_information(Logger(),fmt::format("Mail for '{}' has timed out and will not be sent.", Recipient));
i = Messages_.erase(i); i = Messages_.erase(i);
} else { } else {
++i; ++i;
@@ -138,7 +140,7 @@ namespace OpenWifi {
Message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, Recipient)); Message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, Recipient));
Message->setSubject(Msg.Attrs.find(SUBJECT)->second); Message->setSubject(Msg.Attrs.find(SUBJECT)->second);
Logger().information(fmt::format("Sending message to:{} from {}",Recipient,TheSender)); poco_information(Logger(),fmt::format("Sending message to:{} from {}",Recipient,TheSender));
if(Msg.Attrs.find(TEXT) != Msg.Attrs.end()) { if(Msg.Attrs.find(TEXT) != Msg.Attrs.end()) {
std::string Content = Msg.Attrs.find(TEXT)->second; std::string Content = Msg.Attrs.find(TEXT)->second;
@@ -157,13 +159,13 @@ namespace OpenWifi {
auto Logo = Msg.Attrs.find(LOGO); auto Logo = Msg.Attrs.find(LOGO);
if(Logo!=Msg.Attrs.end()) { if(Logo!=Msg.Attrs.end()) {
try { try {
Poco::File LogoFile(EmailLogo_); Poco::File LogoFile( Msg.Subscriber ? AuthService::GetSubLogoAssetFileName() : AuthService::GetLogoAssetFileName ());
std::ifstream IF(LogoFile.path()); std::ifstream IF(LogoFile.path());
std::ostringstream OS; std::ostringstream OS;
Poco::StreamCopier::copyStream(IF, OS); Poco::StreamCopier::copyStream(IF, OS);
Message->addAttachment("logo", new Poco::Net::StringPartSource(OS.str(), "image/png")); Message->addAttachment("logo", new Poco::Net::StringPartSource(OS.str(), "image/png"));
} catch (...) { } catch (...) {
Logger().warning(fmt::format("Cannot add '{}' logo in email",AuthService::GetLogoAssetFileName())); poco_warning(Logger(),fmt::format("Cannot add '{}' logo in email",AuthService::GetLogoAssetFileName()));
} }
} }
@@ -198,7 +200,7 @@ namespace OpenWifi {
return MessageSendStatus::msg_not_sent_but_resend; return MessageSendStatus::msg_not_sent_but_resend;
} }
catch (const std::exception &E) { catch (const std::exception &E) {
Logger().warning(fmt::format("Cannot send message to:{}, error: {}",Recipient, E.what())); poco_warning(Logger(),fmt::format("Cannot send message to:{}, error: {}",Recipient, E.what()));
return MessageSendStatus::msg_not_sent_but_do_not_resend; return MessageSendStatus::msg_not_sent_but_do_not_resend;
} }
} }

View File

@@ -2,15 +2,14 @@
// Created by stephane bourque on 2021-06-17. // Created by stephane bourque on 2021-06-17.
// //
#ifndef UCENTRALSEC_SMTPMAILERSERVICE_H #pragma once
#define UCENTRALSEC_SMTPMAILERSERVICE_H
#include "framework/MicroService.h"
#include "Poco/File.h" #include "Poco/File.h"
#include "Poco/Net/InvalidCertificateHandler.h" #include "Poco/Net/InvalidCertificateHandler.h"
#include "Poco/Net/AcceptCertificateHandler.h" #include "Poco/Net/AcceptCertificateHandler.h"
#include "framework/SubSystemServer.h"
namespace OpenWifi { namespace OpenWifi {
enum MESSAGE_ATTRIBUTES { enum MESSAGE_ATTRIBUTES {
@@ -77,13 +76,14 @@ namespace OpenWifi {
uint64_t Sent=0; uint64_t Sent=0;
std::string TemplateName; std::string TemplateName;
MessageAttributes Attrs; MessageAttributes Attrs;
bool Subscriber=false;
}; };
void run() override; void run() override;
int Start() override; int Start() override;
void Stop() override; void Stop() override;
bool SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs); bool SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs, bool Subscriber);
MessageSendStatus SendIt(const MessageEvent &Msg); MessageSendStatus SendIt(const MessageEvent &Msg);
void LoadMyConfig(); void LoadMyConfig();
void reinitialize(Poco::Util::Application &self) override; void reinitialize(Poco::Util::Application &self) override;
@@ -105,7 +105,7 @@ namespace OpenWifi {
std::atomic_bool Running_=false; std::atomic_bool Running_=false;
bool Enabled_=false; bool Enabled_=false;
bool UseHTML_=false; bool UseHTML_=false;
std::string EmailLogo_{"logo.jpg"}; std::string EmailLogo_{"logo.png"};
SMTPMailerService() noexcept: SMTPMailerService() noexcept:
SubSystemServer("SMTPMailer", "MAILER-SVR", "smtpmailer") SubSystemServer("SMTPMailer", "MAILER-SVR", "smtpmailer")
@@ -116,4 +116,3 @@ namespace OpenWifi {
inline SMTPMailerService * SMTPMailerService() { return SMTPMailerService::instance(); } inline SMTPMailerService * SMTPMailerService() { return SMTPMailerService::instance(); }
} }
#endif //UCENTRALSEC_SMTPMAILERSERVICE_H

View File

@@ -5,6 +5,8 @@
#pragma once #pragma once
#include "StorageService.h" #include "StorageService.h"
#include "framework/AppServiceRegistry.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
@@ -17,9 +19,9 @@ namespace OpenWifi {
AppServiceRegistry().Get("defaultusercreated", DefaultUserCreated); AppServiceRegistry().Get("defaultusercreated", DefaultUserCreated);
if (!StorageService()->UserDB().GetUserById(NewDefaultUseridStockUUID, U) && !DefaultUserCreated) { if (!StorageService()->UserDB().GetUserById(NewDefaultUseridStockUUID, U) && !DefaultUserCreated) {
U.currentPassword = MicroService::instance().ConfigGetString("authentication.default.password", ""); U.currentPassword = MicroServiceConfigGetString("authentication.default.password", "");
U.lastPasswords.push_back(U.currentPassword); U.lastPasswords.push_back(U.currentPassword);
U.email = MicroService::instance().ConfigGetString("authentication.default.username", ""); U.email = MicroServiceConfigGetString("authentication.default.username", "");
U.id = NewDefaultUseridStockUUID; U.id = NewDefaultUseridStockUUID;
U.userRole = SecurityObjects::ROOT; U.userRole = SecurityObjects::ROOT;
U.creationDate = OpenWifi::Now(); U.creationDate = OpenWifi::Now();

View File

@@ -8,11 +8,14 @@
#include "StorageService.h" #include "StorageService.h"
#include "SpecialUserHelpers.h" #include "SpecialUserHelpers.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
namespace OpenWifi { namespace OpenWifi {
int StorageService::Start() { int StorageService::Start() {
std::lock_guard Guard(Mutex_); std::lock_guard Guard(Mutex_);
poco_information(Logger(),"Starting...");
StorageClass::Start(); StorageClass::Start();
@@ -33,6 +36,7 @@ namespace OpenWifi {
SubAvatarDB_ = std::make_unique<OpenWifi::AvatarDB>("SubAvatars", "avs", dbType_,*Pool_, Logger()); SubAvatarDB_ = std::make_unique<OpenWifi::AvatarDB>("SubAvatars", "avs", dbType_,*Pool_, Logger());
LoginDB_ = std::make_unique<OpenWifi::LoginDB>("Logins", "lin", dbType_,*Pool_, Logger()); LoginDB_ = std::make_unique<OpenWifi::LoginDB>("Logins", "lin", dbType_,*Pool_, Logger());
SubLoginDB_ = std::make_unique<OpenWifi::LoginDB>("SubLogins", "lis", dbType_,*Pool_, Logger()); SubLoginDB_ = std::make_unique<OpenWifi::LoginDB>("SubLogins", "lis", dbType_,*Pool_, Logger());
ApiKeyDB_ = std::make_unique<OpenWifi::ApiKeyDB>("ApiKeys", "api", dbType_,*Pool_, Logger());
UserDB_->Create(); UserDB_->Create();
SubDB_->Create(); SubDB_->Create();
@@ -44,6 +48,7 @@ namespace OpenWifi {
AvatarDB_->Create(); AvatarDB_->Create();
SubAvatarDB_->Create(); SubAvatarDB_->Create();
LoginDB_->Create(); LoginDB_->Create();
ApiKeyDB_->Create();
SubLoginDB_->Create(); SubLoginDB_->Create();
OpenWifi::SpecialUserHelpers::InitializeDefaultUser(); OpenWifi::SpecialUserHelpers::InitializeDefaultUser();
@@ -51,15 +56,16 @@ namespace OpenWifi {
Archivercallback_ = std::make_unique<Poco::TimerCallback<Archiver>>(Archiver_,&Archiver::onTimer); Archivercallback_ = std::make_unique<Poco::TimerCallback<Archiver>>(Archiver_,&Archiver::onTimer);
Timer_.setStartInterval( 5 * 60 * 1000); // first run in 5 minutes Timer_.setStartInterval( 5 * 60 * 1000); // first run in 5 minutes
Timer_.setPeriodicInterval(1 * 60 * 60 * 1000); // 1 hours Timer_.setPeriodicInterval(1 * 60 * 60 * 1000); // 1 hours
Timer_.start(*Archivercallback_, MicroService::instance().TimerPool()); Timer_.start(*Archivercallback_, MicroServiceTimerPool());
return 0; return 0;
} }
void StorageService::Stop() { void StorageService::Stop() {
Logger().notice("Stopping."); poco_information(Logger(),"Stopping...");
Timer_.stop(); Timer_.stop();
StorageClass::Stop(); StorageClass::Stop();
poco_information(Logger(),"Stopped...");
} }
void Archiver::onTimer([[maybe_unused]] Poco::Timer &timer) { void Archiver::onTimer([[maybe_unused]] Poco::Timer &timer) {
@@ -70,6 +76,8 @@ namespace OpenWifi {
StorageService()->UserTokenDB().CleanExpiredTokens(); StorageService()->UserTokenDB().CleanExpiredTokens();
logger.information("Squiggy the DB: removing old actionLinks."); logger.information("Squiggy the DB: removing old actionLinks.");
StorageService()->ActionLinksDB().CleanOldActionLinks(); StorageService()->ActionLinksDB().CleanOldActionLinks();
logger.information("Squiggy the DB: removing old expired API Keys.");
StorageService()->ActionLinksDB().CleanOldActionLinks();
} }
} }

View File

@@ -6,8 +6,7 @@
// Arilia Wireless Inc. // Arilia Wireless Inc.
// //
#ifndef UCENTRAL_USTORAGESERVICE_H #pragma once
#define UCENTRAL_USTORAGESERVICE_H
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "framework/StorageClass.h" #include "framework/StorageClass.h"
@@ -21,6 +20,7 @@
#include "storage/orm_actionLinks.h" #include "storage/orm_actionLinks.h"
#include "storage/orm_avatar.h" #include "storage/orm_avatar.h"
#include "storage/orm_logins.h" #include "storage/orm_logins.h"
#include "storage/orm_apikeys.h"
namespace OpenWifi { namespace OpenWifi {
@@ -52,6 +52,7 @@ namespace OpenWifi {
OpenWifi::AvatarDB & SubAvatarDB() { return *SubAvatarDB_; } OpenWifi::AvatarDB & SubAvatarDB() { return *SubAvatarDB_; }
OpenWifi::LoginDB & LoginDB() { return *LoginDB_; } OpenWifi::LoginDB & LoginDB() { return *LoginDB_; }
OpenWifi::LoginDB & SubLoginDB() { return *SubLoginDB_; } OpenWifi::LoginDB & SubLoginDB() { return *SubLoginDB_; }
OpenWifi::ApiKeyDB & ApiKeyDB() { return *ApiKeyDB_; }
private: private:
@@ -66,6 +67,7 @@ namespace OpenWifi {
std::unique_ptr<OpenWifi::AvatarDB> SubAvatarDB_; std::unique_ptr<OpenWifi::AvatarDB> SubAvatarDB_;
std::unique_ptr<OpenWifi::LoginDB> LoginDB_; std::unique_ptr<OpenWifi::LoginDB> LoginDB_;
std::unique_ptr<OpenWifi::LoginDB> SubLoginDB_; std::unique_ptr<OpenWifi::LoginDB> SubLoginDB_;
std::unique_ptr<OpenWifi::ApiKeyDB> ApiKeyDB_;
std::unique_ptr<OpenWifi::UserCache> UserCache_; std::unique_ptr<OpenWifi::UserCache> UserCache_;
std::unique_ptr<OpenWifi::UserCache> SubCache_; std::unique_ptr<OpenWifi::UserCache> SubCache_;
@@ -80,5 +82,3 @@ namespace OpenWifi {
inline auto StorageService() { return StorageService::instance(); }; inline auto StorageService() { return StorageService::instance(); };
} // namespace } // namespace
#endif //UCENTRAL_USTORAGESERVICE_H

View File

@@ -2,14 +2,14 @@
// Created by stephane bourque on 2022-01-31. // Created by stephane bourque on 2022-01-31.
// //
#ifndef OWSEC_TOTPCACHE_H #pragma once
#define OWSEC_TOTPCACHE_H
#include "framework/MicroService.h"
#include "seclibs/cpptotp/bytes.h" #include "seclibs/cpptotp/bytes.h"
#include "seclibs/qrcode/qrcodegen.hpp" #include "seclibs/qrcode/qrcodegen.hpp"
#include "seclibs/cpptotp/otp.h" #include "seclibs/cpptotp/otp.h"
#include "framework/MicroServiceFuncs.h"
namespace OpenWifi { namespace OpenWifi {
class TotpCache : public SubSystemServer { class TotpCache : public SubSystemServer {
@@ -34,7 +34,7 @@ namespace OpenWifi {
std::string R; std::string R;
for(;Size;Size--) { for(;Size;Size--) {
R += (char) MicroService::instance().Random(33,127); R += (char) MicroServiceRandom(33,127);
} }
Base32Secret = CppTotp::Bytes::toBase32( CppTotp::Bytes::ByteString{ (const u_char *)R.c_str()}); Base32Secret = CppTotp::Bytes::toBase32( CppTotp::Bytes::ByteString{ (const u_char *)R.c_str()});
return R; return R;
@@ -55,13 +55,13 @@ namespace OpenWifi {
uint64_t Now = OpenWifi::Now(); uint64_t Now = OpenWifi::Now();
uint32_t p = CppTotp::totp(CppTotp::Bytes::ByteString{ (const u_char *)Secret.c_str()}, Now, 0, 30, 6); uint32_t p = CppTotp::totp(CppTotp::Bytes::ByteString{ (const u_char *)Secret.c_str()}, Now, 0, 30, 6);
char buffer[16]{0}; char buffer[16]{0};
sprintf(buffer,"%06u",p); snprintf(buffer,7,"%06u",p);
Expecting = std::string(buffer); Expecting = std::string(buffer);
return Code == Expecting; return Code == Expecting;
} }
int Start() override { int Start() override {
Issuer_ = MicroService::instance().ConfigGetString("totp.issuer","OpenWiFi"); Issuer_ = MicroServiceConfigGetString("totp.issuer","OpenWiFi");
return 0; return 0;
}; };
@@ -163,5 +163,3 @@ namespace OpenWifi {
inline auto TotpCache() { return TotpCache::instance(); } inline auto TotpCache() { return TotpCache::instance(); }
} }
#endif //OWSEC_TOTPCACHE_H

View File

@@ -0,0 +1,77 @@
//
// Created by stephane bourque on 2022-10-25.
//
#include "ALBserver.h"
#include "framework/utils.h"
#include "framework/MicroServiceFuncs.h"
#include "fmt/format.h"
namespace OpenWifi {
void ALBRequestHandler::handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) {
Utils::SetThreadName("alb-request");
try {
if((id_ % 100) == 0) {
Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.", Request.clientAddress().toString(), id_));
}
Response.setChunkedTransferEncoding(true);
Response.setContentType("text/html");
Response.setDate(Poco::Timestamp());
Response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
Response.setKeepAlive(true);
Response.set("Connection", "keep-alive");
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
std::ostream &Answer = Response.send();
Answer << "process Alive and kicking!";
} catch (...) {
}
}
ALBRequestHandlerFactory::ALBRequestHandlerFactory(Poco::Logger & L):
Logger_(L) {
}
ALBRequestHandler* ALBRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest& request) {
if (request.getURI() == "/")
return new ALBRequestHandler(Logger_, req_id_++);
else
return nullptr;
}
ALBHealthCheckServer::ALBHealthCheckServer() :
SubSystemServer("ALBHealthCheckServer", "ALB-SVR", "alb")
{
}
int ALBHealthCheckServer::Start() {
if(MicroServiceConfigGetBool("alb.enable",false)) {
poco_information(Logger(),"Starting...");
Running_=true;
Port_ = (int)MicroServiceConfigGetInt("alb.port",15015);
Poco::Net::IPAddress Addr(Poco::Net::IPAddress::wildcard(
Poco::Net::Socket::supportsIPv6() ? Poco::Net::AddressFamily::IPv6
: Poco::Net::AddressFamily::IPv4));
Poco::Net::SocketAddress SockAddr(Addr, Port_);
Poco::Net::ServerSocket ClientSocket(SockAddr, 64);
Socket_ = std::make_unique<Poco::Net::ServerSocket>(SockAddr, Port_);
auto Params = new Poco::Net::HTTPServerParams;
Params->setName("ws:alb");
Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger()), *Socket_, Params);
Server_->start();
}
return 0;
}
void ALBHealthCheckServer::Stop() {
poco_information(Logger(),"Stopping...");
if(Running_)
Server_->stopAll(true);
poco_information(Logger(),"Stopped...");
}
} // namespace OpenWifi

Some files were not shown because too many files have changed in this diff Show More