Implement basic API scoping

This commit is contained in:
Tom 2023-05-04 15:13:51 +02:00
parent 064ae2f564
commit 9db53d39c4
21 changed files with 519 additions and 264 deletions

View file

@ -0,0 +1,38 @@
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) {
// TODO: at the moment everyone has this permission
// this should change in the future!
return true, nil
}