1
0
Fork 0
mirror of https://github.com/thomiceli/opengist.git synced 2025-01-24 23:00:35 +00:00
opengist/internal/auth/auth.go

19 lines
446 B
Go
Raw Normal View History

package auth
type AuthInfoProvider interface {
RequireLogin() (bool, error)
AllowGistsWithoutLogin() (bool, error)
}
func ShouldAllowUnauthenticatedGistAccess(prov AuthInfoProvider, isSingleGistAccess bool) (bool, error) {
require, err := prov.RequireLogin()
if err != nil {
return false, err
}
allow, err := prov.AllowGistsWithoutLogin()
if err != nil {
return false, err
}
return !require || (isSingleGistAccess && allow), nil
}