fix
This commit is contained in:
+8
-9
@@ -2,20 +2,19 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"authentication/db"
|
"authentication/db"
|
||||||
|
"authentication/helper"
|
||||||
"authentication/models"
|
"authentication/models"
|
||||||
"authentication/redisclient"
|
"authentication/redisclient"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HealthHandler(w http.ResponseWriter, r *http.Request) {
|
func HealthHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
response := models.HealthResponse{
|
||||||
w.WriteHeader(http.StatusOK)
|
Status: "AuthN Capy!",
|
||||||
json.NewEncoder(w).Encode(models.HealthResponse{
|
}
|
||||||
Status: "ok",
|
helper.RespondWithJSON(w, http.StatusOK, response)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadyHandler checks if the service is ready to handle requests
|
// ReadyHandler checks if the service is ready to handle requests
|
||||||
@@ -62,15 +61,15 @@ func ReadyHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
allHealthy = false
|
allHealthy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
status := "ready"
|
status := "Capy!"
|
||||||
statusCode := http.StatusOK
|
statusCode := http.StatusOK
|
||||||
if !allHealthy {
|
if !allHealthy {
|
||||||
status = "not_ready"
|
status = "not Capy!"
|
||||||
statusCode = http.StatusServiceUnavailable
|
statusCode = http.StatusServiceUnavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
json.NewEncoder(w).Encode(models.HealthResponse{
|
helper.RespondWithJSON(w, statusCode, models.HealthResponse{
|
||||||
Status: status,
|
Status: status,
|
||||||
Services: services,
|
Services: services,
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ func init() {
|
|||||||
keyPath = "rsa/psa.gov.ph.key"
|
keyPath = "rsa/psa.gov.ph.key"
|
||||||
}
|
}
|
||||||
|
|
||||||
keyData, err := os.ReadFile(keyPath)
|
keyData, err := os.ReadFile(keyPath) // #nosec G304
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isTestEnvironment() {
|
if isTestEnvironment() {
|
||||||
log.Printf("Failed to read RSA private key file at %s, generating test key: %v", keyPath, err)
|
log.Printf("Failed to read RSA private key file at %s, generating test key: %v", keyPath, err)
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
csrfTokenHeader = "X-CSRF-Token"
|
csrfTokenHeader = "X-CSRF-Token" // #nosec G101
|
||||||
csrfCookieName = "csrf_token"
|
csrfCookieName = "csrf_token"
|
||||||
csrfTokenLength = 32
|
csrfTokenLength = 32
|
||||||
csrfTokenTTL = 24 * time.Hour
|
csrfTokenTTL = 24 * time.Hour
|
||||||
|
|||||||
Reference in New Issue
Block a user