mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
Adjust import paths and service urls in index.js
This commit is contained in:
@@ -3,17 +3,19 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// AddAccount command creates a new account
|
||||
func AddAccount(cfg *config.Config) *cli.Command {
|
||||
a := &accounts.Account{
|
||||
PasswordProfile: &accounts.PasswordProfile{},
|
||||
a := &accountsmsg.Account{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{},
|
||||
}
|
||||
return &cli.Command{
|
||||
Name: "add",
|
||||
@@ -43,8 +45,8 @@ func AddAccount(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
|
||||
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
_, err := accSvc.CreateAccount(c.Context, &accounts.CreateAccountRequest{
|
||||
accSvc := accountssvc.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
_, err := accSvc.CreateAccount(c.Context, &accountssvc.CreateAccountRequest{
|
||||
Account: a,
|
||||
})
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
tw "github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -30,8 +32,8 @@ func InspectAccount(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
uid := c.Args().First()
|
||||
accSvc := accounts.NewAccountsService(accServiceID, grpc.NewClient())
|
||||
acc, err := accSvc.GetAccount(c.Context, &accounts.GetAccountRequest{
|
||||
accSvc := accountssvc.NewAccountsService(accServiceID, grpc.NewClient())
|
||||
acc, err := accSvc.GetAccount(c.Context, &accountssvc.GetAccountRequest{
|
||||
Id: uid,
|
||||
})
|
||||
|
||||
@@ -45,7 +47,7 @@ func InspectAccount(cfg *config.Config) *cli.Command {
|
||||
}}
|
||||
}
|
||||
|
||||
func buildAccountInspectTable(acc *accounts.Account) *tw.Table {
|
||||
func buildAccountInspectTable(acc *accountsmsg.Account) *tw.Table {
|
||||
table := tw.NewWriter(os.Stdout)
|
||||
table.SetAutoMergeCells(true)
|
||||
table.AppendBulk([][]string{
|
||||
|
||||
@@ -5,12 +5,14 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
tw "github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -24,8 +26,8 @@ func ListAccounts(cfg *config.Config) *cli.Command {
|
||||
Flags: flagset.ListAccountsWithConfig(cfg),
|
||||
Action: func(c *cli.Context) error {
|
||||
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
|
||||
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
resp, err := accSvc.ListAccounts(c.Context, &accounts.ListAccountsRequest{})
|
||||
accSvc := accountssvc.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
resp, err := accSvc.ListAccounts(c.Context, &accountssvc.ListAccountsRequest{})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("could not list accounts %w", err))
|
||||
@@ -38,7 +40,7 @@ func ListAccounts(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
// buildAccountsListTable creates an ascii table for printing on the cli
|
||||
func buildAccountsListTable(accs []*accounts.Account) *tw.Table {
|
||||
func buildAccountsListTable(accs []*accountsmsg.Account) *tw.Table {
|
||||
table := tw.NewWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Id", "DisplayName", "Mail", "AccountEnabled"})
|
||||
table.SetAutoFormatHeaders(false)
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
index "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
)
|
||||
@@ -20,9 +21,9 @@ func RebuildIndex(cdf *config.Config) *cli.Command {
|
||||
Aliases: []string{"rebuild", "ri"},
|
||||
Action: func(ctx *cli.Context) error {
|
||||
idxSvcID := "com.owncloud.api.accounts"
|
||||
idxSvc := index.NewIndexService(idxSvcID, grpc.NewClient())
|
||||
idxSvc := accountssvc.NewIndexService(idxSvcID, grpc.NewClient())
|
||||
|
||||
_, err := idxSvc.RebuildIndex(context.Background(), &index.RebuildIndexRequest{})
|
||||
_, err := idxSvc.RebuildIndex(context.Background(), &accountssvc.RebuildIndexRequest{})
|
||||
if err != nil {
|
||||
fmt.Println(merrors.FromError(err).Detail)
|
||||
return err
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -29,8 +30,8 @@ func RemoveAccount(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
uid := c.Args().First()
|
||||
accSvc := accounts.NewAccountsService(accServiceID, grpc.NewClient())
|
||||
_, err := accSvc.DeleteAccount(c.Context, &accounts.DeleteAccountRequest{Id: uid})
|
||||
accSvc := accountssvc.NewAccountsService(accServiceID, grpc.NewClient())
|
||||
_, err := accSvc.DeleteAccount(c.Context, &accountssvc.DeleteAccountRequest{Id: uid})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("could not delete account %w", err))
|
||||
|
||||
@@ -4,19 +4,21 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/genproto/protobuf/field_mask"
|
||||
)
|
||||
|
||||
// UpdateAccount command for modifying accounts including password policies
|
||||
func UpdateAccount(cfg *config.Config) *cli.Command {
|
||||
a := &accounts.Account{
|
||||
PasswordProfile: &accounts.PasswordProfile{},
|
||||
a := &accountsmsg.Account{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{},
|
||||
}
|
||||
return &cli.Command{
|
||||
Name: "update",
|
||||
@@ -42,8 +44,8 @@ func UpdateAccount(cfg *config.Config) *cli.Command {
|
||||
Action: func(c *cli.Context) error {
|
||||
a.Id = c.Args().First()
|
||||
accSvcID := cfg.GRPC.Namespace + "." + cfg.Service.Name
|
||||
accSvc := accounts.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
_, err := accSvc.UpdateAccount(c.Context, &accounts.UpdateAccountRequest{
|
||||
accSvc := accountssvc.NewAccountsService(accSvcID, grpc.NewClient())
|
||||
_, err := accSvc.UpdateAccount(c.Context, &accountssvc.UpdateAccountRequest{
|
||||
Account: a,
|
||||
UpdateMask: buildAccUpdateMask(c.FlagNames()),
|
||||
})
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package flagset
|
||||
|
||||
import (
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/flags"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// UpdateAccountWithConfig applies update command flags to cfg
|
||||
func UpdateAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag {
|
||||
func UpdateAccountWithConfig(cfg *config.Config, a *accountsmsg.Account) []cli.Flag {
|
||||
if a.PasswordProfile == nil {
|
||||
a.PasswordProfile = &accounts.PasswordProfile{}
|
||||
a.PasswordProfile = &accountsmsg.PasswordProfile{}
|
||||
}
|
||||
|
||||
return []cli.Flag{
|
||||
@@ -92,9 +93,9 @@ func UpdateAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag
|
||||
}
|
||||
|
||||
// AddAccountWithConfig applies create command flags to cfg
|
||||
func AddAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag {
|
||||
func AddAccountWithConfig(cfg *config.Config, a *accountsmsg.Account) []cli.Flag {
|
||||
if a.PasswordProfile == nil {
|
||||
a.PasswordProfile = &accounts.PasswordProfile{}
|
||||
a.PasswordProfile = &accountsmsg.PasswordProfile{}
|
||||
}
|
||||
|
||||
return []cli.Flag{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
@@ -21,13 +22,13 @@ func Server(opts ...Option) grpc.Service {
|
||||
grpc.Version(version.String),
|
||||
)
|
||||
|
||||
if err := proto.RegisterAccountsServiceHandler(service.Server(), handler); err != nil {
|
||||
if err := accountssvc.RegisterAccountsServiceHandler(service.Server(), handler); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register service handler")
|
||||
}
|
||||
if err := proto.RegisterGroupsServiceHandler(service.Server(), handler); err != nil {
|
||||
if err := accountssvc.RegisterGroupsServiceHandler(service.Server(), handler); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register groups handler")
|
||||
}
|
||||
if err := proto.RegisterIndexServiceHandler(service.Server(), handler); err != nil {
|
||||
if err := accountssvc.RegisterIndexServiceHandler(service.Server(), handler); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register index handler")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
chimiddleware "github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/owncloud/ocis/accounts/pkg/assets"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/account"
|
||||
"github.com/owncloud/ocis/ocis-pkg/cors"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
@@ -66,8 +67,8 @@ func Server(opts ...Option) http.Service {
|
||||
))
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
proto.RegisterAccountsServiceWeb(r, handler)
|
||||
proto.RegisterGroupsServiceWeb(r, handler)
|
||||
accountssvc.RegisterAccountsServiceWeb(r, handler)
|
||||
accountssvc.RegisterGroupsServiceWeb(r, handler)
|
||||
})
|
||||
|
||||
err := micro.RegisterHandler(service.Server(), mux)
|
||||
|
||||
@@ -16,10 +16,12 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
fieldmask_utils "github.com/mennanov/fieldmask-utils"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/accounts/pkg/storage"
|
||||
accTracing "github.com/owncloud/ocis/accounts/pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
@@ -47,13 +49,13 @@ const passwordValidCacheExpiration = 10 * time.Minute
|
||||
// login eq \"teddy\" and password eq \"F&1!b90t111!\"
|
||||
var authQuery = regexp.MustCompile(`^login eq '(.*)' and password eq '(.*)'$`) // TODO how is ' escaped in the password?
|
||||
|
||||
func (s Service) expandMemberOf(a *proto.Account) {
|
||||
func (s Service) expandMemberOf(a *accountsmsg.Account) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
expanded := []*proto.Group{}
|
||||
expanded := []*accountsmsg.Group{}
|
||||
for i := range a.MemberOf {
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
// TODO resolve by name, when a create or update is issued they may not have an id? fall back to searching the group id in the index?
|
||||
if err := s.repo.LoadGroup(context.Background(), a.MemberOf[i].Id, g); err == nil {
|
||||
g.Members = nil // always hide members when expanding
|
||||
@@ -112,8 +114,8 @@ func (s Service) serviceUserToIndex() (teardownServiceUser func()) {
|
||||
return func() {}
|
||||
}
|
||||
|
||||
func (s Service) getInMemoryServiceUser() proto.Account {
|
||||
return proto.Account{
|
||||
func (s Service) getInMemoryServiceUser() accountsmsg.Account {
|
||||
return accountsmsg.Account{
|
||||
AccountEnabled: true,
|
||||
Id: s.Config.ServiceUser.UUID,
|
||||
PreferredName: s.Config.ServiceUser.Username,
|
||||
@@ -126,7 +128,7 @@ func (s Service) getInMemoryServiceUser() proto.Account {
|
||||
|
||||
// ListAccounts implements the AccountsServiceHandler interface
|
||||
// the query contains account properties
|
||||
func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest, out *proto.ListAccountsResponse) (err error) {
|
||||
func (s Service) ListAccounts(ctx context.Context, in *accountssvc.ListAccountsRequest, out *accountssvc.ListAccountsResponse) (err error) {
|
||||
var span trace.Span
|
||||
ctx, span = accTracing.TraceProvider.Tracer("accounts").Start(ctx, "Accounts.ListAccounts")
|
||||
defer span.End()
|
||||
@@ -152,18 +154,18 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
||||
return merrors.Unauthorized(s.id, "account not found or invalid credentials")
|
||||
}
|
||||
|
||||
ids, err := s.index.FindBy(&proto.Account{}, "OnPremisesSamAccountName", match[1])
|
||||
ids, err := s.index.FindBy(&accountsmsg.Account{}, "OnPremisesSamAccountName", match[1])
|
||||
if err != nil || len(ids) > 1 {
|
||||
return merrors.Unauthorized(s.id, "account not found or invalid credentials")
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
ids, err = s.index.FindBy(&proto.Account{}, "Mail", match[1])
|
||||
ids, err = s.index.FindBy(&accountsmsg.Account{}, "Mail", match[1])
|
||||
if err != nil || len(ids) != 1 {
|
||||
return merrors.Unauthorized(s.id, "account not found or invalid credentials")
|
||||
}
|
||||
}
|
||||
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
err = s.repo.LoadAccount(ctx, ids[0], a)
|
||||
if err != nil || a.PasswordProfile == nil || len(a.PasswordProfile.Password) == 0 {
|
||||
return merrors.Unauthorized(s.id, "account not found or invalid credentials")
|
||||
@@ -211,7 +213,7 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
||||
}
|
||||
|
||||
a.PasswordProfile.Password = ""
|
||||
out.Accounts = []*proto.Account{a}
|
||||
out.Accounts = []*accountsmsg.Account{a}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -246,10 +248,10 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
||||
}
|
||||
|
||||
searchResults, err := s.findAccountsByQuery(ctx, in.Query)
|
||||
out.Accounts = make([]*proto.Account, 0, len(searchResults))
|
||||
out.Accounts = make([]*accountsmsg.Account, 0, len(searchResults))
|
||||
|
||||
for _, hit := range searchResults {
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
if hit == s.Config.ServiceUser.UUID {
|
||||
acc := s.getInMemoryServiceUser()
|
||||
a = &acc
|
||||
@@ -276,11 +278,11 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
||||
}
|
||||
|
||||
func (s Service) findAccountsByQuery(ctx context.Context, query string) ([]string, error) {
|
||||
return s.index.Query(ctx, &proto.Account{}, query)
|
||||
return s.index.Query(ctx, &accountsmsg.Account{}, query)
|
||||
}
|
||||
|
||||
// GetAccount implements the AccountsServiceHandler interface
|
||||
func (s Service) GetAccount(ctx context.Context, in *proto.GetAccountRequest, out *proto.Account) (err error) {
|
||||
func (s Service) GetAccount(ctx context.Context, in *accountssvc.GetAccountRequest, out *accountsmsg.Account) (err error) {
|
||||
var span trace.Span
|
||||
|
||||
ctx, span = accTracing.TraceProvider.Tracer("accounts").Start(ctx, "Accounts.GetAccount")
|
||||
@@ -337,7 +339,7 @@ func (s Service) GetAccount(ctx context.Context, in *proto.GetAccountRequest, ou
|
||||
}
|
||||
|
||||
// CreateAccount implements the AccountsServiceHandler interface
|
||||
func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountRequest, out *proto.Account) (err error) {
|
||||
func (s Service) CreateAccount(ctx context.Context, in *accountssvc.CreateAccountRequest, out *accountsmsg.Account) (err error) {
|
||||
var span trace.Span
|
||||
|
||||
ctx, span = accTracing.TraceProvider.Tracer("accounts").Start(ctx, "Accounts.CreateAccount")
|
||||
@@ -428,8 +430,8 @@ func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountReque
|
||||
out.GidNumber = userDefaultGID
|
||||
}
|
||||
|
||||
r := proto.ListGroupsResponse{}
|
||||
err = s.ListGroups(ctx, &proto.ListGroupsRequest{}, &r)
|
||||
r := accountssvc.ListGroupsResponse{}
|
||||
err = s.ListGroups(ctx, &accountssvc.ListGroupsRequest{}, &r)
|
||||
if err != nil {
|
||||
// rollback account creation
|
||||
return err
|
||||
@@ -464,7 +466,7 @@ func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountReque
|
||||
}
|
||||
|
||||
// rollbackCreateAccount tries to rollback changes made by `CreateAccount` if parts of it failed.
|
||||
func (s Service) rollbackCreateAccount(ctx context.Context, acc *proto.Account) {
|
||||
func (s Service) rollbackCreateAccount(ctx context.Context, acc *accountsmsg.Account) {
|
||||
err := s.index.Delete(acc)
|
||||
if err != nil {
|
||||
s.log.Err(err).Msg("failed to rollback account from indices")
|
||||
@@ -478,7 +480,7 @@ func (s Service) rollbackCreateAccount(ctx context.Context, acc *proto.Account)
|
||||
// UpdateAccount implements the AccountsServiceHandler interface
|
||||
// read only fields are ignored
|
||||
// TODO how can we unset specific values? using the update mask
|
||||
func (s Service) UpdateAccount(ctx context.Context, in *proto.UpdateAccountRequest, out *proto.Account) (err error) {
|
||||
func (s Service) UpdateAccount(ctx context.Context, in *accountssvc.UpdateAccountRequest, out *accountsmsg.Account) (err error) {
|
||||
var span trace.Span
|
||||
|
||||
ctx, span = accTracing.TraceProvider.Tracer("accounts").Start(ctx, "Accounts.UpdateAccount")
|
||||
@@ -568,7 +570,7 @@ func (s Service) UpdateAccount(ctx context.Context, in *proto.UpdateAccountReque
|
||||
|
||||
if in.Account.PasswordProfile != nil {
|
||||
if out.PasswordProfile == nil {
|
||||
out.PasswordProfile = &proto.PasswordProfile{}
|
||||
out.PasswordProfile = &accountsmsg.PasswordProfile{}
|
||||
}
|
||||
if in.Account.PasswordProfile.Password != "" {
|
||||
// encrypt password
|
||||
@@ -601,7 +603,7 @@ func (s Service) UpdateAccount(ctx context.Context, in *proto.UpdateAccountReque
|
||||
}
|
||||
|
||||
// We need to reload the old account state to be able to compute the update
|
||||
old := &proto.Account{}
|
||||
old := &accountsmsg.Account{}
|
||||
if err = s.repo.LoadAccount(ctx, id, old); err != nil {
|
||||
s.log.Error().Err(err).Str("id", out.Id).Msg("could not load old account representation during update, maybe the account got deleted meanwhile?")
|
||||
return merrors.InternalServerError(s.id, "could not load current account for update: %v", err.Error())
|
||||
@@ -653,7 +655,7 @@ var updatableAccountPaths = map[string]struct{}{
|
||||
}
|
||||
|
||||
// DeleteAccount implements the AccountsServiceHandler interface
|
||||
func (s Service) DeleteAccount(ctx context.Context, in *proto.DeleteAccountRequest, out *empty.Empty) (err error) {
|
||||
func (s Service) DeleteAccount(ctx context.Context, in *accountssvc.DeleteAccountRequest, out *empty.Empty) (err error) {
|
||||
var span trace.Span
|
||||
|
||||
ctx, span = accTracing.TraceProvider.Tracer("accounts").Start(ctx, "Accounts.DeleteAccount")
|
||||
@@ -668,7 +670,7 @@ func (s Service) DeleteAccount(ctx context.Context, in *proto.DeleteAccountReque
|
||||
return merrors.InternalServerError(s.id, "could not clean up account id: %v", err.Error())
|
||||
}
|
||||
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
if err = s.repo.LoadAccount(ctx, id, a); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "account not found: %v", err.Error())
|
||||
@@ -680,7 +682,7 @@ func (s Service) DeleteAccount(ctx context.Context, in *proto.DeleteAccountReque
|
||||
|
||||
// delete member relationship in groups
|
||||
for i := range a.MemberOf {
|
||||
err = s.RemoveMember(ctx, &proto.RemoveMemberRequest{
|
||||
err = s.RemoveMember(ctx, &accountssvc.RemoveMemberRequest{
|
||||
GroupId: a.MemberOf[i].Id,
|
||||
AccountId: id,
|
||||
}, a.MemberOf[i])
|
||||
@@ -707,7 +709,7 @@ func (s Service) DeleteAccount(ctx context.Context, in *proto.DeleteAccountReque
|
||||
return
|
||||
}
|
||||
|
||||
func validateAccount(serviceID string, a *proto.Account) error {
|
||||
func validateAccount(serviceID string, a *accountsmsg.Account) error {
|
||||
if err := validateAccountPreferredName(serviceID, a); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -720,21 +722,21 @@ func validateAccount(serviceID string, a *proto.Account) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateAccountPreferredName(serviceID string, a *proto.Account) error {
|
||||
func validateAccountPreferredName(serviceID string, a *accountsmsg.Account) error {
|
||||
if !isValidUsername(a.PreferredName) {
|
||||
return merrors.BadRequest(serviceID, "preferred_name '%s' must be at least the local part of an email", a.PreferredName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateAccountOnPremisesSamAccountName(serviceID string, a *proto.Account) error {
|
||||
func validateAccountOnPremisesSamAccountName(serviceID string, a *accountsmsg.Account) error {
|
||||
if !isValidUsername(a.OnPremisesSamAccountName) {
|
||||
return merrors.BadRequest(serviceID, "on_premises_sam_account_name '%s' must be at least the local part of an email", a.OnPremisesSamAccountName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateAccountEmail(serviceID string, a *proto.Account) error {
|
||||
func validateAccountEmail(serviceID string, a *accountsmsg.Account) error {
|
||||
if !isValidEmail(a.Mail) {
|
||||
return merrors.BadRequest(serviceID, "mail '%s' must be a valid email", a.Mail)
|
||||
}
|
||||
@@ -808,7 +810,7 @@ func validateUpdate(mask *field_mask.FieldMask, updatablePaths map[string]struct
|
||||
}
|
||||
|
||||
// debugLogAccount returns a debug-log event with detailed account-info, and filtered password data
|
||||
func (s Service) debugLogAccount(a *proto.Account) *zerolog.Event {
|
||||
func (s Service) debugLogAccount(a *accountsmsg.Account) *zerolog.Event {
|
||||
return s.log.Debug().Fields(map[string]interface{}{
|
||||
"Id": a.Id,
|
||||
"Mail": a.Mail,
|
||||
@@ -834,7 +836,7 @@ func (s Service) debugLogAccount(a *proto.Account) *zerolog.Event {
|
||||
|
||||
func (s Service) accountExists(ctx context.Context, username, mail, id string) (exists bool, err error) {
|
||||
var ids []string
|
||||
ids, err = s.index.FindBy(&proto.Account{}, "preferred_name", username)
|
||||
ids, err = s.index.FindBy(&accountsmsg.Account{}, "preferred_name", username)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -842,7 +844,7 @@ func (s Service) accountExists(ctx context.Context, username, mail, id string) (
|
||||
return true, nil
|
||||
}
|
||||
|
||||
ids, err = s.index.FindBy(&proto.Account{}, "on_premises_sam_account_name", username)
|
||||
ids, err = s.index.FindBy(&accountsmsg.Account{}, "on_premises_sam_account_name", username)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -850,7 +852,7 @@ func (s Service) accountExists(ctx context.Context, username, mail, id string) (
|
||||
return true, nil
|
||||
}
|
||||
|
||||
ids, err = s.index.FindBy(&proto.Account{}, "mail", mail)
|
||||
ids, err = s.index.FindBy(&accountsmsg.Account{}, "mail", mail)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -858,7 +860,7 @@ func (s Service) accountExists(ctx context.Context, username, mail, id string) (
|
||||
return true, nil
|
||||
}
|
||||
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
err = s.repo.LoadAccount(ctx, id, a)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
|
||||
@@ -9,9 +9,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
@@ -98,10 +100,10 @@ func TestPermissionsListAccounts(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.ListAccountsRequest{
|
||||
request := &accountssvc.ListAccountsRequest{
|
||||
Query: scenario.query,
|
||||
}
|
||||
response := &proto.ListAccountsResponse{}
|
||||
response := &accountssvc.ListAccountsResponse{}
|
||||
err := s.ListAccounts(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
@@ -145,8 +147,8 @@ func TestPermissionsGetAccount(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.GetAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
request := &accountssvc.GetAccountRequest{}
|
||||
response := &accountsmsg.Account{}
|
||||
err := s.GetAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
@@ -193,8 +195,8 @@ func TestPermissionsCreateAccount(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.CreateAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
request := &accountssvc.CreateAccountRequest{}
|
||||
response := &accountsmsg.Account{}
|
||||
err := s.CreateAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
@@ -241,8 +243,8 @@ func TestPermissionsUpdateAccount(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.UpdateAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
request := &accountssvc.UpdateAccountRequest{}
|
||||
response := &accountsmsg.Account{}
|
||||
err := s.UpdateAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
@@ -289,7 +291,7 @@ func TestPermissionsDeleteAccount(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.DeleteAccountRequest{}
|
||||
request := &accountssvc.DeleteAccountRequest{}
|
||||
response := &empty.Empty{}
|
||||
err := s.DeleteAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
|
||||
@@ -5,22 +5,24 @@ import (
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/accounts/pkg/storage"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
p "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (s Service) expandMembers(g *proto.Group) {
|
||||
func (s Service) expandMembers(g *accountsmsg.Group) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
expanded := []*proto.Account{}
|
||||
expanded := []*accountsmsg.Account{}
|
||||
for i := range g.Members {
|
||||
// TODO resolve by name, when a create or update is issued they may not have an id? fall back to searching the group id in the index?
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
if err := s.repo.LoadAccount(context.Background(), g.Members[i].Id, a); err == nil {
|
||||
expanded = append(expanded, a)
|
||||
} else {
|
||||
@@ -32,14 +34,14 @@ func (s Service) expandMembers(g *proto.Group) {
|
||||
}
|
||||
|
||||
// deflateMembers replaces the users of a group with an instance that only contains the id
|
||||
func (s Service) deflateMembers(g *proto.Group) {
|
||||
func (s Service) deflateMembers(g *accountsmsg.Group) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
deflated := []*proto.Account{}
|
||||
deflated := []*accountsmsg.Account{}
|
||||
for i := range g.Members {
|
||||
if g.Members[i].Id != "" {
|
||||
deflated = append(deflated, &proto.Account{Id: g.Members[i].Id})
|
||||
deflated = append(deflated, &accountsmsg.Account{Id: g.Members[i].Id})
|
||||
} else {
|
||||
// TODO fetch and use an id when group only has a name but no id
|
||||
s.log.Error().Str("id", g.Id).Interface("account", g.Members[i]).Msg("resolving members by name is not implemented yet")
|
||||
@@ -49,7 +51,7 @@ func (s Service) deflateMembers(g *proto.Group) {
|
||||
}
|
||||
|
||||
// ListGroups implements the GroupsServiceHandler interface
|
||||
func (s Service) ListGroups(ctx context.Context, in *proto.ListGroupsRequest, out *proto.ListGroupsResponse) (err error) {
|
||||
func (s Service) ListGroups(ctx context.Context, in *accountssvc.ListGroupsRequest, out *accountssvc.ListGroupsResponse) (err error) {
|
||||
if in.Query == "" {
|
||||
err = s.repo.LoadGroups(ctx, &out.Groups)
|
||||
if err != nil {
|
||||
@@ -68,10 +70,10 @@ func (s Service) ListGroups(ctx context.Context, in *proto.ListGroupsRequest, ou
|
||||
}
|
||||
|
||||
searchResults, err := s.findGroupsByQuery(ctx, in.Query)
|
||||
out.Groups = make([]*proto.Group, 0, len(searchResults))
|
||||
out.Groups = make([]*accountsmsg.Group, 0, len(searchResults))
|
||||
|
||||
for _, hit := range searchResults {
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
if err = s.repo.LoadGroup(ctx, hit, g); err != nil {
|
||||
s.log.Error().Err(err).Str("group", hit).Msg("could not load group, skipping")
|
||||
continue
|
||||
@@ -88,11 +90,11 @@ func (s Service) ListGroups(ctx context.Context, in *proto.ListGroupsRequest, ou
|
||||
return
|
||||
}
|
||||
func (s Service) findGroupsByQuery(ctx context.Context, query string) ([]string, error) {
|
||||
return s.index.Query(ctx, &proto.Group{}, query)
|
||||
return s.index.Query(ctx, &accountsmsg.Group{}, query)
|
||||
}
|
||||
|
||||
// GetGroup implements the GroupsServiceHandler interface
|
||||
func (s Service) GetGroup(c context.Context, in *proto.GetGroupRequest, out *proto.Group) (err error) {
|
||||
func (s Service) GetGroup(c context.Context, in *accountssvc.GetGroupRequest, out *accountsmsg.Group) (err error) {
|
||||
var id string
|
||||
if id, err = cleanupID(in.Id); err != nil {
|
||||
return merrors.InternalServerError(s.id, "could not clean up group id: %v", err.Error())
|
||||
@@ -116,7 +118,7 @@ func (s Service) GetGroup(c context.Context, in *proto.GetGroupRequest, out *pro
|
||||
}
|
||||
|
||||
// CreateGroup implements the GroupsServiceHandler interface
|
||||
func (s Service) CreateGroup(c context.Context, in *proto.CreateGroupRequest, out *proto.Group) (err error) {
|
||||
func (s Service) CreateGroup(c context.Context, in *accountssvc.CreateGroupRequest, out *accountsmsg.Group) (err error) {
|
||||
if in.Group == nil {
|
||||
return merrors.InternalServerError(s.id, "invalid group: empty")
|
||||
}
|
||||
@@ -159,7 +161,7 @@ func (s Service) CreateGroup(c context.Context, in *proto.CreateGroupRequest, ou
|
||||
}
|
||||
|
||||
// rollbackCreateGroup tries to rollback changes made by `CreateGroup` if parts of it failed.
|
||||
func (s Service) rollbackCreateGroup(ctx context.Context, group *proto.Group) {
|
||||
func (s Service) rollbackCreateGroup(ctx context.Context, group *accountsmsg.Group) {
|
||||
err := s.index.Delete(group)
|
||||
if err != nil {
|
||||
s.log.Err(err).Msg("failed to rollback group from indices")
|
||||
@@ -171,18 +173,18 @@ func (s Service) rollbackCreateGroup(ctx context.Context, group *proto.Group) {
|
||||
}
|
||||
|
||||
// UpdateGroup implements the GroupsServiceHandler interface
|
||||
func (s Service) UpdateGroup(c context.Context, in *proto.UpdateGroupRequest, out *proto.Group) (err error) {
|
||||
func (s Service) UpdateGroup(c context.Context, in *accountssvc.UpdateGroupRequest, out *accountsmsg.Group) (err error) {
|
||||
return merrors.InternalServerError(s.id, "not implemented")
|
||||
}
|
||||
|
||||
// DeleteGroup implements the GroupsServiceHandler interface
|
||||
func (s Service) DeleteGroup(c context.Context, in *proto.DeleteGroupRequest, out *empty.Empty) (err error) {
|
||||
func (s Service) DeleteGroup(c context.Context, in *accountssvc.DeleteGroupRequest, out *empty.Empty) (err error) {
|
||||
var id string
|
||||
if id, err = cleanupID(in.Id); err != nil {
|
||||
return merrors.InternalServerError(s.id, "could not clean up group id: %v", err.Error())
|
||||
}
|
||||
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
if err = s.repo.LoadGroup(c, id, g); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "group not found: %v", err.Error())
|
||||
@@ -192,7 +194,7 @@ func (s Service) DeleteGroup(c context.Context, in *proto.DeleteGroupRequest, ou
|
||||
|
||||
// delete memberof relationship in users
|
||||
for i := range g.Members {
|
||||
err = s.RemoveMember(c, &proto.RemoveMemberRequest{
|
||||
err = s.RemoveMember(c, &accountssvc.RemoveMemberRequest{
|
||||
AccountId: g.Members[i].Id,
|
||||
GroupId: id,
|
||||
}, g)
|
||||
@@ -219,7 +221,7 @@ func (s Service) DeleteGroup(c context.Context, in *proto.DeleteGroupRequest, ou
|
||||
}
|
||||
|
||||
// AddMember implements the GroupsServiceHandler interface
|
||||
func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *proto.Group) (err error) {
|
||||
func (s Service) AddMember(c context.Context, in *accountssvc.AddMemberRequest, out *accountsmsg.Group) (err error) {
|
||||
// cleanup ids
|
||||
var groupID string
|
||||
if groupID, err = cleanupID(in.GroupId); err != nil {
|
||||
@@ -232,7 +234,7 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
|
||||
}
|
||||
|
||||
// load structs
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
if err = s.repo.LoadAccount(c, accountID, a); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "group not found: %v", err.Error())
|
||||
@@ -240,7 +242,7 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
|
||||
return merrors.InternalServerError(s.id, "could not load group: %v", err.Error())
|
||||
}
|
||||
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
if err = s.repo.LoadGroup(c, groupID, g); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "could not load group: %v", err.Error())
|
||||
@@ -255,7 +257,7 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
|
||||
alreadyRelated = true
|
||||
}
|
||||
}
|
||||
aref := &proto.Account{
|
||||
aref := &accountsmsg.Account{
|
||||
Id: a.Id,
|
||||
}
|
||||
if !alreadyRelated {
|
||||
@@ -271,7 +273,7 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
|
||||
}
|
||||
}
|
||||
// only store the reference to prevent recursion when marshaling json
|
||||
gref := &proto.Group{
|
||||
gref := &accountsmsg.Group{
|
||||
Id: g.Id,
|
||||
}
|
||||
if !alreadyRelated {
|
||||
@@ -292,7 +294,7 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
|
||||
}
|
||||
|
||||
// RemoveMember implements the GroupsServiceHandler interface
|
||||
func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest, out *proto.Group) (err error) {
|
||||
func (s Service) RemoveMember(c context.Context, in *accountssvc.RemoveMemberRequest, out *accountsmsg.Group) (err error) {
|
||||
|
||||
// cleanup ids
|
||||
var groupID string
|
||||
@@ -306,7 +308,7 @@ func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest,
|
||||
}
|
||||
|
||||
// load structs
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
if err = s.repo.LoadAccount(c, accountID, a); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "could not load account: %v", err.Error())
|
||||
@@ -315,7 +317,7 @@ func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest,
|
||||
return merrors.InternalServerError(s.id, "could not load account: %v", err.Error())
|
||||
}
|
||||
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
if err = s.repo.LoadGroup(c, groupID, g); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "could not load group: %v", err.Error())
|
||||
@@ -325,7 +327,7 @@ func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest,
|
||||
}
|
||||
|
||||
//remove the account from the group if it exists
|
||||
newMembers := []*proto.Account{}
|
||||
newMembers := []*accountsmsg.Account{}
|
||||
for i := range g.Members {
|
||||
if g.Members[i].Id != a.Id {
|
||||
newMembers = append(newMembers, g.Members[i])
|
||||
@@ -334,7 +336,7 @@ func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest,
|
||||
g.Members = newMembers
|
||||
|
||||
// remove the group from the account if it exists
|
||||
newGroups := []*proto.Group{}
|
||||
newGroups := []*accountsmsg.Group{}
|
||||
for i := range a.MemberOf {
|
||||
if a.MemberOf[i].Id != g.Id {
|
||||
newGroups = append(newGroups, a.MemberOf[i])
|
||||
@@ -358,14 +360,14 @@ func (s Service) RemoveMember(c context.Context, in *proto.RemoveMemberRequest,
|
||||
}
|
||||
|
||||
// ListMembers implements the GroupsServiceHandler interface
|
||||
func (s Service) ListMembers(c context.Context, in *proto.ListMembersRequest, out *proto.ListMembersResponse) (err error) {
|
||||
func (s Service) ListMembers(c context.Context, in *accountssvc.ListMembersRequest, out *accountssvc.ListMembersResponse) (err error) {
|
||||
// cleanup ids
|
||||
var groupID string
|
||||
if groupID, err = cleanupID(in.Id); err != nil {
|
||||
return merrors.InternalServerError(s.id, "could not clean up group id: %v", err.Error())
|
||||
}
|
||||
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
if err = s.repo.LoadGroup(c, groupID, g); err != nil {
|
||||
if storage.IsNotFoundErr(err) {
|
||||
return merrors.NotFound(s.id, "group not found: %v", err.Error())
|
||||
|
||||
@@ -4,16 +4,18 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/storage"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/indexer"
|
||||
"github.com/owncloud/ocis/ocis-pkg/indexer/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/indexer/option"
|
||||
)
|
||||
|
||||
// RebuildIndex deletes all indices (in memory and on storage) and rebuilds them from scratch.
|
||||
func (s Service) RebuildIndex(ctx context.Context, request *proto.RebuildIndexRequest, response *proto.RebuildIndexResponse) error {
|
||||
func (s Service) RebuildIndex(ctx context.Context, request *accountssvc.RebuildIndexRequest, response *accountssvc.RebuildIndexResponse) error {
|
||||
if err := s.index.Reset(); err != nil {
|
||||
return fmt.Errorf("failed to delete index containers: %w", err)
|
||||
}
|
||||
@@ -36,26 +38,26 @@ func (s Service) RebuildIndex(ctx context.Context, request *proto.RebuildIndexRe
|
||||
// recreateContainers adds all indices to the indexer that we have for this service.
|
||||
func recreateContainers(idx *indexer.Indexer, cfg *config.Config) error {
|
||||
// Accounts
|
||||
if err := idx.AddIndex(&proto.Account{}, "Id", "Id", "accounts", "non_unique", nil, true); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "Id", "Id", "accounts", "non_unique", nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Account{}, "DisplayName", "Id", "accounts", "non_unique", nil, true); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "DisplayName", "Id", "accounts", "non_unique", nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := idx.AddIndex(&proto.Account{}, "Mail", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "Mail", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Account{}, "OnPremisesSamAccountName", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "OnPremisesSamAccountName", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Account{}, "PreferredName", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "PreferredName", "Id", "accounts", "unique", nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Account{}, "UidNumber", "Id", "accounts", "autoincrement", &option.Bound{
|
||||
if err := idx.AddIndex(&accountsmsg.Account{}, "UidNumber", "Id", "accounts", "autoincrement", &option.Bound{
|
||||
Lower: cfg.Index.UID.Lower,
|
||||
Upper: cfg.Index.UID.Upper,
|
||||
}, false); err != nil {
|
||||
@@ -63,15 +65,15 @@ func recreateContainers(idx *indexer.Indexer, cfg *config.Config) error {
|
||||
}
|
||||
|
||||
// Groups
|
||||
if err := idx.AddIndex(&proto.Group{}, "OnPremisesSamAccountName", "Id", "groups", "unique", nil, false); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Group{}, "OnPremisesSamAccountName", "Id", "groups", "unique", nil, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Group{}, "DisplayName", "Id", "groups", "non_unique", nil, false); err != nil {
|
||||
if err := idx.AddIndex(&accountsmsg.Group{}, "DisplayName", "Id", "groups", "non_unique", nil, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := idx.AddIndex(&proto.Group{}, "GidNumber", "Id", "groups", "autoincrement", &option.Bound{
|
||||
if err := idx.AddIndex(&accountsmsg.Group{}, "GidNumber", "Id", "groups", "autoincrement", &option.Bound{
|
||||
Lower: cfg.Index.GID.Lower,
|
||||
Upper: cfg.Index.GID.Upper,
|
||||
}, false); err != nil {
|
||||
@@ -83,7 +85,7 @@ func recreateContainers(idx *indexer.Indexer, cfg *config.Config) error {
|
||||
|
||||
// reindexDocuments loads all existing documents and adds them to the index.
|
||||
func reindexDocuments(ctx context.Context, repo storage.Repo, index *indexer.Indexer) error {
|
||||
accounts := make([]*proto.Account, 0)
|
||||
accounts := make([]*accountsmsg.Account, 0)
|
||||
if err := repo.LoadAccounts(ctx, &accounts); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -94,7 +96,7 @@ func reindexDocuments(ctx context.Context, repo storage.Repo, index *indexer.Ind
|
||||
}
|
||||
}
|
||||
|
||||
groups := make([]*proto.Group, 0)
|
||||
groups := make([]*accountsmsg.Group, 0)
|
||||
if err := repo.LoadGroups(ctx, &groups); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
idxerrs "github.com/owncloud/ocis/ocis-pkg/indexer/errors"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
oreg "github.com/owncloud/ocis/ocis-pkg/registry"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
@@ -162,7 +162,7 @@ func configFromSvc(cfg *config.Config) (*idxcfg.Config, error) {
|
||||
}
|
||||
|
||||
func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
accounts := []proto.Account{
|
||||
accounts := []accountsmsg.Account{
|
||||
{
|
||||
Id: "4c510ada-c86b-4815-8820-42cdf82c3d51",
|
||||
PreferredName: "einstein",
|
||||
@@ -171,11 +171,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Albert Einstein",
|
||||
UidNumber: 20000,
|
||||
GidNumber: 30000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$4WNffzgU/WrIRiDnwu8OnOwgOIIUqR/2Ptvp7WJAQCTSgSrylyuvC",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa"}, // users
|
||||
{Id: "6040aa17-9c64-4fef-9bd0-77234d71bad0"}, // sailing-lovers
|
||||
{Id: "dd58e5ec-842e-498b-8800-61f2ec6f911f"}, // violin-haters
|
||||
@@ -190,11 +190,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Marie Curie",
|
||||
UidNumber: 20001,
|
||||
GidNumber: 30000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$Wu2XcDnE6G2No8C88FVWluNHyXuQQi0cHzSe82Vni8AdwIO12fphC",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa"}, // users
|
||||
{Id: "7b87fd49-286e-4a5f-bafd-c535d5dd997a"}, // radium-lovers
|
||||
{Id: "cedc21aa-4072-4614-8676-fa9165f598ff"}, // polonium-lovers
|
||||
@@ -209,11 +209,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Richard Feynman",
|
||||
UidNumber: 20002,
|
||||
GidNumber: 30000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$6Lak4zh1xUkpObg2rrOotOTdQYGj2Uu/sowcVLhub.8qYIr.CxzEW",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa"}, // users
|
||||
{Id: "a1726108-01f8-4c30-88df-2b1a9d1cba1a"}, // quantum-lovers
|
||||
{Id: "167cbee2-0518-455a-bfb2-031fe0621e5d"}, // philosophy-haters
|
||||
@@ -229,11 +229,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Maurice Moss",
|
||||
UidNumber: 20003,
|
||||
GidNumber: 30000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$jvI6PHuvrimpcCHzL2Q2WOqfm1FGdYAuSYZBDahr/B48fpiFxyDy2",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa"}, // users
|
||||
},
|
||||
},
|
||||
@@ -245,11 +245,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Admin",
|
||||
UidNumber: 20004,
|
||||
GidNumber: 30000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$En9VIUtqOdDyUl.LuUq2KeuBb5A2n8zE0lkJ2v6IDRSaOamhNq6Uu",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa"}, // users
|
||||
},
|
||||
},
|
||||
@@ -262,11 +262,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Kopano IDP",
|
||||
UidNumber: 10000,
|
||||
GidNumber: 15000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2y$12$ywfGLDPsSlBTVZU0g.2GZOPO8Wap3rVOpm8e3192VlytNdGWH7x72",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "34f38767-c937-4eb6-b847-1c175829a2a0"}, // sysusers
|
||||
},
|
||||
},
|
||||
@@ -278,11 +278,11 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
DisplayName: "Reva Inter Operability Platform",
|
||||
UidNumber: 10001,
|
||||
GidNumber: 15000,
|
||||
PasswordProfile: &proto.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: "$2a$11$40xzy3rO8Tq4j2VkFbKz8Ow19BRaqaixEjAR0IbvQXxtOvMtkjwzy",
|
||||
},
|
||||
AccountEnabled: true,
|
||||
MemberOf: []*proto.Group{
|
||||
MemberOf: []*accountsmsg.Group{
|
||||
{Id: "34f38767-c937-4eb6-b847-1c175829a2a0"}, // sysusers
|
||||
},
|
||||
},
|
||||
@@ -300,7 +300,7 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
a := &proto.Account{}
|
||||
a := &accountsmsg.Account{}
|
||||
err := s.repo.LoadAccount(context.Background(), accounts[i].Id, a)
|
||||
if !storage.IsNotFoundErr(err) {
|
||||
continue // account already exists -> do not overwrite
|
||||
@@ -344,35 +344,35 @@ func (s Service) createDefaultAccounts(withDemoAccounts bool) (err error) {
|
||||
}
|
||||
|
||||
func (s Service) createDefaultGroups(withDemoGroups bool) (err error) {
|
||||
groups := []proto.Group{
|
||||
{Id: "34f38767-c937-4eb6-b847-1c175829a2a0", GidNumber: 15000, OnPremisesSamAccountName: "sysusers", DisplayName: "Technical users", Description: "A group for technical users. They should not show up in sharing dialogs.", Members: []*proto.Account{
|
||||
groups := []accountsmsg.Group{
|
||||
{Id: "34f38767-c937-4eb6-b847-1c175829a2a0", GidNumber: 15000, OnPremisesSamAccountName: "sysusers", DisplayName: "Technical users", Description: "A group for technical users. They should not show up in sharing dialogs.", Members: []*accountsmsg.Account{
|
||||
{Id: "820ba2a1-3f54-4538-80a4-2d73007e30bf"}, // idp
|
||||
{Id: "bc596f3c-c955-4328-80a0-60d018b4ad57"}, // reva
|
||||
}},
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa", GidNumber: 30000, OnPremisesSamAccountName: "users", DisplayName: "Users", Description: "A group every normal user belongs to.", Members: []*proto.Account{
|
||||
{Id: "509a9dcd-bb37-4f4f-a01a-19dca27d9cfa", GidNumber: 30000, OnPremisesSamAccountName: "users", DisplayName: "Users", Description: "A group every normal user belongs to.", Members: []*accountsmsg.Account{
|
||||
{Id: "4c510ada-c86b-4815-8820-42cdf82c3d51"}, // einstein
|
||||
{Id: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"}, // marie
|
||||
{Id: "932b4540-8d16-481e-8ef4-588e4b6b151c"}, // feynman
|
||||
}},
|
||||
{Id: "6040aa17-9c64-4fef-9bd0-77234d71bad0", GidNumber: 30001, OnPremisesSamAccountName: "sailing-lovers", DisplayName: "Sailing lovers", Members: []*proto.Account{
|
||||
{Id: "6040aa17-9c64-4fef-9bd0-77234d71bad0", GidNumber: 30001, OnPremisesSamAccountName: "sailing-lovers", DisplayName: "Sailing lovers", Members: []*accountsmsg.Account{
|
||||
{Id: "4c510ada-c86b-4815-8820-42cdf82c3d51"}, // einstein
|
||||
}},
|
||||
{Id: "dd58e5ec-842e-498b-8800-61f2ec6f911f", GidNumber: 30002, OnPremisesSamAccountName: "violin-haters", DisplayName: "Violin haters", Members: []*proto.Account{
|
||||
{Id: "dd58e5ec-842e-498b-8800-61f2ec6f911f", GidNumber: 30002, OnPremisesSamAccountName: "violin-haters", DisplayName: "Violin haters", Members: []*accountsmsg.Account{
|
||||
{Id: "4c510ada-c86b-4815-8820-42cdf82c3d51"}, // einstein
|
||||
}},
|
||||
{Id: "7b87fd49-286e-4a5f-bafd-c535d5dd997a", GidNumber: 30003, OnPremisesSamAccountName: "radium-lovers", DisplayName: "Radium lovers", Members: []*proto.Account{
|
||||
{Id: "7b87fd49-286e-4a5f-bafd-c535d5dd997a", GidNumber: 30003, OnPremisesSamAccountName: "radium-lovers", DisplayName: "Radium lovers", Members: []*accountsmsg.Account{
|
||||
{Id: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"}, // marie
|
||||
}},
|
||||
{Id: "cedc21aa-4072-4614-8676-fa9165f598ff", GidNumber: 30004, OnPremisesSamAccountName: "polonium-lovers", DisplayName: "Polonium lovers", Members: []*proto.Account{
|
||||
{Id: "cedc21aa-4072-4614-8676-fa9165f598ff", GidNumber: 30004, OnPremisesSamAccountName: "polonium-lovers", DisplayName: "Polonium lovers", Members: []*accountsmsg.Account{
|
||||
{Id: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"}, // marie
|
||||
}},
|
||||
{Id: "a1726108-01f8-4c30-88df-2b1a9d1cba1a", GidNumber: 30005, OnPremisesSamAccountName: "quantum-lovers", DisplayName: "Quantum lovers", Members: []*proto.Account{
|
||||
{Id: "a1726108-01f8-4c30-88df-2b1a9d1cba1a", GidNumber: 30005, OnPremisesSamAccountName: "quantum-lovers", DisplayName: "Quantum lovers", Members: []*accountsmsg.Account{
|
||||
{Id: "932b4540-8d16-481e-8ef4-588e4b6b151c"}, // feynman
|
||||
}},
|
||||
{Id: "167cbee2-0518-455a-bfb2-031fe0621e5d", GidNumber: 30006, OnPremisesSamAccountName: "philosophy-haters", DisplayName: "Philosophy haters", Members: []*proto.Account{
|
||||
{Id: "167cbee2-0518-455a-bfb2-031fe0621e5d", GidNumber: 30006, OnPremisesSamAccountName: "philosophy-haters", DisplayName: "Philosophy haters", Members: []*accountsmsg.Account{
|
||||
{Id: "932b4540-8d16-481e-8ef4-588e4b6b151c"}, // feynman
|
||||
}},
|
||||
{Id: "262982c1-2362-4afa-bfdf-8cbfef64a06e", GidNumber: 30007, OnPremisesSamAccountName: "physics-lovers", DisplayName: "Physics lovers", Members: []*proto.Account{
|
||||
{Id: "262982c1-2362-4afa-bfdf-8cbfef64a06e", GidNumber: 30007, OnPremisesSamAccountName: "physics-lovers", DisplayName: "Physics lovers", Members: []*accountsmsg.Account{
|
||||
{Id: "4c510ada-c86b-4815-8820-42cdf82c3d51"}, // einstein
|
||||
{Id: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"}, // marie
|
||||
{Id: "932b4540-8d16-481e-8ef4-588e4b6b151c"}, // feynman
|
||||
@@ -389,7 +389,7 @@ func (s Service) createDefaultGroups(withDemoGroups bool) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
g := &proto.Group{}
|
||||
g := &accountsmsg.Group{}
|
||||
err := s.repo.LoadGroup(context.Background(), groups[i].Id, g)
|
||||
if !storage.IsNotFoundErr(err) {
|
||||
continue // group already exists -> do not overwrite
|
||||
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/cs3org/reva/pkg/token/manager/jwt"
|
||||
"github.com/cs3org/reva/pkg/utils"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
metadatastorage "github.com/owncloud/ocis/ocis-pkg/metadata_storage"
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
@@ -69,7 +69,7 @@ func NewCS3Repo(cfg *config.Config) (Repo, error) {
|
||||
}
|
||||
|
||||
// WriteAccount writes an account via cs3 and modifies the provided account (e.g. with a generated id).
|
||||
func (r CS3Repo) WriteAccount(ctx context.Context, a *proto.Account) (err error) {
|
||||
func (r CS3Repo) WriteAccount(ctx context.Context, a *accountsmsg.Account) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -90,7 +90,7 @@ func (r CS3Repo) WriteAccount(ctx context.Context, a *proto.Account) (err error)
|
||||
}
|
||||
|
||||
// LoadAccount loads an account via cs3 by id and writes it to the provided account
|
||||
func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) (err error) {
|
||||
func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *accountsmsg.Account) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -100,7 +100,7 @@ func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) (
|
||||
}
|
||||
|
||||
// LoadAccounts loads all the accounts from the cs3 api
|
||||
func (r CS3Repo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error) {
|
||||
func (r CS3Repo) LoadAccounts(ctx context.Context, a *[]*accountsmsg.Account) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -118,7 +118,7 @@ func (r CS3Repo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err err
|
||||
|
||||
log := olog.NewLogger(olog.Pretty(r.cfg.Log.Pretty), olog.Color(r.cfg.Log.Color), olog.Level(r.cfg.Log.Level))
|
||||
for i := range res.Infos {
|
||||
acc := &proto.Account{}
|
||||
acc := &accountsmsg.Account{}
|
||||
err := r.loadAccount(ctx, filepath.Base(res.Infos[i].Path), acc)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("could not load account")
|
||||
@@ -129,7 +129,7 @@ func (r CS3Repo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r CS3Repo) loadAccount(ctx context.Context, id string, a *proto.Account) error {
|
||||
func (r CS3Repo) loadAccount(ctx context.Context, id string, a *accountsmsg.Account) error {
|
||||
account, err := r.metadataStorage.SimpleDownload(ctx, r.accountURL(id))
|
||||
if err != nil {
|
||||
if metadatastorage.IsNotFoundErr(err) {
|
||||
@@ -167,7 +167,7 @@ func (r CS3Repo) DeleteAccount(ctx context.Context, id string) (err error) {
|
||||
}
|
||||
|
||||
// WriteGroup writes a group via cs3 and modifies the provided group (e.g. with a generated id).
|
||||
func (r CS3Repo) WriteGroup(ctx context.Context, g *proto.Group) (err error) {
|
||||
func (r CS3Repo) WriteGroup(ctx context.Context, g *accountsmsg.Group) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -187,7 +187,7 @@ func (r CS3Repo) WriteGroup(ctx context.Context, g *proto.Group) (err error) {
|
||||
}
|
||||
|
||||
// LoadGroup loads a group via cs3 by id and writes it to the provided group
|
||||
func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err error) {
|
||||
func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *accountsmsg.Group) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -197,7 +197,7 @@ func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err
|
||||
}
|
||||
|
||||
// LoadGroups loads all the groups from the cs3 api
|
||||
func (r CS3Repo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error) {
|
||||
func (r CS3Repo) LoadGroups(ctx context.Context, g *[]*accountsmsg.Group) (err error) {
|
||||
ctx, err = r.getAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -215,7 +215,7 @@ func (r CS3Repo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error)
|
||||
|
||||
log := olog.NewLogger(olog.Pretty(r.cfg.Log.Pretty), olog.Color(r.cfg.Log.Color), olog.Level(r.cfg.Log.Level))
|
||||
for i := range res.Infos {
|
||||
grp := &proto.Group{}
|
||||
grp := &accountsmsg.Group{}
|
||||
err := r.loadGroup(ctx, filepath.Base(res.Infos[i].Path), grp)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("could not load account")
|
||||
@@ -226,7 +226,7 @@ func (r CS3Repo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r CS3Repo) loadGroup(ctx context.Context, id string, g *proto.Group) error {
|
||||
func (r CS3Repo) loadGroup(ctx context.Context, id string, g *accountsmsg.Group) error {
|
||||
group, err := r.metadataStorage.SimpleDownload(ctx, r.groupURL(id))
|
||||
if err != nil {
|
||||
if metadatastorage.IsNotFoundErr(err) {
|
||||
|
||||
@@ -4,8 +4,8 @@ package storage
|
||||
|
||||
//import (
|
||||
// "context"
|
||||
// accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/config"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
// "github.com/stretchr/testify/assert"
|
||||
// "testing"
|
||||
//)
|
||||
@@ -25,7 +25,7 @@ package storage
|
||||
// r, err := NewCS3Repo("hello", cfg)
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// err = r.WriteAccount(context.Background(), &proto.Account{
|
||||
// err = r.WriteAccount(context.Background(), &accountsmsg.Account{
|
||||
// Id: "fefef-egegweg-gegeg",
|
||||
// AccountEnabled: true,
|
||||
// DisplayName: "Mike Jones",
|
||||
@@ -39,14 +39,14 @@ package storage
|
||||
// r, err := NewCS3Repo("hello", cfg)
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// err = r.WriteAccount(context.Background(), &proto.Account{
|
||||
// err = r.WriteAccount(context.Background(), &accountsmsg.Account{
|
||||
// Id: "fefef-egegweg-gegeg",
|
||||
// AccountEnabled: true,
|
||||
// DisplayName: "Mike Jones",
|
||||
// Mail: "mike@example.com",
|
||||
// })
|
||||
//
|
||||
// acc := &proto.Account{}
|
||||
// acc := &accountsmsg.Account{}
|
||||
// err = r.LoadAccount(context.Background(), "fefef-egegweg-gegeg", acc)
|
||||
//
|
||||
// assert.NoError(t, err)
|
||||
@@ -59,7 +59,7 @@ package storage
|
||||
// r, err := NewCS3Repo("hello", cfg)
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// err = r.WriteAccount(context.Background(), &proto.Account{
|
||||
// err = r.WriteAccount(context.Background(), &accountsmsg.Account{
|
||||
// Id: "delete-me-id",
|
||||
// AccountEnabled: true,
|
||||
// DisplayName: "Mike Jones",
|
||||
|
||||
@@ -8,8 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
@@ -43,7 +44,7 @@ func NewDiskRepo(cfg *config.Config, log olog.Logger) DiskRepo {
|
||||
}
|
||||
|
||||
// WriteAccount to the local filesystem
|
||||
func (r DiskRepo) WriteAccount(ctx context.Context, a *proto.Account) (err error) {
|
||||
func (r DiskRepo) WriteAccount(ctx context.Context, a *accountsmsg.Account) (err error) {
|
||||
// leave only the group id
|
||||
r.deflateMemberOf(a)
|
||||
|
||||
@@ -57,7 +58,7 @@ func (r DiskRepo) WriteAccount(ctx context.Context, a *proto.Account) (err error
|
||||
}
|
||||
|
||||
// LoadAccount from the local filesystem
|
||||
func (r DiskRepo) LoadAccount(ctx context.Context, id string, a *proto.Account) (err error) {
|
||||
func (r DiskRepo) LoadAccount(ctx context.Context, id string, a *accountsmsg.Account) (err error) {
|
||||
path := filepath.Join(r.cfg.Repo.Disk.Path, accountsFolder, id)
|
||||
var data []byte
|
||||
if data, err = ioutil.ReadFile(path); err != nil {
|
||||
@@ -71,14 +72,14 @@ func (r DiskRepo) LoadAccount(ctx context.Context, id string, a *proto.Account)
|
||||
}
|
||||
|
||||
// LoadAccounts loads all the accounts from the local filesystem
|
||||
func (r DiskRepo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error) {
|
||||
func (r DiskRepo) LoadAccounts(ctx context.Context, a *[]*accountsmsg.Account) (err error) {
|
||||
root := filepath.Join(r.cfg.Repo.Disk.Path, accountsFolder)
|
||||
infos, err := ioutil.ReadDir(root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range infos {
|
||||
acc := &proto.Account{}
|
||||
acc := &accountsmsg.Account{}
|
||||
if e := r.LoadAccount(ctx, infos[i].Name(), acc); e != nil {
|
||||
r.log.Err(e).Msg("could not load account")
|
||||
continue
|
||||
@@ -101,7 +102,7 @@ func (r DiskRepo) DeleteAccount(ctx context.Context, id string) (err error) {
|
||||
}
|
||||
|
||||
// WriteGroup to the local filesystem
|
||||
func (r DiskRepo) WriteGroup(ctx context.Context, g *proto.Group) (err error) {
|
||||
func (r DiskRepo) WriteGroup(ctx context.Context, g *accountsmsg.Group) (err error) {
|
||||
// leave only the member id
|
||||
r.deflateMembers(g)
|
||||
|
||||
@@ -119,7 +120,7 @@ func (r DiskRepo) WriteGroup(ctx context.Context, g *proto.Group) (err error) {
|
||||
}
|
||||
|
||||
// LoadGroup from the local filesystem
|
||||
func (r DiskRepo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err error) {
|
||||
func (r DiskRepo) LoadGroup(ctx context.Context, id string, g *accountsmsg.Group) (err error) {
|
||||
path := filepath.Join(r.cfg.Repo.Disk.Path, groupsFolder, id)
|
||||
|
||||
groupLock.Lock()
|
||||
@@ -137,14 +138,14 @@ func (r DiskRepo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err
|
||||
}
|
||||
|
||||
// LoadGroups loads all the groups from the local filesystem
|
||||
func (r DiskRepo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error) {
|
||||
func (r DiskRepo) LoadGroups(ctx context.Context, g *[]*accountsmsg.Group) (err error) {
|
||||
root := filepath.Join(r.cfg.Repo.Disk.Path, groupsFolder)
|
||||
infos, err := ioutil.ReadDir(root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range infos {
|
||||
grp := &proto.Group{}
|
||||
grp := &accountsmsg.Group{}
|
||||
if e := r.LoadGroup(ctx, infos[i].Name(), grp); e != nil {
|
||||
r.log.Err(e).Msg("could not load group")
|
||||
continue
|
||||
@@ -167,14 +168,14 @@ func (r DiskRepo) DeleteGroup(ctx context.Context, id string) (err error) {
|
||||
}
|
||||
|
||||
// deflateMemberOf replaces the groups of a user with an instance that only contains the id
|
||||
func (r DiskRepo) deflateMemberOf(a *proto.Account) {
|
||||
func (r DiskRepo) deflateMemberOf(a *accountsmsg.Account) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
var deflated []*proto.Group
|
||||
var deflated []*accountsmsg.Group
|
||||
for i := range a.MemberOf {
|
||||
if a.MemberOf[i].Id != "" {
|
||||
deflated = append(deflated, &proto.Group{Id: a.MemberOf[i].Id})
|
||||
deflated = append(deflated, &accountsmsg.Group{Id: a.MemberOf[i].Id})
|
||||
} else {
|
||||
// TODO fetch and use an id when group only has a name but no id
|
||||
r.log.Error().Str("id", a.Id).Interface("group", a.MemberOf[i]).Msg("resolving groups by name is not implemented yet")
|
||||
@@ -184,14 +185,14 @@ func (r DiskRepo) deflateMemberOf(a *proto.Account) {
|
||||
}
|
||||
|
||||
// deflateMembers replaces the users of a group with an instance that only contains the id
|
||||
func (r DiskRepo) deflateMembers(g *proto.Group) {
|
||||
func (r DiskRepo) deflateMembers(g *accountsmsg.Group) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
var deflated []*proto.Account
|
||||
var deflated []*accountsmsg.Account
|
||||
for i := range g.Members {
|
||||
if g.Members[i].Id != "" {
|
||||
deflated = append(deflated, &proto.Account{Id: g.Members[i].Id})
|
||||
deflated = append(deflated, &accountsmsg.Account{Id: g.Members[i].Id})
|
||||
} else {
|
||||
// TODO fetch and use an id when group only has a name but no id
|
||||
r.log.Error().Str("id", g.Id).Interface("account", g.Members[i]).Msg("resolving members by name is not implemented yet")
|
||||
|
||||
@@ -3,7 +3,7 @@ package storage
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -13,12 +13,12 @@ const (
|
||||
|
||||
// Repo defines the storage operations
|
||||
type Repo interface {
|
||||
WriteAccount(ctx context.Context, a *proto.Account) (err error)
|
||||
LoadAccount(ctx context.Context, id string, a *proto.Account) (err error)
|
||||
LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error)
|
||||
WriteAccount(ctx context.Context, a *accountsmsg.Account) (err error)
|
||||
LoadAccount(ctx context.Context, id string, a *accountsmsg.Account) (err error)
|
||||
LoadAccounts(ctx context.Context, a *[]*accountsmsg.Account) (err error)
|
||||
DeleteAccount(ctx context.Context, id string) (err error)
|
||||
WriteGroup(ctx context.Context, g *proto.Group) (err error)
|
||||
LoadGroup(ctx context.Context, id string, g *proto.Group) (err error)
|
||||
LoadGroups(ctx context.Context, g *[]*proto.Group) (err error)
|
||||
WriteGroup(ctx context.Context, g *accountsmsg.Group) (err error)
|
||||
LoadGroup(ctx context.Context, id string, g *accountsmsg.Group) (err error)
|
||||
LoadGroups(ctx context.Context, g *[]*accountsmsg.Group) (err error)
|
||||
DeleteGroup(ctx context.Context, id string) (err error)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export const request = (method, url, body, queryParameters, form, config) => {
|
||||
}
|
||||
}
|
||||
/*==========================================================
|
||||
*
|
||||
*
|
||||
==========================================================*/
|
||||
/**
|
||||
* Creates an account
|
||||
@@ -33,12 +33,12 @@ export const request = (method, url, body, queryParameters, form, config) => {
|
||||
* url: AccountsService_CreateAccountURL
|
||||
* method: AccountsService_CreateAccount_TYPE
|
||||
* raw_url: AccountsService_CreateAccount_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const AccountsService_CreateAccount = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/accounts/accounts-create'
|
||||
let path = '/api/v1/accounts/accounts-create'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -56,7 +56,7 @@ export const AccountsService_CreateAccount = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const AccountsService_CreateAccount_RAW_URL = function() {
|
||||
return '/api/v0/accounts/accounts-create'
|
||||
return '/api/v1/accounts/accounts-create'
|
||||
}
|
||||
export const AccountsService_CreateAccount_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -64,7 +64,7 @@ export const AccountsService_CreateAccount_TYPE = function() {
|
||||
export const AccountsService_CreateAccountURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/accounts/accounts-create'
|
||||
let path = '/api/v1/accounts/accounts-create'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -79,12 +79,12 @@ export const AccountsService_CreateAccountURL = function(parameters = {}) {
|
||||
* url: AccountsService_DeleteAccountURL
|
||||
* method: AccountsService_DeleteAccount_TYPE
|
||||
* raw_url: AccountsService_DeleteAccount_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const AccountsService_DeleteAccount = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/accounts/accounts-delete'
|
||||
let path = '/api/v1/accounts/accounts-delete'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -102,7 +102,7 @@ export const AccountsService_DeleteAccount = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const AccountsService_DeleteAccount_RAW_URL = function() {
|
||||
return '/api/v0/accounts/accounts-delete'
|
||||
return '/api/v1/accounts/accounts-delete'
|
||||
}
|
||||
export const AccountsService_DeleteAccount_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -110,7 +110,7 @@ export const AccountsService_DeleteAccount_TYPE = function() {
|
||||
export const AccountsService_DeleteAccountURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/accounts/accounts-delete'
|
||||
let path = '/api/v1/accounts/accounts-delete'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -125,12 +125,12 @@ export const AccountsService_DeleteAccountURL = function(parameters = {}) {
|
||||
* url: AccountsService_GetAccountURL
|
||||
* method: AccountsService_GetAccount_TYPE
|
||||
* raw_url: AccountsService_GetAccount_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const AccountsService_GetAccount = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/accounts/accounts-get'
|
||||
let path = '/api/v1/accounts/accounts-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -148,7 +148,7 @@ export const AccountsService_GetAccount = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const AccountsService_GetAccount_RAW_URL = function() {
|
||||
return '/api/v0/accounts/accounts-get'
|
||||
return '/api/v1/accounts/accounts-get'
|
||||
}
|
||||
export const AccountsService_GetAccount_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -156,7 +156,7 @@ export const AccountsService_GetAccount_TYPE = function() {
|
||||
export const AccountsService_GetAccountURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/accounts/accounts-get'
|
||||
let path = '/api/v1/accounts/accounts-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -171,12 +171,12 @@ export const AccountsService_GetAccountURL = function(parameters = {}) {
|
||||
* url: AccountsService_ListAccountsURL
|
||||
* method: AccountsService_ListAccounts_TYPE
|
||||
* raw_url: AccountsService_ListAccounts_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const AccountsService_ListAccounts = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/accounts/accounts-list'
|
||||
let path = '/api/v1/accounts/accounts-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -194,7 +194,7 @@ export const AccountsService_ListAccounts = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const AccountsService_ListAccounts_RAW_URL = function() {
|
||||
return '/api/v0/accounts/accounts-list'
|
||||
return '/api/v1/accounts/accounts-list'
|
||||
}
|
||||
export const AccountsService_ListAccounts_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -202,7 +202,7 @@ export const AccountsService_ListAccounts_TYPE = function() {
|
||||
export const AccountsService_ListAccountsURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/accounts/accounts-list'
|
||||
let path = '/api/v1/accounts/accounts-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -217,12 +217,12 @@ export const AccountsService_ListAccountsURL = function(parameters = {}) {
|
||||
* url: AccountsService_UpdateAccountURL
|
||||
* method: AccountsService_UpdateAccount_TYPE
|
||||
* raw_url: AccountsService_UpdateAccount_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const AccountsService_UpdateAccount = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/accounts/accounts-update'
|
||||
let path = '/api/v1/accounts/accounts-update'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -240,7 +240,7 @@ export const AccountsService_UpdateAccount = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const AccountsService_UpdateAccount_RAW_URL = function() {
|
||||
return '/api/v0/accounts/accounts-update'
|
||||
return '/api/v1/accounts/accounts-update'
|
||||
}
|
||||
export const AccountsService_UpdateAccount_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -248,7 +248,7 @@ export const AccountsService_UpdateAccount_TYPE = function() {
|
||||
export const AccountsService_UpdateAccountURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/accounts/accounts-update'
|
||||
let path = '/api/v1/accounts/accounts-update'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -287,7 +287,7 @@ display names that include both "Test" and "String"
|
||||
export const GroupsService_ListGroups = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups'
|
||||
let path = '/v1/groups'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -311,7 +311,7 @@ export const GroupsService_ListGroups = function(parameters = {}) {
|
||||
return request('get', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_ListGroups_RAW_URL = function() {
|
||||
return '/v0/groups'
|
||||
return '/v1/groups'
|
||||
}
|
||||
export const GroupsService_ListGroups_TYPE = function() {
|
||||
return 'get'
|
||||
@@ -319,7 +319,7 @@ export const GroupsService_ListGroups_TYPE = function() {
|
||||
export const GroupsService_ListGroupsURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups'
|
||||
let path = '/v1/groups'
|
||||
if (parameters['pageSize'] !== undefined) {
|
||||
queryParameters['page_size'] = parameters['pageSize']
|
||||
}
|
||||
@@ -351,7 +351,7 @@ export const GroupsService_ListGroupsURL = function(parameters = {}) {
|
||||
export const GroupsService_CreateGroup = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups'
|
||||
let path = '/v1/groups'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -369,7 +369,7 @@ export const GroupsService_CreateGroup = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_CreateGroup_RAW_URL = function() {
|
||||
return '/v0/groups'
|
||||
return '/v1/groups'
|
||||
}
|
||||
export const GroupsService_CreateGroup_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -377,7 +377,7 @@ export const GroupsService_CreateGroup_TYPE = function() {
|
||||
export const GroupsService_CreateGroupURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups'
|
||||
let path = '/v1/groups'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -399,7 +399,7 @@ Returned by default. Inherited from directoryObject. Key. Not nullable. Read-onl
|
||||
export const GroupsService_UpdateGroup = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{group.id}'
|
||||
let path = '/v1/groups/{group.id}'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -421,7 +421,7 @@ export const GroupsService_UpdateGroup = function(parameters = {}) {
|
||||
return request('patch', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_UpdateGroup_RAW_URL = function() {
|
||||
return '/v0/groups/{group.id}'
|
||||
return '/v1/groups/{group.id}'
|
||||
}
|
||||
export const GroupsService_UpdateGroup_TYPE = function() {
|
||||
return 'patch'
|
||||
@@ -429,7 +429,7 @@ export const GroupsService_UpdateGroup_TYPE = function() {
|
||||
export const GroupsService_UpdateGroupURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{group.id}'
|
||||
let path = '/v1/groups/{group.id}'
|
||||
path = path.replace('{group.id}', `${parameters['groupId']}`)
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
@@ -445,12 +445,12 @@ export const GroupsService_UpdateGroupURL = function(parameters = {}) {
|
||||
* url: GroupsService_GetGroupURL
|
||||
* method: GroupsService_GetGroup_TYPE
|
||||
* raw_url: GroupsService_GetGroup_RAW_URL
|
||||
* @param id -
|
||||
* @param id -
|
||||
*/
|
||||
export const GroupsService_GetGroup = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{id}'
|
||||
let path = '/v1/groups/{id}'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -466,7 +466,7 @@ export const GroupsService_GetGroup = function(parameters = {}) {
|
||||
return request('get', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_GetGroup_RAW_URL = function() {
|
||||
return '/v0/groups/{id}'
|
||||
return '/v1/groups/{id}'
|
||||
}
|
||||
export const GroupsService_GetGroup_TYPE = function() {
|
||||
return 'get'
|
||||
@@ -474,7 +474,7 @@ export const GroupsService_GetGroup_TYPE = function() {
|
||||
export const GroupsService_GetGroupURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{id}'
|
||||
let path = '/v1/groups/{id}'
|
||||
path = path.replace('{id}', `${parameters['id']}`)
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
@@ -490,12 +490,12 @@ export const GroupsService_GetGroupURL = function(parameters = {}) {
|
||||
* url: GroupsService_DeleteGroupURL
|
||||
* method: GroupsService_DeleteGroup_TYPE
|
||||
* raw_url: GroupsService_DeleteGroup_RAW_URL
|
||||
* @param id -
|
||||
* @param id -
|
||||
*/
|
||||
export const GroupsService_DeleteGroup = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{id}'
|
||||
let path = '/v1/groups/{id}'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -511,7 +511,7 @@ export const GroupsService_DeleteGroup = function(parameters = {}) {
|
||||
return request('delete', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_DeleteGroup_RAW_URL = function() {
|
||||
return '/v0/groups/{id}'
|
||||
return '/v1/groups/{id}'
|
||||
}
|
||||
export const GroupsService_DeleteGroup_TYPE = function() {
|
||||
return 'delete'
|
||||
@@ -519,7 +519,7 @@ export const GroupsService_DeleteGroup_TYPE = function() {
|
||||
export const GroupsService_DeleteGroupURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{id}'
|
||||
let path = '/v1/groups/{id}'
|
||||
path = path.replace('{id}', `${parameters['id']}`)
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
@@ -536,7 +536,7 @@ export const GroupsService_DeleteGroupURL = function(parameters = {}) {
|
||||
* method: GroupsService_ListMembers_TYPE
|
||||
* raw_url: GroupsService_ListMembers_RAW_URL
|
||||
* @param id - The group id
|
||||
* @param pageSize -
|
||||
* @param pageSize -
|
||||
* @param pageToken - Optional. A pagination token returned from a previous call to `Get`
|
||||
that indicates from where search should continue.
|
||||
* @param fieldMaskPaths - The set of field mask paths.
|
||||
@@ -560,7 +560,7 @@ display names that include both "Test" and "String"
|
||||
export const GroupsService_ListMembers = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{id}/members/$ref'
|
||||
let path = '/v1/groups/{id}/members/$ref'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -588,7 +588,7 @@ export const GroupsService_ListMembers = function(parameters = {}) {
|
||||
return request('get', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_ListMembers_RAW_URL = function() {
|
||||
return '/v0/groups/{id}/members/$ref'
|
||||
return '/v1/groups/{id}/members/$ref'
|
||||
}
|
||||
export const GroupsService_ListMembers_TYPE = function() {
|
||||
return 'get'
|
||||
@@ -596,7 +596,7 @@ export const GroupsService_ListMembers_TYPE = function() {
|
||||
export const GroupsService_ListMembersURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{id}/members/$ref'
|
||||
let path = '/v1/groups/{id}/members/$ref'
|
||||
path = path.replace('{id}', `${parameters['id']}`)
|
||||
if (parameters['pageSize'] !== undefined) {
|
||||
queryParameters['page_size'] = parameters['pageSize']
|
||||
@@ -625,12 +625,12 @@ export const GroupsService_ListMembersURL = function(parameters = {}) {
|
||||
* method: GroupsService_AddMember_TYPE
|
||||
* raw_url: GroupsService_AddMember_RAW_URL
|
||||
* @param id - The account id to add
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const GroupsService_AddMember = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{id}/members/$ref'
|
||||
let path = '/v1/groups/{id}/members/$ref'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -652,7 +652,7 @@ export const GroupsService_AddMember = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_AddMember_RAW_URL = function() {
|
||||
return '/v0/groups/{id}/members/$ref'
|
||||
return '/v1/groups/{id}/members/$ref'
|
||||
}
|
||||
export const GroupsService_AddMember_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -660,7 +660,7 @@ export const GroupsService_AddMember_TYPE = function() {
|
||||
export const GroupsService_AddMemberURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{id}/members/$ref'
|
||||
let path = '/v1/groups/{id}/members/$ref'
|
||||
path = path.replace('{id}', `${parameters['id']}`)
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
@@ -682,7 +682,7 @@ export const GroupsService_AddMemberURL = function(parameters = {}) {
|
||||
export const GroupsService_RemoveMember = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/v0/groups/{id}/members/{account_id}/$ref'
|
||||
let path = '/v1/groups/{id}/members/{account_id}/$ref'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -702,7 +702,7 @@ export const GroupsService_RemoveMember = function(parameters = {}) {
|
||||
return request('delete', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const GroupsService_RemoveMember_RAW_URL = function() {
|
||||
return '/v0/groups/{id}/members/{account_id}/$ref'
|
||||
return '/v1/groups/{id}/members/{account_id}/$ref'
|
||||
}
|
||||
export const GroupsService_RemoveMember_TYPE = function() {
|
||||
return 'delete'
|
||||
@@ -710,7 +710,7 @@ export const GroupsService_RemoveMember_TYPE = function() {
|
||||
export const GroupsService_RemoveMemberURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/v0/groups/{id}/members/{account_id}/$ref'
|
||||
let path = '/v1/groups/{id}/members/{account_id}/$ref'
|
||||
path = path.replace('{id}', `${parameters['id']}`)
|
||||
path = path.replace('{account_id}', `${parameters['accountId']}`)
|
||||
if (parameters.$queryParameters) {
|
||||
@@ -720,4 +720,4 @@ export const GroupsService_RemoveMemberURL = function(parameters = {}) {
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
glauthcfg "github.com/glauth/glauth/v2/pkg/config"
|
||||
"github.com/oklog/run"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/glauth/pkg/config"
|
||||
"github.com/owncloud/ocis/glauth/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/glauth/pkg/logging"
|
||||
@@ -179,7 +180,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
// getAccountsServices returns an ocis-accounts service
|
||||
func getAccountsServices() (accounts.AccountsService, accounts.GroupsService) {
|
||||
return accounts.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient),
|
||||
accounts.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
func getAccountsServices() (accountssvc.AccountsService, accountssvc.GroupsService) {
|
||||
return accountssvc.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient),
|
||||
accountssvc.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/glauth/glauth/v2/pkg/config"
|
||||
"github.com/glauth/glauth/v2/pkg/handler"
|
||||
"github.com/glauth/glauth/v2/pkg/stats"
|
||||
ber "github.com/nmcclain/asn1-ber"
|
||||
"github.com/nmcclain/ldap"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"go-micro.dev/v4/metadata"
|
||||
@@ -27,8 +29,8 @@ const (
|
||||
)
|
||||
|
||||
type ocisHandler struct {
|
||||
as accounts.AccountsService
|
||||
gs accounts.GroupsService
|
||||
as accountssvc.AccountsService
|
||||
gs accountssvc.GroupsService
|
||||
log log.Logger
|
||||
basedn string
|
||||
nameFormat string
|
||||
@@ -86,7 +88,7 @@ func (h ocisHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (ldap.LDAP
|
||||
ctx = metadata.Set(ctx, middleware.RoleIDs, string(roleIDs))
|
||||
|
||||
// check password
|
||||
res, err := h.as.ListAccounts(ctx, &accounts.ListAccountsRequest{
|
||||
res, err := h.as.ListAccounts(ctx, &accountssvc.ListAccountsRequest{
|
||||
//Query: fmt.Sprintf("username eq '%s'", username),
|
||||
// TODO this allows looking up users when you know the username using basic auth
|
||||
// adding the password to the query is an option but sending this over the wire a la scim seems ugly
|
||||
@@ -209,7 +211,7 @@ func (h ocisHandler) Search(bindDN string, searchReq ldap.SearchRequest, conn ne
|
||||
Msg("parsed query")
|
||||
switch qtype {
|
||||
case usersQuery:
|
||||
accounts, err := h.as.ListAccounts(ctx, &accounts.ListAccountsRequest{
|
||||
accounts, err := h.as.ListAccounts(ctx, &accountssvc.ListAccountsRequest{
|
||||
Query: query,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -229,7 +231,7 @@ func (h ocisHandler) Search(bindDN string, searchReq ldap.SearchRequest, conn ne
|
||||
}
|
||||
entries = append(entries, h.mapAccounts(accounts.Accounts)...)
|
||||
case groupsQuery:
|
||||
groups, err := h.gs.ListGroups(ctx, &accounts.ListGroupsRequest{
|
||||
groups, err := h.gs.ListGroups(ctx, &accountssvc.ListGroupsRequest{
|
||||
Query: query,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -275,7 +277,7 @@ func attribute(name string, values ...string) *ldap.EntryAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
func (h ocisHandler) mapAccounts(accounts []*accounts.Account) []*ldap.Entry {
|
||||
func (h ocisHandler) mapAccounts(accounts []*accountsmsg.Account) []*ldap.Entry {
|
||||
entries := make([]*ldap.Entry, 0, len(accounts))
|
||||
for i := range accounts {
|
||||
attrs := []*ldap.EntryAttribute{
|
||||
@@ -314,7 +316,7 @@ func (h ocisHandler) mapAccounts(accounts []*accounts.Account) []*ldap.Entry {
|
||||
return entries
|
||||
}
|
||||
|
||||
func (h ocisHandler) mapGroups(groups []*accounts.Group) []*ldap.Entry {
|
||||
func (h ocisHandler) mapGroups(groups []*accountsmsg.Group) []*ldap.Entry {
|
||||
entries := make([]*ldap.Entry, 0, len(groups))
|
||||
for i := range groups {
|
||||
attrs := []*ldap.EntryAttribute{
|
||||
|
||||
@@ -3,8 +3,9 @@ package glauth
|
||||
import (
|
||||
"context"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/glauth/glauth/v2/pkg/config"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
@@ -23,8 +24,8 @@ type Options struct {
|
||||
NameFormat string
|
||||
GroupFormat string
|
||||
RoleBundleUUID string
|
||||
AccountsService accounts.AccountsService
|
||||
GroupsService accounts.GroupsService
|
||||
AccountsService accountssvc.AccountsService
|
||||
GroupsService accountssvc.GroupsService
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -102,14 +103,14 @@ func GroupFormat(val string) Option {
|
||||
}
|
||||
|
||||
// AccountsService provides an AccountsService client to set the AccountsService option.
|
||||
func AccountsService(val accounts.AccountsService) Option {
|
||||
func AccountsService(val accountssvc.AccountsService) Option {
|
||||
return func(o *Options) {
|
||||
o.AccountsService = val
|
||||
}
|
||||
}
|
||||
|
||||
// GroupsService provides an GroupsService client to set the GroupsService option.
|
||||
func GroupsService(val accounts.GroupsService) Option {
|
||||
func GroupsService(val accountssvc.GroupsService) Option {
|
||||
return func(o *Options) {
|
||||
o.GroupsService = val
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
revactx "github.com/cs3org/reva/pkg/ctx"
|
||||
"github.com/go-chi/chi/v5"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/data"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/response"
|
||||
ocstracing "github.com/owncloud/ocis/ocs/pkg/tracing"
|
||||
@@ -26,7 +28,7 @@ func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
|
||||
// short circuit if there is a user already in the context
|
||||
if u, ok := revactx.ContextGetUser(r.Context()); ok {
|
||||
@@ -50,7 +52,7 @@ func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if isValidUUID(userid) {
|
||||
account, err = o.getAccountService().GetAccount(r.Context(), &accounts.GetAccountRequest{
|
||||
account, err = o.getAccountService().GetAccount(r.Context(), &accountssvc.GetAccountRequest{
|
||||
Id: userid,
|
||||
})
|
||||
} else {
|
||||
@@ -73,7 +75,7 @@ func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {
|
||||
if account.MemberOf[i].OnPremisesSamAccountName == "" {
|
||||
o.logger.Warn().Str("groupid", account.MemberOf[i].Id).Msg("group on_premises_sam_account_name is empty, trying to lookup by id")
|
||||
// we can try to look up the name
|
||||
group, err := o.getGroupsService().GetGroup(r.Context(), &accounts.GetGroupRequest{
|
||||
group, err := o.getGroupsService().GetGroup(r.Context(), &accountssvc.GetGroupRequest{
|
||||
Id: account.MemberOf[i].Id,
|
||||
})
|
||||
|
||||
@@ -139,7 +141,7 @@ func (o Ocs) AddToGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = o.getGroupsService().AddMember(r.Context(), &accounts.AddMemberRequest{
|
||||
_, err = o.getGroupsService().AddMember(r.Context(), &accountssvc.AddMemberRequest{
|
||||
AccountId: account.Id,
|
||||
GroupId: group.Id,
|
||||
})
|
||||
@@ -192,10 +194,10 @@ func (o Ocs) RemoveFromGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
|
||||
if isValidUUID(userid) {
|
||||
account, _ = o.getAccountService().GetAccount(r.Context(), &accounts.GetAccountRequest{
|
||||
account, _ = o.getAccountService().GetAccount(r.Context(), &accountssvc.GetAccountRequest{
|
||||
Id: userid,
|
||||
})
|
||||
} else {
|
||||
@@ -225,7 +227,7 @@ func (o Ocs) RemoveFromGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = o.getGroupsService().RemoveMember(r.Context(), &accounts.RemoveMemberRequest{
|
||||
_, err = o.getGroupsService().RemoveMember(r.Context(), &accountssvc.RemoveMemberRequest{
|
||||
AccountId: account.Id,
|
||||
GroupId: group.Id,
|
||||
})
|
||||
@@ -253,7 +255,7 @@ func (o Ocs) ListGroups(w http.ResponseWriter, r *http.Request) {
|
||||
query = fmt.Sprintf("id eq '%s' or on_premises_sam_account_name eq '%s'", escapeValue(search), escapeValue(search))
|
||||
}
|
||||
|
||||
res, err := o.getGroupsService().ListGroups(r.Context(), &accounts.ListGroupsRequest{
|
||||
res, err := o.getGroupsService().ListGroups(r.Context(), &accountssvc.ListGroupsRequest{
|
||||
Query: query,
|
||||
})
|
||||
|
||||
@@ -312,13 +314,13 @@ func (o Ocs) AddGroup(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
newGroup := &accounts.Group{
|
||||
newGroup := &accountsmsg.Group{
|
||||
Id: groupid,
|
||||
DisplayName: displayname,
|
||||
OnPremisesSamAccountName: groupid,
|
||||
GidNumber: gidNumber,
|
||||
}
|
||||
group, err := o.getGroupsService().CreateGroup(r.Context(), &accounts.CreateGroupRequest{
|
||||
group, err := o.getGroupsService().CreateGroup(r.Context(), &accountssvc.CreateGroupRequest{
|
||||
Group: newGroup,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -366,7 +368,7 @@ func (o Ocs) DeleteGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = o.getGroupsService().DeleteGroup(r.Context(), &accounts.DeleteGroupRequest{
|
||||
_, err = o.getGroupsService().DeleteGroup(r.Context(), &accountssvc.DeleteGroupRequest{
|
||||
Id: group.Id,
|
||||
})
|
||||
|
||||
@@ -406,7 +408,7 @@ func (o Ocs) GetGroupMembers(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := o.getGroupsService().ListMembers(r.Context(), &accounts.ListMembersRequest{Id: group.Id})
|
||||
res, err := o.getGroupsService().ListMembers(r.Context(), &accountssvc.ListMembersRequest{Id: group.Id})
|
||||
|
||||
if err != nil {
|
||||
merr := merrors.FromError(err)
|
||||
@@ -433,9 +435,9 @@ func isValidUUID(uuid string) bool {
|
||||
return r.MatchString(uuid)
|
||||
}
|
||||
|
||||
func (o Ocs) fetchGroupByName(ctx context.Context, name string) (*accounts.Group, error) {
|
||||
var res *accounts.ListGroupsResponse
|
||||
res, err := o.getGroupsService().ListGroups(ctx, &accounts.ListGroupsRequest{
|
||||
func (o Ocs) fetchGroupByName(ctx context.Context, name string) (*accountsmsg.Group, error) {
|
||||
var res *accountssvc.ListGroupsResponse
|
||||
res, err := o.getGroupsService().ListGroups(ctx, &accountssvc.ListGroupsRequest{
|
||||
Query: fmt.Sprintf("on_premises_sam_account_name eq '%v'", escapeValue(name)),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/render"
|
||||
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/account"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
opkgm "github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
@@ -158,8 +159,8 @@ func (o Ocs) NotFound(w http.ResponseWriter, r *http.Request) {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaNotFound.StatusCode, "not found"))
|
||||
}
|
||||
|
||||
func (o Ocs) getAccountService() accounts.AccountsService {
|
||||
return accounts.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
func (o Ocs) getAccountService() accountssvc.AccountsService {
|
||||
return accountssvc.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
}
|
||||
|
||||
func (o Ocs) getCS3Backend() backend.UserBackend {
|
||||
@@ -170,8 +171,8 @@ func (o Ocs) getCS3Backend() backend.UserBackend {
|
||||
return backend.NewCS3UserBackend(nil, revaClient, o.config.MachineAuthAPIKey, o.logger)
|
||||
}
|
||||
|
||||
func (o Ocs) getGroupsService() accounts.GroupsService {
|
||||
return accounts.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
func (o Ocs) getGroupsService() accountssvc.GroupsService {
|
||||
return accountssvc.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient)
|
||||
}
|
||||
|
||||
// NotImplementedStub returns a not implemented error
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
revauser "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
@@ -21,7 +24,6 @@ import (
|
||||
"github.com/cs3org/reva/pkg/token/manager/jwt"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/google/uuid"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/data"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/response"
|
||||
ocstracing "github.com/owncloud/ocis/ocs/pkg/tracing"
|
||||
@@ -35,7 +37,7 @@ import (
|
||||
|
||||
// GetSelf returns the currently logged in user
|
||||
func (o Ocs) GetSelf(w http.ResponseWriter, r *http.Request) {
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
var err error
|
||||
u, ok := revactx.ContextGetUser(r.Context())
|
||||
if !ok || u.Id == nil || u.Id.OpaqueId == "" {
|
||||
@@ -43,7 +45,7 @@ func (o Ocs) GetSelf(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
account, err = o.getAccountService().GetAccount(r.Context(), &accounts.GetAccountRequest{
|
||||
account, err = o.getAccountService().GetAccount(r.Context(), &accountssvc.GetAccountRequest{
|
||||
Id: u.Id.OpaqueId,
|
||||
})
|
||||
|
||||
@@ -92,7 +94,7 @@ func (o Ocs) GetUser(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
|
||||
switch {
|
||||
case userid == "":
|
||||
@@ -198,12 +200,12 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
|
||||
displayname = userid
|
||||
}
|
||||
|
||||
newAccount := &accounts.Account{
|
||||
newAccount := &accountsmsg.Account{
|
||||
Id: uuid.New().String(),
|
||||
DisplayName: displayname,
|
||||
PreferredName: userid,
|
||||
OnPremisesSamAccountName: userid,
|
||||
PasswordProfile: &accounts.PasswordProfile{
|
||||
PasswordProfile: &accountsmsg.PasswordProfile{
|
||||
Password: password,
|
||||
},
|
||||
Mail: email,
|
||||
@@ -218,11 +220,11 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
|
||||
newAccount.GidNumber = gidNumber
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
account, err = o.getAccountService().CreateAccount(r.Context(), &accounts.CreateAccountRequest{
|
||||
account, err = o.getAccountService().CreateAccount(r.Context(), &accountssvc.CreateAccountRequest{
|
||||
Account: newAccount,
|
||||
})
|
||||
case "cs3":
|
||||
@@ -284,7 +286,7 @@ func (o Ocs) EditUser(w http.ResponseWriter, r *http.Request) {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
account, err = o.fetchAccountByUsername(r.Context(), userid)
|
||||
@@ -305,8 +307,8 @@ func (o Ocs) EditUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
req := accounts.UpdateAccountRequest{
|
||||
Account: &accounts.Account{
|
||||
req := accountssvc.UpdateAccountRequest{
|
||||
Account: &accountsmsg.Account{
|
||||
Id: account.Id,
|
||||
},
|
||||
}
|
||||
@@ -322,7 +324,7 @@ func (o Ocs) EditUser(w http.ResponseWriter, r *http.Request) {
|
||||
req.Account.OnPremisesSamAccountName = value
|
||||
req.UpdateMask = &fieldmaskpb.FieldMask{Paths: []string{"PreferredName", "OnPremisesSamAccountName"}}
|
||||
case "password":
|
||||
req.Account.PasswordProfile = &accounts.PasswordProfile{
|
||||
req.Account.PasswordProfile = &accountsmsg.PasswordProfile{
|
||||
Password: value,
|
||||
}
|
||||
req.UpdateMask = &fieldmaskpb.FieldMask{Paths: []string{"PasswordProfile.Password"}}
|
||||
@@ -365,7 +367,7 @@ func (o Ocs) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
account, err = o.fetchAccountByUsername(r.Context(), userid)
|
||||
@@ -486,7 +488,7 @@ func (o Ocs) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
req := accounts.DeleteAccountRequest{
|
||||
req := accountssvc.DeleteAccountRequest{
|
||||
Id: account.Id,
|
||||
}
|
||||
|
||||
@@ -507,7 +509,7 @@ func (o Ocs) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// TODO(refs) this to ocis-pkg ... we are minting tokens all over the place ... or use a service? ... like reva?
|
||||
func (o Ocs) mintTokenForUser(ctx context.Context, account *accounts.Account) (string, error) {
|
||||
func (o Ocs) mintTokenForUser(ctx context.Context, account *accountsmsg.Account) (string, error) {
|
||||
tm, _ := jwt.New(map[string]interface{}{
|
||||
"secret": o.config.TokenManager.JWTSecret,
|
||||
"expires": int64(24 * 60 * 60),
|
||||
@@ -537,7 +539,7 @@ func (o Ocs) EnableUser(w http.ResponseWriter, r *http.Request) {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
account, err = o.fetchAccountByUsername(r.Context(), userid)
|
||||
@@ -560,7 +562,7 @@ func (o Ocs) EnableUser(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
account.AccountEnabled = true
|
||||
|
||||
req := accounts.UpdateAccountRequest{
|
||||
req := accountssvc.UpdateAccountRequest{
|
||||
Account: account,
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"AccountEnabled"},
|
||||
@@ -591,7 +593,7 @@ func (o Ocs) DisableUser(w http.ResponseWriter, r *http.Request) {
|
||||
o.mustRender(w, r, response.ErrRender(data.MetaServerError.StatusCode, err.Error()))
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
account, err = o.fetchAccountByUsername(r.Context(), userid)
|
||||
@@ -614,7 +616,7 @@ func (o Ocs) DisableUser(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
account.AccountEnabled = false
|
||||
|
||||
req := accounts.UpdateAccountRequest{
|
||||
req := accountssvc.UpdateAccountRequest{
|
||||
Account: account,
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"AccountEnabled"},
|
||||
@@ -717,11 +719,11 @@ func (o Ocs) ListUsers(w http.ResponseWriter, r *http.Request) {
|
||||
query = fmt.Sprintf("on_premises_sam_account_name eq '%s'", escapeValue(search))
|
||||
}
|
||||
|
||||
var res *accounts.ListAccountsResponse
|
||||
var res *accountssvc.ListAccountsResponse
|
||||
var err error
|
||||
switch o.config.AccountBackend {
|
||||
case "accounts":
|
||||
res, err = o.getAccountService().ListAccounts(r.Context(), &accounts.ListAccountsRequest{
|
||||
res, err = o.getAccountService().ListAccounts(r.Context(), &accountssvc.ListAccountsRequest{
|
||||
Query: query,
|
||||
})
|
||||
case "cs3":
|
||||
@@ -750,9 +752,9 @@ func escapeValue(value string) string {
|
||||
return strings.ReplaceAll(value, "'", "''")
|
||||
}
|
||||
|
||||
func (o Ocs) fetchAccountByUsername(ctx context.Context, name string) (*accounts.Account, error) {
|
||||
var res *accounts.ListAccountsResponse
|
||||
res, err := o.getAccountService().ListAccounts(ctx, &accounts.ListAccountsRequest{
|
||||
func (o Ocs) fetchAccountByUsername(ctx context.Context, name string) (*accountsmsg.Account, error) {
|
||||
var res *accountssvc.ListAccountsResponse
|
||||
res, err := o.getAccountService().ListAccounts(ctx, &accountssvc.ListAccountsRequest{
|
||||
Query: fmt.Sprintf("on_premises_sam_account_name eq '%v'", escapeValue(name)),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -764,13 +766,13 @@ func (o Ocs) fetchAccountByUsername(ctx context.Context, name string) (*accounts
|
||||
return nil, merrors.NotFound("", data.MessageUserNotFound)
|
||||
}
|
||||
|
||||
func (o Ocs) fetchAccountFromCS3Backend(ctx context.Context, name string) (*accounts.Account, error) {
|
||||
func (o Ocs) fetchAccountFromCS3Backend(ctx context.Context, name string) (*accountsmsg.Account, error) {
|
||||
backend := o.getCS3Backend()
|
||||
u, _, err := backend.GetUserByClaims(ctx, "username", name, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &accounts.Account{
|
||||
return &accountsmsg.Account{
|
||||
OnPremisesSamAccountName: u.Username,
|
||||
DisplayName: u.DisplayName,
|
||||
Mail: u.Mail,
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/cs3org/reva/pkg/token/manager/jwt"
|
||||
chimiddleware "github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/justinas/alice"
|
||||
"github.com/oklog/run"
|
||||
acc "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
pkgmiddleware "github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
@@ -139,7 +140,7 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config)
|
||||
Msg("Failed to create token manager")
|
||||
}
|
||||
userProvider = backend.NewAccountsServiceUserBackend(
|
||||
acc.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient),
|
||||
accountssvc.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient),
|
||||
rolesClient,
|
||||
cfg.OIDC.Issuer,
|
||||
tokenManager,
|
||||
|
||||
@@ -132,7 +132,7 @@ func DefaultPolicies() []Policy {
|
||||
},
|
||||
// if we were using the go micro api gateway we could look up the endpoint in the registry dynamically
|
||||
{
|
||||
Endpoint: "/api/v0/accounts",
|
||||
Endpoint: "/api/v1/accounts",
|
||||
Backend: "http://localhost:9181",
|
||||
},
|
||||
// TODO the lookup needs a better mechanism
|
||||
|
||||
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
acc "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
storepb "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
@@ -29,7 +30,7 @@ type Options struct {
|
||||
// HTTPClient to use for communication with the oidcAuth provider
|
||||
HTTPClient *http.Client
|
||||
// AccountsClient for resolving accounts
|
||||
AccountsClient acc.AccountsService
|
||||
AccountsClient accountssvc.AccountsService
|
||||
// UP
|
||||
UserProvider backend.UserBackend
|
||||
// SettingsRoleService for the roles API in settings
|
||||
@@ -100,7 +101,7 @@ func HTTPClient(c *http.Client) Option {
|
||||
}
|
||||
|
||||
// AccountsClient provides a function to set the accounts client config option.
|
||||
func AccountsClient(ac acc.AccountsService) Option {
|
||||
func AccountsClient(ac accountssvc.AccountsService) Option {
|
||||
return func(o *Options) {
|
||||
o.AccountsClient = ac
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
revactx "github.com/cs3org/reva/pkg/ctx"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/oidc"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
)
|
||||
@@ -84,7 +85,7 @@ func LoadSelector(cfg *config.PolicySelector) (Selector, error) {
|
||||
if cfg.Migration != nil {
|
||||
return NewMigrationSelector(
|
||||
cfg.Migration,
|
||||
accounts.NewAccountsService("com.owncloud.accounts", grpc.NewClient())), nil
|
||||
accountssvc.NewAccountsService("com.owncloud.accounts", grpc.NewClient())), nil
|
||||
}
|
||||
|
||||
if cfg.Claims != nil {
|
||||
@@ -129,7 +130,7 @@ func NewStaticSelector(cfg *config.StaticSelectorConf) Selector {
|
||||
//
|
||||
// This selector can be used in migration-scenarios where some users have already migrated from ownCloud10 to OCIS and
|
||||
// thus have an entry in ocis-accounts. All users without accounts entry are routed to the legacy ownCloud10 instance.
|
||||
func NewMigrationSelector(cfg *config.MigrationSelectorConf, ss accounts.AccountsService) Selector {
|
||||
func NewMigrationSelector(cfg *config.MigrationSelectorConf, ss accountssvc.AccountsService) Selector {
|
||||
var acc = ss
|
||||
return func(r *http.Request) (s string, err error) {
|
||||
var claims map[string]interface{}
|
||||
@@ -144,7 +145,7 @@ func NewMigrationSelector(cfg *config.MigrationSelectorConf, ss accounts.Account
|
||||
return cfg.AccNotFoundPolicy, nil
|
||||
}
|
||||
|
||||
if _, err := acc.GetAccount(r.Context(), &accounts.GetAccountRequest{Id: userID}); err != nil {
|
||||
if _, err := acc.GetAccount(r.Context(), &accountssvc.GetAccountRequest{Id: userID}); err != nil {
|
||||
return cfg.AccNotFoundPolicy, nil
|
||||
}
|
||||
return cfg.AccFoundPolicy, nil
|
||||
|
||||
@@ -6,18 +6,20 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
"github.com/cs3org/reva/pkg/auth/scope"
|
||||
"github.com/cs3org/reva/pkg/token"
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/oidc"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// NewAccountsServiceUserBackend creates a user-provider which fetches users from the ocis accounts-service
|
||||
func NewAccountsServiceUserBackend(ac accounts.AccountsService, rs settings.RoleService, oidcISS string, tokenManager token.Manager, logger log.Logger) UserBackend {
|
||||
func NewAccountsServiceUserBackend(ac accountssvc.AccountsService, rs settings.RoleService, oidcISS string, tokenManager token.Manager, logger log.Logger) UserBackend {
|
||||
return &accountsServiceBackend{
|
||||
accountsClient: ac,
|
||||
settingsRoleService: rs,
|
||||
@@ -28,7 +30,7 @@ func NewAccountsServiceUserBackend(ac accounts.AccountsService, rs settings.Role
|
||||
}
|
||||
|
||||
type accountsServiceBackend struct {
|
||||
accountsClient accounts.AccountsService
|
||||
accountsClient accountssvc.AccountsService
|
||||
settingsRoleService settings.RoleService
|
||||
OIDCIss string
|
||||
logger log.Logger
|
||||
@@ -36,7 +38,7 @@ type accountsServiceBackend struct {
|
||||
}
|
||||
|
||||
func (a accountsServiceBackend) GetUserByClaims(ctx context.Context, claim, value string, withRoles bool) (*cs3.User, string, error) {
|
||||
var account *accounts.Account
|
||||
var account *accountsmsg.Account
|
||||
var status int
|
||||
var query string
|
||||
|
||||
@@ -109,8 +111,8 @@ func (a *accountsServiceBackend) Authenticate(ctx context.Context, username stri
|
||||
}
|
||||
|
||||
func (a accountsServiceBackend) CreateUserFromClaims(ctx context.Context, claims map[string]interface{}) (*cs3.User, error) {
|
||||
req := &accounts.CreateAccountRequest{
|
||||
Account: &accounts.Account{
|
||||
req := &accountssvc.CreateAccountRequest{
|
||||
Account: &accountsmsg.Account{
|
||||
CreationType: "LocalAccount",
|
||||
AccountEnabled: true,
|
||||
},
|
||||
@@ -155,7 +157,7 @@ func (a accountsServiceBackend) GetUserGroups(ctx context.Context, userID string
|
||||
|
||||
// accountToUser converts an owncloud account struct to a reva user struct. In the proxy
|
||||
// we work with the reva struct as a token can be minted from it.
|
||||
func (a *accountsServiceBackend) accountToUser(account *accounts.Account) *cs3.User {
|
||||
func (a *accountsServiceBackend) accountToUser(account *accountsmsg.Account) *cs3.User {
|
||||
user := &cs3.User{
|
||||
Id: &cs3.UserId{
|
||||
OpaqueId: account.Id,
|
||||
@@ -173,8 +175,8 @@ func (a *accountsServiceBackend) accountToUser(account *accounts.Account) *cs3.U
|
||||
return user
|
||||
}
|
||||
|
||||
func (a *accountsServiceBackend) getAccount(ctx context.Context, query string) (account *accounts.Account, status int) {
|
||||
resp, err := a.accountsClient.ListAccounts(ctx, &accounts.ListAccountsRequest{
|
||||
func (a *accountsServiceBackend) getAccount(ctx context.Context, query string) (account *accountsmsg.Account, status int) {
|
||||
resp, err := a.accountsClient.ListAccounts(ctx, &accountssvc.ListAccountsRequest{
|
||||
Query: query,
|
||||
PageSize: 2,
|
||||
})
|
||||
@@ -216,7 +218,7 @@ func (a *accountsServiceBackend) generateToken(ctx context.Context, u *cs3.User)
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func expandGroups(account *accounts.Account) []string {
|
||||
func expandGroups(account *accountsmsg.Account) []string {
|
||||
groups := make([]string, len(account.MemberOf))
|
||||
for i := range account.MemberOf {
|
||||
// reva needs the unix group name
|
||||
|
||||
Reference in New Issue
Block a user