diff --git a/endpoints.go b/endpoints.go index 18e9a7e..124c698 100644 --- a/endpoints.go +++ b/endpoints.go @@ -6,6 +6,19 @@ import ( "github.com/gorilla/mux" ) +func rootEndpoint(w http.ResponseWriter, r *http.Request) { + sendJSON(w, YggdrasilInfo{ + Status: "OK", + RuntimeMode: "productionMode", + AppAuthor: "Tripwire Team", + AppDescription: "Custom Yggdrasil authentication server", + SpecVersion: "5.2.0", + AppName: "tripwire.yggdrasil", + ImplVersion: "5.2.0", + AppOwner: "Who knows?", + }) +} + func authenticateEndpoint(w http.ResponseWriter, r *http.Request) { var authPayload AuthPayload err := unmarshalTo(r, &authPayload) @@ -140,7 +153,7 @@ func invalidateEndpoint(w http.ResponseWriter, r *http.Request) { } func registerEndpoints(r *mux.Router) { - r.HandleFunc("/", notFoundStub) + r.HandleFunc("/", rootEndpoint) r.HandleFunc("/authenticate", authenticateEndpoint).Methods("POST") r.HandleFunc("/refresh", refreshTokenEndpoint).Methods("POST") r.HandleFunc("/signout", signoutEndpoint).Methods("POST") diff --git a/main.go b/main.go index e454fb4..93132a7 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,11 @@ func handleRequests() { } func main() { + log.Println("Tripwire initializing...") initDB() + log.Println("Tripwire started.") + handleRequests() defer DB.Close() diff --git a/types.go b/types.go index a079f05..5725387 100644 --- a/types.go +++ b/types.go @@ -41,6 +41,17 @@ type UserCredentials struct { Password string `json:"password"` } +type YggdrasilInfo struct { + Status string `json:"Status"` + RuntimeMode string `json:"Runtime-Mode"` + AppAuthor string `json:"Application-Author"` + AppDescription string `json:"Application-Description"` + SpecVersion string `json:"Specification-Version"` + AppName string `json:"Application-Name"` + ImplVersion string `json:"Implementation-Version"` + AppOwner string `json:"Application-Owner"` +} + type NotFoundError struct{} func (m *NotFoundError) Error() string {