mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
* pass in roomserver API so that we have access to the db * interface to get db info for spaceid and channelid * determine space or channel by querying the room db * Add authorization check to the JOIN endpoint * fix lint errors
25 lines
707 B
Go
25 lines
707 B
Go
package authorization
|
|
|
|
import (
|
|
"github.com/matrix-org/dendrite/authorization"
|
|
roomserver "github.com/matrix-org/dendrite/roomserver/api"
|
|
"github.com/matrix-org/dendrite/setup/config"
|
|
"github.com/matrix-org/dendrite/zion"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func NewAuthorization(cfg *config.ClientAPI, rsAPI roomserver.ClientRoomserverAPI) authorization.Authorization {
|
|
// Load authorization manager for Zion
|
|
if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz {
|
|
auth, err := zion.NewZionAuthorization(rsAPI)
|
|
|
|
if err != nil {
|
|
log.Errorln("Failed to initialise Zion authorization manager. Using default.", err)
|
|
} else {
|
|
return auth
|
|
}
|
|
}
|
|
|
|
return &authorization.DefaultAuthorization{}
|
|
}
|