Skip to content

Commit

Permalink
Get rid of FIXME and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed May 12, 2024
1 parent 6c4d92b commit dd86d89
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ func ShouldAllowUnauthenticatedGistAccess(prov AuthInfoProvider, isSingleGistAcc
if err != nil {
return false, err
}
return require != true || (isSingleGistAccess && allow == true), nil
return !require || (isSingleGistAccess && allow == true), nil

Check failure on line 17 in internal/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

S1002: should omit comparison to bool constant, can be simplified to `allow` (gosimple)

Check failure on line 17 in internal/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

S1002: should omit comparison to bool constant, can be simplified to `allow` (gosimple)
}
4 changes: 2 additions & 2 deletions internal/db/admin_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func initAdminSettings(settings map[string]string) error {

type DBAuthInfo struct{}

func (this DBAuthInfo) RequireLogin() (bool, error) {
func (auth DBAuthInfo) RequireLogin() (bool, error) {
s, err := GetSetting(SettingRequireLogin)
if err != nil {
return true, err
}
return s == "1", nil
}

func (this DBAuthInfo) AllowGistsWithoutLogin() (bool, error) {
func (auth DBAuthInfo) AllowGistsWithoutLogin() (bool, error) {
s, err := GetSetting(SettingAllowGistsWithoutLogin)
if err != nil {
return false, err
Expand Down
2 changes: 0 additions & 2 deletions internal/ssh/git_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func runGitCommand(ch ssh.Channel, gitCmd string, key string, ip string) error {
return errors.New("gist not found")
}

// FIXME: this seems to not actually work for clones, the auth process
// fails before any metadata is acquired.
allowUnauthenticated, err := auth.ShouldAllowUnauthenticatedGistAccess(db.DBAuthInfo{}, true)
if err != nil {
return errors.New("internal server error")
Expand Down
8 changes: 4 additions & 4 deletions internal/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@ type ContextAuthInfo struct {
context echo.Context
}

func (this ContextAuthInfo) RequireLogin() (bool, error) {
return getData(this.context, "RequireLogin") == true, nil
func (auth ContextAuthInfo) RequireLogin() (bool, error) {
return getData(auth.context, "RequireLogin") == true, nil
}

func (this ContextAuthInfo) AllowGistsWithoutLogin() (bool, error) {
return getData(this.context, "AllowGistsWithoutLogin") == true, nil
func (auth ContextAuthInfo) AllowGistsWithoutLogin() (bool, error) {
return getData(auth.context, "AllowGistsWithoutLogin") == true, nil
}

0 comments on commit dd86d89

Please sign in to comment.