API: Move handling of HTTP auth headers to pkg/header #808 #3943 #3959

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2024-01-09 10:58:47 +01:00
parent 881bc4cb28
commit 3e924b70c7
21 changed files with 234 additions and 158 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/photoprism/photoprism/internal/server/limiter"
"github.com/photoprism/photoprism/pkg/authn"
"github.com/photoprism/photoprism/pkg/clean"
"github.com/photoprism/photoprism/pkg/header"
"github.com/photoprism/photoprism/pkg/rnd"
)
@@ -39,7 +40,7 @@ func CreateOAuthToken(router *gin.RouterGroup) {
var f form.ClientCredentials
// Allow authentication with basic auth and form values.
if clientId, clientSecret, _ := BasicAuth(c); clientId != "" && clientSecret != "" {
if clientId, clientSecret, _ := header.BasicAuth(c); clientId != "" && clientSecret != "" {
f.ClientID = clientId
f.ClientSecret = clientSecret
} else if err = c.Bind(&f); err != nil {