From 74cb3a712906f2a08b398bcd9da48f370e41cad8 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:05:45 +0100 Subject: [PATCH 01/14] fix email template Signed-off-by: Mirko Teodorovic --- .env | 2 +- cmd/users/main.go | 2 +- docker/docker-compose.yml | 2 +- users/README.md | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 915f727068..c4e717f27e 100644 --- a/.env +++ b/.env @@ -44,7 +44,7 @@ MF_EMAIL_USERNAME=18bf7f70705139 MF_EMAIL_PASSWORD=2b0d302e775b1e MF_EMAIL_FROM_ADDRESS=from@example.com MF_EMAIL_FROM_NAME=Example -MF_EMAIL_TEMPLATE=/resetPasswEmail.tmpl +MF_EMAIL_TEMPLATE=email.tmpl ### Token utility MF_TOKEN_SECRET=some_random_bytes diff --git a/cmd/users/main.go b/cmd/users/main.go index 4cce82615a..6154489783 100644 --- a/cmd/users/main.go +++ b/cmd/users/main.go @@ -65,7 +65,7 @@ const ( defEmailPassword = "" defEmailFromAddress = "" defEmailFromName = "" - defEmailTemplate = "../configs/resetPasswEmail.tmpl" + defEmailTemplate = "email.tmpl" defTokenSecret = "mainflux-secret" defTokenDuration = "5" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 587f095b9d..758695e011 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -91,10 +91,10 @@ services: MF_EMAIL_PASSWORD: ${MF_EMAIL_PASSWORD} MF_EMAIL_FROM_ADDRESS: ${MF_EMAIL_FROM_ADDRESS} MF_EMAIL_FROM_NAME: ${MF_EMAIL_FROM_NAME} + MF_EMAIL_TEMPLATE: ${MF_EMAIL_TEMPLATE} MF_TOKEN_SECRET: ${MF_TOKEN_SECRET} MF_TOKEN_DURATION: ${MF_TOKEN_DURATION} MF_TOKEN_RESET_ENDPOINT: ${MF_TOKEN_RESET_ENDPOINT} - MF_EMAIL_TEMPLATE: ${MF_EMAIL_TEMPLATE} ports: - ${MF_USERS_HTTP_PORT}:${MF_USERS_HTTP_PORT} networks: diff --git a/users/README.md b/users/README.md index 1046bf0527..16372523ef 100644 --- a/users/README.md +++ b/users/README.md @@ -41,7 +41,8 @@ default values. | MF_EMAIL_PASSWORD | Mail server password | | | MF_EMAIL_FROM_ADDRESS | Email "from" address | | | MF_EMAIL_FROM_NAME | Email "from" name | | -| MF_TOKEN_SECRET | Token secret for signing token used for password reset | | +| MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | | +| MF_TOKEN_SECRET | Token s|cret for signing token used for password reset | email.tmpl | | MF_TOKEN_DURATION | Token duration in minutes | 5 | | MF_TOKEN_DEBUG_LEVEL | Token util debug level | info | | MF_TOKEN_RESET_ENDPOINT | Password request reset endpoint, for constructing link | /reset-request | @@ -84,6 +85,7 @@ services: MF_EMAIL_PASSWORD: [MF_EMAIL_PASSWORD] MF_EMAIL_FROM_ADDRESS: [MF_EMAIL_FROM_ADDRESS] MF_EMAIL_FROM_NAME: [MF_EMAIL_FROM_NAME] + MF_EMAIL_TEMPLATE: [MF_EMAIL_TEMPLATE] MF_TOKEN_SECRET: [MF_TOKEN_SECRET] MF_TOKEN_DURATION: [MF_TOKEN_DURATION] MF_TOKEN_DEBUG_LEVEL: [MF_TOKEN_DEBUG_LEVEL] From d3316577242ce4afae0d3b6a1d47ebf2aedceef6 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:48:42 +0100 Subject: [PATCH 02/14] rename resetPasswEmail.tmpl Signed-off-by: Mirko Teodorovic --- users/emailer/templates/resetPasswEmail.tmpl | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 users/emailer/templates/resetPasswEmail.tmpl diff --git a/users/emailer/templates/resetPasswEmail.tmpl b/users/emailer/templates/resetPasswEmail.tmpl deleted file mode 100644 index 9725d0030d..0000000000 --- a/users/emailer/templates/resetPasswEmail.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -To: {{.To}} -From: {{.From}} -Subject: {{.Subject}} -{{.Header}} -You have initiated password reset. -Follow the link below to reset password. -{{.Content}} -{{.Footer}} - From 20668dfd23df4d354176683087c1e5a786929c81 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:49:11 +0100 Subject: [PATCH 03/14] add env var Signed-off-by: Mirko Teodorovic --- scripts/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run.sh b/scripts/run.sh index b3d1b61ba0..36b20a173b 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -38,7 +38,7 @@ done ### # Users ### -MF_USERS_LOG_LEVEL=info $BUILD_DIR/mainflux-users & +MF_USERS_LOG_LEVEL=info MF_EMAIL_TEMPLATE=email.tmpl $BUILD_DIR/mainflux-users & ### # Things From 6eb91afce4f4f542c04246efa5d0ac552c0c1ebd Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:49:33 +0100 Subject: [PATCH 04/14] rename resetPasswEmail.tmpl Signed-off-by: Mirko Teodorovic --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 758695e011..b761ea5316 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -67,7 +67,7 @@ services: image: mainflux/users:latest container_name: mainflux-users volumes: - - ../users/emailer/templates/${MF_EMAIL_TEMPLATE}:${MF_EMAIL_TEMPLATE} + - ../users/emailer/templates/${MF_EMAIL_TEMPLATE}:/${MF_EMAIL_TEMPLATE} depends_on: - users-db expose: From 0b37749a005763369a15a7f5a420cf24742b8258 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:50:01 +0100 Subject: [PATCH 05/14] rename resetPasswEmail.tmpl Signed-off-by: Mirko Teodorovic --- users/emailer/templates/email.tmpl | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 users/emailer/templates/email.tmpl diff --git a/users/emailer/templates/email.tmpl b/users/emailer/templates/email.tmpl new file mode 100644 index 0000000000..9725d0030d --- /dev/null +++ b/users/emailer/templates/email.tmpl @@ -0,0 +1,9 @@ +To: {{.To}} +From: {{.From}} +Subject: {{.Subject}} +{{.Header}} +You have initiated password reset. +Follow the link below to reset password. +{{.Content}} +{{.Footer}} + From 8eeb3295e909df310fb18910092d009105447cb4 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 06:52:01 +0100 Subject: [PATCH 06/14] upd docs Signed-off-by: Mirko Teodorovic --- users/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/users/README.md b/users/README.md index 16372523ef..572ea3c307 100644 --- a/users/README.md +++ b/users/README.md @@ -41,8 +41,8 @@ default values. | MF_EMAIL_PASSWORD | Mail server password | | | MF_EMAIL_FROM_ADDRESS | Email "from" address | | | MF_EMAIL_FROM_NAME | Email "from" name | | -| MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | | -| MF_TOKEN_SECRET | Token s|cret for signing token used for password reset | email.tmpl | +| MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | email.tmpl | +| MF_TOKEN_SECRET | Token secret for signing token used for password reset | | | MF_TOKEN_DURATION | Token duration in minutes | 5 | | MF_TOKEN_DEBUG_LEVEL | Token util debug level | info | | MF_TOKEN_RESET_ENDPOINT | Password request reset endpoint, for constructing link | /reset-request | From b2364e4178df73ee0e5e6aff92d57704b7afa88e Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 07:03:20 +0100 Subject: [PATCH 07/14] upd docs Signed-off-by: Mirko Teodorovic --- users/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/users/README.md b/users/README.md index 572ea3c307..561cdaf238 100644 --- a/users/README.md +++ b/users/README.md @@ -42,9 +42,8 @@ default values. | MF_EMAIL_FROM_ADDRESS | Email "from" address | | | MF_EMAIL_FROM_NAME | Email "from" name | | | MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | email.tmpl | -| MF_TOKEN_SECRET | Token secret for signing token used for password reset | | +| MF_TOKEN_SECRET | Password reset token signing secret | | | MF_TOKEN_DURATION | Token duration in minutes | 5 | -| MF_TOKEN_DEBUG_LEVEL | Token util debug level | info | | MF_TOKEN_RESET_ENDPOINT | Password request reset endpoint, for constructing link | /reset-request | ## Deployment @@ -88,7 +87,6 @@ services: MF_EMAIL_TEMPLATE: [MF_EMAIL_TEMPLATE] MF_TOKEN_SECRET: [MF_TOKEN_SECRET] MF_TOKEN_DURATION: [MF_TOKEN_DURATION] - MF_TOKEN_DEBUG_LEVEL: [MF_TOKEN_DEBUG_LEVEL] MF_TOKEN_RESET_ENDPOINT: [MF_TOKEN_RESET_ENDPOINT] ``` @@ -107,7 +105,7 @@ make users make install # set the environment variables and run the service -MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] $GOBIN/mainflux-users +MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] MF_EMAIL_DRIVER=[Mail server driver smtp] MF_EMAIL_HOST=[Mail server host] MF_EMAIL_PORT=[Mail server port] MF_EMAIL_USERNAME=[Mail server username] MF_EMAIL_PASSWORD=[Mail server password] MF_EMAIL_FROM_ADDRESS=[Email from address] MF_EMAIL_FROM_NAME=[Email from name] MF_EMAIL_TEMPLATE=[Email template file] MF_TOKEN_SECRET=[Password reset token signing secret] MF_TOKEN_DURATION=[Password reset token duration] MF_TOKEN_RESET_ENDPOINT=[Password reset token endpoint] $GOBIN/mainflux-users ``` ## Usage From 14ab8c1000e933ab13333cece3a482a603b8e7e7 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 07:05:36 +0100 Subject: [PATCH 08/14] upd docs Signed-off-by: Mirko Teodorovic --- users/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/users/README.md b/users/README.md index 561cdaf238..0f59ea851c 100644 --- a/users/README.md +++ b/users/README.md @@ -108,6 +108,8 @@ make install MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] MF_EMAIL_DRIVER=[Mail server driver smtp] MF_EMAIL_HOST=[Mail server host] MF_EMAIL_PORT=[Mail server port] MF_EMAIL_USERNAME=[Mail server username] MF_EMAIL_PASSWORD=[Mail server password] MF_EMAIL_FROM_ADDRESS=[Email from address] MF_EMAIL_FROM_NAME=[Email from name] MF_EMAIL_TEMPLATE=[Email template file] MF_TOKEN_SECRET=[Password reset token signing secret] MF_TOKEN_DURATION=[Password reset token duration] MF_TOKEN_RESET_ENDPOINT=[Password reset token endpoint] $GOBIN/mainflux-users ``` +if 'MF_EMAIL_TEMPLATE' doesn't point to any file service will function but password reset functionality will not work + ## Usage For more information about service capabilities and its usage, please check out From f2bac00157219c16a0c5d698b7a122785147bae4 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 07:12:23 +0100 Subject: [PATCH 09/14] remove not needed file Signed-off-by: Mirko Teodorovic --- configs/resetPasswEmail.tmpl | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 configs/resetPasswEmail.tmpl diff --git a/configs/resetPasswEmail.tmpl b/configs/resetPasswEmail.tmpl deleted file mode 100644 index c2e99d9934..0000000000 --- a/configs/resetPasswEmail.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -To: {{.To}} -From: {{.From}} -Subject: {{.Subject}} -{{.Header}} -{{.Content}} -{{.Footer}} - From cb89a5f2762428ae406dde69d06f3d06d1cbbc33 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 14:50:46 +0100 Subject: [PATCH 10/14] move email tmpl Signed-off-by: Mirko Teodorovic --- docker/users/emailer/templates/email.tmpl | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docker/users/emailer/templates/email.tmpl diff --git a/docker/users/emailer/templates/email.tmpl b/docker/users/emailer/templates/email.tmpl new file mode 100644 index 0000000000..9725d0030d --- /dev/null +++ b/docker/users/emailer/templates/email.tmpl @@ -0,0 +1,9 @@ +To: {{.To}} +From: {{.From}} +Subject: {{.Subject}} +{{.Header}} +You have initiated password reset. +Follow the link below to reset password. +{{.Content}} +{{.Footer}} + From 8fcf45bffd98c406b39474a7712073d66ea8bfab Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 14:50:57 +0100 Subject: [PATCH 11/14] move email tmpl Signed-off-by: Mirko Teodorovic --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b761ea5316..ac5a118358 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -67,7 +67,7 @@ services: image: mainflux/users:latest container_name: mainflux-users volumes: - - ../users/emailer/templates/${MF_EMAIL_TEMPLATE}:/${MF_EMAIL_TEMPLATE} + - ./users/emailer/templates/${MF_EMAIL_TEMPLATE}:/${MF_EMAIL_TEMPLATE} depends_on: - users-db expose: From b8a9e82b330c8404719d8da2ab96ed7cc5542988 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 14:51:00 +0100 Subject: [PATCH 12/14] move email tmpl Signed-off-by: Mirko Teodorovic --- users/emailer/templates/email.tmpl | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 users/emailer/templates/email.tmpl diff --git a/users/emailer/templates/email.tmpl b/users/emailer/templates/email.tmpl deleted file mode 100644 index 9725d0030d..0000000000 --- a/users/emailer/templates/email.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -To: {{.To}} -From: {{.From}} -Subject: {{.Subject}} -{{.Header}} -You have initiated password reset. -Follow the link below to reset password. -{{.Content}} -{{.Footer}} - From e38e90db445d70dddf33716c210e803bb03fa8fc Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 9 Nov 2019 15:03:03 +0100 Subject: [PATCH 13/14] variable for tmpl Signed-off-by: Mirko Teodorovic --- scripts/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run.sh b/scripts/run.sh index 36b20a173b..d3287e4ccd 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -38,7 +38,7 @@ done ### # Users ### -MF_USERS_LOG_LEVEL=info MF_EMAIL_TEMPLATE=email.tmpl $BUILD_DIR/mainflux-users & +MF_USERS_LOG_LEVEL=info MF_EMAIL_TEMPLATE=../docker/users/emailer/templates/email.tmpl $BUILD_DIR/mainflux-users & ### # Things From dda8d4f700a8afcc17cd83b393c236c212ca05af Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sun, 10 Nov 2019 12:51:14 +0100 Subject: [PATCH 14/14] fix ident and caps Signed-off-by: Mirko Teodorovic --- users/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/users/README.md b/users/README.md index 0f59ea851c..40d007e1ff 100644 --- a/users/README.md +++ b/users/README.md @@ -42,7 +42,7 @@ default values. | MF_EMAIL_FROM_ADDRESS | Email "from" address | | | MF_EMAIL_FROM_NAME | Email "from" name | | | MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | email.tmpl | -| MF_TOKEN_SECRET | Password reset token signing secret | | +| MF_TOKEN_SECRET | Password reset token signing secret | | | MF_TOKEN_DURATION | Token duration in minutes | 5 | | MF_TOKEN_RESET_ENDPOINT | Password request reset endpoint, for constructing link | /reset-request | @@ -108,7 +108,7 @@ make install MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] MF_EMAIL_DRIVER=[Mail server driver smtp] MF_EMAIL_HOST=[Mail server host] MF_EMAIL_PORT=[Mail server port] MF_EMAIL_USERNAME=[Mail server username] MF_EMAIL_PASSWORD=[Mail server password] MF_EMAIL_FROM_ADDRESS=[Email from address] MF_EMAIL_FROM_NAME=[Email from name] MF_EMAIL_TEMPLATE=[Email template file] MF_TOKEN_SECRET=[Password reset token signing secret] MF_TOKEN_DURATION=[Password reset token duration] MF_TOKEN_RESET_ENDPOINT=[Password reset token endpoint] $GOBIN/mainflux-users ``` -if 'MF_EMAIL_TEMPLATE' doesn't point to any file service will function but password reset functionality will not work +If `MF_EMAIL_TEMPLATE` doesn't point to any file service will function but password reset functionality will not work. ## Usage