Add API for resolver
This commit is contained in:
parent
4f4fa2b3d7
commit
3ef9c23a0c
7 changed files with 98 additions and 7 deletions
|
|
@ -32,7 +32,6 @@ func (*ListInstancesScope) Scope() component.ScopeInfo {
|
|||
}
|
||||
|
||||
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
|
||||
_, user, err := lis.Dependencies.Auth.SessionOf(r)
|
||||
return user != nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,6 @@ func (*ListNewsScope) Scope() component.ScopeInfo {
|
|||
}
|
||||
|
||||
func (lns *ListNewsScope) HasScope(param string, r *http.Request) (bool, error) {
|
||||
// TODO: at the moment everyone has this permission
|
||||
return true, nil
|
||||
_, user, err := lns.Dependencies.Auth.SessionOf(r)
|
||||
return user != nil, err
|
||||
}
|
||||
|
|
|
|||
37
internal/dis/component/auth/scopes/resolver.go
Normal file
37
internal/dis/component/auth/scopes/resolver.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 ResolverScope struct {
|
||||
component.Base
|
||||
Dependencies struct {
|
||||
Auth *auth.Auth
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ component.ScopeProvider = (*ResolverScope)(nil)
|
||||
)
|
||||
|
||||
const (
|
||||
ScopeResolver Scope = "url.resolve"
|
||||
)
|
||||
|
||||
func (*ResolverScope) Scope() component.ScopeInfo {
|
||||
return component.ScopeInfo{
|
||||
Scope: ScopeResolver,
|
||||
Description: "resolve a URI to a URL to display it in",
|
||||
DeniedMessage: "",
|
||||
TakesParam: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (rs *ResolverScope) HasScope(param string, r *http.Request) (bool, error) {
|
||||
_, user, err := rs.Dependencies.Auth.SessionOf(r)
|
||||
return user != nil, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue