From 1080c8fcd9be283f5d5fe801f5219e88b08540d2 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Fri, 30 May 2025 01:48:44 +0700 Subject: [PATCH] updated config and added tls support --- auth_service.config | 9 ++++++++- main.go | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/auth_service.config b/auth_service.config index 0ac9aa0..a0b4e5c 100644 --- a/auth_service.config +++ b/auth_service.config @@ -1,3 +1,10 @@ USERS_FILE=users.json USERS_DB=users.db -ENABLE_SELF_REGISTER=false \ No newline at end of file +ENABLE_SELF_REGISTER=false + +ENABLE_TLS=false +CERT_FILE=/home/tola/certs/localhost/localhost.crt +KEY_FILE=/home/tola/certs/localhost/localhost.key + +SERVER_ADDRESS=localhost +SERVER_PORT=8090 \ No newline at end of file diff --git a/main.go b/main.go index 1940ecd..7b859be 100644 --- a/main.go +++ b/main.go @@ -39,5 +39,17 @@ func main() { http.HandleFunc("/api/users/change", users.ChangeUser) http.HandleFunc("/api/users/del", users.DelUser) http.HandleFunc("/api/users/add", users.AddUser) - http.ListenAndServe(":8090", nil) + if os.Getenv("ENABLE_TLS") == "true" { + http.ListenAndServeTLS( + os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"), + os.Getenv("CERT_FILE"), + os.Getenv("KEY_FILE"), + nil, + ) + } else { + http.ListenAndServe( + os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"), + nil, + ) + } }