Changed /api endpoint to /apiKeys in order to avoid confusion with /api/

This commit is contained in:
Marc Ole Bulling
2021-12-02 16:30:57 +01:00
parent 4b411f113f
commit 0bd9bd1a8d
4 changed files with 16 additions and 15 deletions
+6 -5
View File
@@ -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
+3 -3
View File
@@ -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/
+6 -6
View File
@@ -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",
@@ -44,7 +44,7 @@
<h1>{{template "app_name"}}</h1>
<nav class="nav nav-masthead justify-content-center">
<a class="nav-link {{ if .IsMainView }}active{{ end }}" href="./admin">Upload</a>
<a class="nav-link {{ if not .IsMainView }}active{{ end }}" href="./api">API</a>
<a class="nav-link {{ if not .IsMainView }}active{{ end }}" href="./apiKeys">API</a>
{{ if not .IsLoginDisabled }}<a class="nav-link" href="./logout">Logout</a>{{ end }}
</nav>
</div>