Rename userBackend to identityBackend

This is suppoosed to handle Groups and Users so adjust the Name
This commit is contained in:
Ralf Haferkamp
2021-11-25 14:51:52 +01:00
parent fbdcdf255c
commit 76390f3d4f
4 changed files with 14 additions and 14 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ import (
msgraph "github.com/yaegashi/msgraph.go/beta"
)
type Users interface {
type Backend interface {
GetUser(ctx context.Context, nameOrId string) (*msgraph.User, error)
GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.User, error)
}
+4 -4
View File
@@ -13,10 +13,10 @@ import (
// Graph defines implements the business logic for Service.
type Graph struct {
config *config.Config
mux *chi.Mux
logger *log.Logger
userBackend identity.Users
config *config.Config
mux *chi.Mux
logger *log.Logger
identityBackend identity.Backend
}
// ServeHTTP implements the Service interface.
+7 -7
View File
@@ -25,24 +25,24 @@ func NewService(opts ...Option) Service {
m := chi.NewMux()
m.Use(options.Middleware...)
var userBackend identity.Users
var backend identity.Backend
switch options.Config.Identity.Backend {
case "cs3":
userBackend = &identity.CS3{
backend = &identity.CS3{
Config: &options.Config.Reva,
Logger: &options.Logger,
}
case "ldap":
userBackend = identity.NewLDAPBackend(options.Config.Identity.LDAP, &options.Logger)
backend = identity.NewLDAPBackend(options.Config.Identity.LDAP, &options.Logger)
default:
options.Logger.Error().Msgf("Unknown Identity Backend: '%s'", options.Config.Identity.Backend)
}
svc := Graph{
config: options.Config,
mux: m,
logger: &options.Logger,
userBackend: userBackend,
config: options.Config,
mux: m,
logger: &options.Logger,
identityBackend: backend,
}
m.Route(options.Config.HTTP.Root, func(r chi.Router) {
+2 -2
View File
@@ -33,7 +33,7 @@ func (g Graph) GetMe(w http.ResponseWriter, r *http.Request) {
// GetUsers implements the Service interface.
// TODO use cs3 api to look up user
func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
users, err := g.userBackend.GetUsers(r.Context(), r.URL.Query())
users, err := g.identityBackend.GetUsers(r.Context(), r.URL.Query())
if err != nil {
var errcode errorcode.Error
if errors.As(err, &errcode) {
@@ -54,7 +54,7 @@ func (g Graph) GetUser(w http.ResponseWriter, r *http.Request) {
return
}
user, err := g.userBackend.GetUser(r.Context(), userID)
user, err := g.identityBackend.GetUser(r.Context(), userID)
if err != nil {
var errcode errorcode.Error