Skip to content

Commit

Permalink
Add machine auth API key to ocs service
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Sep 21, 2021
1 parent 08c51ee commit b54471d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ocs/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Config struct {
AccountBackend string
RevaAddress string
StorageUsersDriver string
MachineAuthAPIKey string
IdentityManagement IdentityManagement

Context context.Context
Expand Down
7 changes: 7 additions & 0 deletions ocs/pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"OCS_REVA_GATEWAY_ADDR"},
Destination: &cfg.RevaAddress,
},
&cli.StringFlag{
Name: "machine-auth-api-key",
Value: flags.OverrideDefaultString(cfg.MachineAuthAPIKey, "change-me-please"),
Usage: "the API key to be used for the machine auth driver in reva",
EnvVars: []string{"OCS_MACHINE_AUTH_API_KEY"},
Destination: &cfg.MachineAuthAPIKey,
},
&cli.StringFlag{
Name: "idm-address",
Value: flags.OverrideDefaultString(cfg.IdentityManagement.Address, "https://localhost:9200"),
Expand Down
2 changes: 1 addition & 1 deletion ocs/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (o Ocs) getCS3Backend() backend.UserBackend {
if err != nil {
o.logger.Fatal().Msgf("could not get reva client at address %s", o.config.RevaAddress)
}
return backend.NewCS3UserBackend(revaClient, nil, revaClient, o.logger)
return backend.NewCS3UserBackend(nil, revaClient, o.config.MachineAuthAPIKey, o.logger)
}

func (o Ocs) getGroupsService() accounts.GroupsService {
Expand Down
2 changes: 1 addition & 1 deletion ocs/pkg/service/v0/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ func (o Ocs) fetchAccountByUsername(ctx context.Context, name string) (*accounts

func (o Ocs) fetchAccountFromCS3Backend(ctx context.Context, name string) (*accounts.Account, error) {
backend := o.getCS3Backend()
u, err := backend.GetUserByClaims(ctx, "username", name, false)
u, _, err := backend.GetUserByClaims(ctx, "username", name, false)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b54471d

Please sign in to comment.