Add basic username/password authentication

This commit is contained in:
WithoutPants
2019-07-28 19:36:52 +10:00
parent 4f016ab3c9
commit 5a891d00cf
18 changed files with 1043 additions and 11 deletions

View File

@@ -3,10 +3,11 @@ package api
import (
"context"
"fmt"
"path/filepath"
"github.com/stashapp/stash/pkg/manager/config"
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/utils"
"path/filepath"
)
func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.ConfigGeneralInput) (*models.ConfigGeneralResult, error) {
@@ -35,6 +36,20 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co
config.Set(config.Generated, input.GeneratedPath)
}
if input.Username != nil {
config.Set(config.Username, input.Username)
}
if input.Password != nil {
// bit of a hack - check if the passed in password is the same as the stored hash
// and only set if they are different
currentPWHash := config.GetPasswordHash()
if *input.Password != currentPWHash {
config.SetPassword(*input.Password)
}
}
if err := config.Write(); err != nil {
return makeConfigGeneralResult(), err
}