Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ocm auth manager #5101

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-ocm-auth-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Fix ocm auth manager

OCM auth manager had the Gatewayselector caching issue

https://github.com/cs3org/reva/pull/5101
17 changes: 11 additions & 6 deletions pkg/auth/manager/ocmshares/ocmshares.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func init() {
}

type manager struct {
c *config
gw gateway.GatewayAPIClient
c *config
gateway *pool.Selector[gateway.GatewayAPIClient]
}

type config struct {
Expand All @@ -64,11 +64,11 @@ func New(m map[string]interface{}) (auth.Manager, error) {
if err := mgr.Configure(m); err != nil {
return nil, err
}
gw, err := pool.GetGatewayServiceClient(mgr.c.GatewayAddr)
gw, err := pool.GatewaySelector(mgr.c.GatewayAddr)
if err != nil {
return nil, err
}
mgr.gw = gw
mgr.gateway = gw

return &mgr, nil
}
Expand All @@ -84,8 +84,13 @@ func (m *manager) Configure(ml map[string]interface{}) error {

func (m *manager) Authenticate(ctx context.Context, ocmshare, sharedSecret string) (*userpb.User, map[string]*authpb.Scope, error) {
log := appctx.GetLogger(ctx).With().Str("ocmshare", ocmshare).Logger()
gwc, err := m.gateway.Next()
if err != nil {
return nil, nil, err
}

// We need to use GetOCMShareByToken, as GetOCMShare would require a user in the context
shareRes, err := m.gw.GetOCMShareByToken(ctx, &ocm.GetOCMShareByTokenRequest{
shareRes, err := gwc.GetOCMShareByToken(ctx, &ocm.GetOCMShareByTokenRequest{
Token: sharedSecret,
})

Expand Down Expand Up @@ -128,7 +133,7 @@ func (m *manager) Authenticate(ctx context.Context, ocmshare, sharedSecret strin
},
}

userRes, err := m.gw.GetAcceptedUser(ctx, &ocminvite.GetAcceptedUserRequest{
userRes, err := gwc.GetAcceptedUser(ctx, &ocminvite.GetAcceptedUserRequest{
RemoteUserId: u,
Opaque: o,
})
Expand Down
Loading