wisski-cloud-distillery/internal/dis/component/auth/scopes/instances.go
2023-11-02 12:05:13 +01:00

37 lines
798 B
Go

package scopes
import (
"net/http"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
)
type ListInstancesScope struct {
component.Base
dependencies struct {
Auth *auth.Auth
}
}
var (
_ component.ScopeProvider = (*ListInstancesScope)(nil)
)
const (
ScopeInstanceDirectory Scope = "instances.directory"
)
func (*ListInstancesScope) Scope() component.ScopeInfo {
return component.ScopeInfo{
Scope: ScopeInstanceDirectory,
Description: "get a public directory of instances",
DeniedMessage: "",
TakesParam: false,
}
}
func (lis *ListInstancesScope) HasScope(param string, r *http.Request) (bool, error) {
_, user, err := lis.dependencies.Auth.SessionOf(r)
return user != nil, err
}