Implement basic API scoping
This commit is contained in:
parent
064ae2f564
commit
9db53d39c4
21 changed files with 519 additions and 264 deletions
37
internal/dis/component/auth/scopes/news.go
Normal file
37
internal/dis/component/auth/scopes/news.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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 ListNewsScope struct {
|
||||
component.Base
|
||||
Dependencies struct {
|
||||
Auth *auth.Auth
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ component.ScopeProvider = (*ListNewsScope)(nil)
|
||||
)
|
||||
|
||||
const (
|
||||
ScopeListNews Scope = "news.list"
|
||||
)
|
||||
|
||||
func (*ListNewsScope) Scope() component.ScopeInfo {
|
||||
return component.ScopeInfo{
|
||||
Scope: ScopeListNews,
|
||||
Description: "list news items",
|
||||
DeniedMessage: "",
|
||||
TakesParam: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (lns *ListNewsScope) HasScope(param string, r *http.Request) (bool, error) {
|
||||
// TODO: at the moment everyone has this permission
|
||||
return true, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue