Implement basic API scoping
This commit is contained in:
parent
064ae2f564
commit
9db53d39c4
21 changed files with 519 additions and 264 deletions
38
internal/dis/component/auth/scopes/instances.go
Normal file
38
internal/dis/component/auth/scopes/instances.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue