From 0bd9bd1a8da35cdf2a50057d9862257fe786a76d Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Thu, 2 Dec 2021 16:30:57 +0100 Subject: [PATCH] Changed /api endpoint to /apiKeys in order to avoid confusion with /api/ --- docs/advanced.rst | 11 ++++++----- internal/webserver/Webserver.go | 6 +++--- internal/webserver/Webserver_test.go | 12 ++++++------ internal/webserver/web/templates/html_header.tmpl | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/advanced.rst b/docs/advanced.rst index 9c9c52d..8e07c26 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -124,15 +124,16 @@ All values that are described in :ref:`cloudstorage` can be passed as environmen External Authentication ******************************** -In order to use external authentication (eg. services like Authelia or Authentik), set the environment variable ``GOKAPI_DISABLE_LOGIN`` to ``true`` on the first start. *Warning:* This will diasable authentication for the admin menu, which can be dangerous if not set up correctly! +In order to use external authentication (eg. services like Authelia or Authentik), set the environment variable ``GOKAPI_DISABLE_LOGIN`` to ``true`` on the first start. **Warning:** This will diasable authentication for the admin menu, which can be dangerous if not set up correctly! + +**Refer to the documention of your reverse proxy on how to protect the following URLs:** -Refer to the documention of your reverse proxy on how to protect the following URLs: * ``/admin`` - * ``/apiNew`` * ``/apiDelete`` + * ``/apiKeys`` + * ``/apiNew`` * ``/delete`` * ``/upload`` - * ``/api`` (``/api/`` however does not need to be protected) .. _api: @@ -140,7 +141,7 @@ Refer to the documention of your reverse proxy on how to protect the following U API ******************************** -Gokapi offers an API that can be reached at ``http(s)://your.gokapi.url/api``. You can find the current documentation with an overview of all API functions and examples at ``http(s)://your.gokapi.url/apidocumentation/``. +Gokapi offers an API that can be reached at ``http(s)://your.gokapi.url/api/``. You can find the current documentation with an overview of all API functions and examples at ``http(s)://your.gokapi.url/apidocumentation/``. Interacting with the API diff --git a/internal/webserver/Webserver.go b/internal/webserver/Webserver.go index 3aac759..8f96eb2 100644 --- a/internal/webserver/Webserver.go +++ b/internal/webserver/Webserver.go @@ -85,7 +85,7 @@ func Start() { http.HandleFunc("/downloadFile", downloadFile) http.HandleFunc("/forgotpw", forgotPassword) http.HandleFunc("/api/", processApi) - http.HandleFunc("/api", showApiAdmin) + http.HandleFunc("/apiKeys", showApiAdmin) http.HandleFunc("/apiNew", newApiKey) http.HandleFunc("/apiDelete", deleteApiKey) fmt.Println("Binding webserver to " + webserverPort) @@ -186,7 +186,7 @@ func newApiKey(w http.ResponseWriter, r *http.Request) { return } api.NewKey() - redirect(w, "api") + redirect(w, "apiKeys") } // Handling of /apiDelete @@ -199,7 +199,7 @@ func deleteApiKey(w http.ResponseWriter, r *http.Request) { if ok { api.DeleteKey(keys[0]) } - redirect(w, "api") + redirect(w, "apiKeys") } // Handling of /api/ diff --git a/internal/webserver/Webserver_test.go b/internal/webserver/Webserver_test.go index c1ec04c..2e41ea8 100644 --- a/internal/webserver/Webserver_test.go +++ b/internal/webserver/Webserver_test.go @@ -426,7 +426,7 @@ func TestDeleteFile(t *testing.T) { func TestApiPageAuthorized(t *testing.T) { t.Parallel() test.HttpPageResult(t, test.HttpTestConfig{ - Url: "http://127.0.0.1:53843/api", + Url: "http://127.0.0.1:53843/apiKeys", IsHtml: true, RequiredContent: []string{"Click on the API key name to give it a new name."}, Cookies: []test.Cookie{{ @@ -438,7 +438,7 @@ func TestApiPageAuthorized(t *testing.T) { func TestApiPageNotAuthorized(t *testing.T) { t.Parallel() test.HttpPageResult(t, test.HttpTestConfig{ - Url: "http://127.0.0.1:53843/api", + Url: "http://127.0.0.1:53843/apiKeys", IsHtml: true, RequiredContent: []string{"URL=./login"}, ExcludedContent: []string{"Click on the API key name to give it a new name."}, @@ -457,7 +457,7 @@ func TestNewApiKey(t *testing.T) { test.HttpPageResult(t, test.HttpTestConfig{ Url: "http://127.0.0.1:53843/apiNew", IsHtml: true, - RequiredContent: []string{"URL=./api"}, + RequiredContent: []string{"URL=./apiKeys"}, ExcludedContent: []string{"URL=./login"}, Cookies: []test.Cookie{{ Name: "session_token", @@ -476,7 +476,7 @@ func TestNewApiKey(t *testing.T) { Url: "http://127.0.0.1:53843/apiNew", IsHtml: true, RequiredContent: []string{"URL=./login"}, - ExcludedContent: []string{"URL=./api"}, + ExcludedContent: []string{"URL=./apiKeys"}, Cookies: []test.Cookie{{ Name: "session_token", Value: "invalid", @@ -498,7 +498,7 @@ func TestDeleteApiKey(t *testing.T) { Url: "http://127.0.0.1:53843/apiDelete?id=jiREglQJW0bOqJakfjdVfe8T1EM8n8", IsHtml: true, RequiredContent: []string{"URL=./login"}, - ExcludedContent: []string{"URL=./api"}, + ExcludedContent: []string{"URL=./apiKeys"}, Cookies: []test.Cookie{{ Name: "session_token", Value: "invalid", @@ -515,7 +515,7 @@ func TestDeleteApiKey(t *testing.T) { test.HttpPageResult(t, test.HttpTestConfig{ Url: "http://127.0.0.1:53843/apiDelete?id=jiREglQJW0bOqJakfjdVfe8T1EM8n8", IsHtml: true, - RequiredContent: []string{"URL=./api"}, + RequiredContent: []string{"URL=./apiKeys"}, ExcludedContent: []string{"URL=./login"}, Cookies: []test.Cookie{{ Name: "session_token", diff --git a/internal/webserver/web/templates/html_header.tmpl b/internal/webserver/web/templates/html_header.tmpl index f115f88..dfa00f7 100644 --- a/internal/webserver/web/templates/html_header.tmpl +++ b/internal/webserver/web/templates/html_header.tmpl @@ -44,7 +44,7 @@

{{template "app_name"}}