dendrite/clientapi/authorization/authorization.go
Tak Wai Wong 04a78694d1
Authorization framework for gating dendrite endpoints (#39)
* import new versions of the zion contracts

* bootstrap zion authz

* define interface for space manager contract

* instantiate spacemanager interface

* load goerli and localhost

* embed json

* remove zion interface. Use contracts directly

* split user identifiter into address and chain id

* isAllowed in routing.go

* remove permission.go

Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
2022-10-24 21:24:35 -07:00

24 lines
604 B
Go

package authorization
import (
"github.com/matrix-org/dendrite/authorization"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/zion"
log "github.com/sirupsen/logrus"
)
func NewAuthorization(cfg *config.ClientAPI) authorization.Authorization {
// Load authorization manager for Zion
if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz {
auth, err := zion.NewZionAuthorization()
if err != nil {
log.Errorln("Failed to initialise Zion authorization manager. Using default.", err)
} else {
return auth
}
}
return &authorization.DefaultAuthorization{}
}