Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Direct access to rules map when getting auth provider (cs3org#3028)
Browse files Browse the repository at this point in the history
* direct access to rules map when getting auth provider

* add changelog
  • Loading branch information
gmgigi96 authored Nov 29, 2022
1 parent 79a7d13 commit 01676fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/auth-registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Access directly auth registry rules map when getting provider

https://github.com/cs3org/reva/pull/3028
14 changes: 6 additions & 8 deletions pkg/auth/registry/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type reg struct {
}

func (r *reg) ListProviders(ctx context.Context) ([]*registrypb.ProviderInfo, error) {
providers := []*registrypb.ProviderInfo{}
providers := make([]*registrypb.ProviderInfo, len(r.rules))
for k, v := range r.rules {
providers = append(providers, &registrypb.ProviderInfo{
ProviderType: k,
Expand All @@ -61,13 +61,11 @@ func (r *reg) ListProviders(ctx context.Context) ([]*registrypb.ProviderInfo, er
}

func (r *reg) GetProvider(ctx context.Context, authType string) (*registrypb.ProviderInfo, error) {
for k, v := range r.rules {
if k == authType {
return &registrypb.ProviderInfo{
ProviderType: k,
Address: v,
}, nil
}
if address, ok := r.rules[authType]; ok {
return &registrypb.ProviderInfo{
ProviderType: authType,
Address: address,
}, nil
}
return nil, errtypes.NotFound("static: auth type not found: " + authType)
}
Expand Down

0 comments on commit 01676fe

Please sign in to comment.