|
@@ -34,6 +34,7 @@ func userHandlers(r *mux.Router) {
|
|
r.HandleFunc("/api/oauth/login", auth.HandleAuthLogin).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/oauth/login", auth.HandleAuthLogin).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/oauth/callback", auth.HandleAuthCallback).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/oauth/callback", auth.HandleAuthCallback).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/oauth/node-handler", socketHandler)
|
|
r.HandleFunc("/api/oauth/node-handler", socketHandler)
|
|
|
|
+ r.HandleFunc("/api/oauth/headless", auth.HandleHeadlessSSO)
|
|
r.HandleFunc("/api/oauth/register/{regKey}", auth.RegisterNodeSSO).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/oauth/register/{regKey}", auth.RegisterNodeSSO).Methods(http.MethodGet)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -41,13 +42,13 @@ func userHandlers(r *mux.Router) {
|
|
//
|
|
//
|
|
// Node authenticates using its password and retrieves a JWT for authorization.
|
|
// Node authenticates using its password and retrieves a JWT for authorization.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: successResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: successResponse
|
|
func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
|
func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
// Auth request consists of Mac Address and Password (from node that is authorizing
|
|
// Auth request consists of Mac Address and Password (from node that is authorizing
|
|
@@ -113,13 +114,13 @@ func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
|
//
|
|
//
|
|
// Checks whether the server has an admin.
|
|
// Checks whether the server has an admin.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: successResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: successResponse
|
|
func hasAdmin(w http.ResponseWriter, r *http.Request) {
|
|
func hasAdmin(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -139,13 +140,13 @@ func hasAdmin(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Get an individual user.
|
|
// Get an individual user.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func getUser(w http.ResponseWriter, r *http.Request) {
|
|
func getUser(w http.ResponseWriter, r *http.Request) {
|
|
// set header.
|
|
// set header.
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -167,13 +168,13 @@ func getUser(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Get all users.
|
|
// Get all users.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func getUsers(w http.ResponseWriter, r *http.Request) {
|
|
func getUsers(w http.ResponseWriter, r *http.Request) {
|
|
// set header.
|
|
// set header.
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -194,13 +195,13 @@ func getUsers(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Make a user an admin.
|
|
// Make a user an admin.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func createAdmin(w http.ResponseWriter, r *http.Request) {
|
|
func createAdmin(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
|
@@ -236,13 +237,13 @@ func createAdmin(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Create a user.
|
|
// Create a user.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func createUser(w http.ResponseWriter, r *http.Request) {
|
|
func createUser(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
|
@@ -270,13 +271,13 @@ func createUser(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Updates the networks of the given user.
|
|
// Updates the networks of the given user.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func updateUserNetworks(w http.ResponseWriter, r *http.Request) {
|
|
func updateUserNetworks(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -319,13 +320,13 @@ func updateUserNetworks(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Update a user.
|
|
// Update a user.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func updateUser(w http.ResponseWriter, r *http.Request) {
|
|
func updateUser(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -369,13 +370,13 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Updates the given admin user's info (as long as the user is an admin).
|
|
// Updates the given admin user's info (as long as the user is an admin).
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func updateUserAdm(w http.ResponseWriter, r *http.Request) {
|
|
func updateUserAdm(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -420,13 +421,13 @@ func updateUserAdm(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Delete a user.
|
|
// Delete a user.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: userBodyResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: userBodyResponse
|
|
func deleteUser(w http.ResponseWriter, r *http.Request) {
|
|
func deleteUser(w http.ResponseWriter, r *http.Request) {
|
|
// Set header
|
|
// Set header
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|