directory: remove provider from user id (#2068)

This commit is contained in:
Caleb Doxsey 2021-04-07 15:06:08 -06:00 committed by GitHub
parent a51c7140ea
commit aeb8aaf9cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 71 additions and 104 deletions

View file

@ -5,23 +5,8 @@ import (
"context"
"fmt"
"io"
"strings"
)
// GetUserID gets the databroker user id from a provider user id.
func GetUserID(provider, providerUserID string) string {
return provider + "/" + providerUserID
}
// FromUserID gets the provider and provider user id from a databroker user id.
func FromUserID(userID string) (provider, providerUserID string) {
ps := strings.SplitN(userID, "/", 2)
if len(ps) < 2 {
return "", userID
}
return ps[0], ps[1]
}
// ApplyOffsetAndLimit applies the offset and limit to the list of records.
func ApplyOffsetAndLimit(all []*Record, offset, limit int) (records []*Record, totalCount int) {
records = all

View file

@ -27,10 +27,10 @@ const (
// we rely on transactions in redis, so all redis-cluster keys need to be
// on the same node. Using a `hash tag` gives us this capability.
lastVersionKey = "{pomerium}.last_version"
lastVersionChKey = "{pomerium}.last_version_ch"
recordHashKey = "{pomerium}.records"
changesSetKey = "{pomerium}.changes"
lastVersionKey = "{pomerium_v2}.last_version"
lastVersionChKey = "{pomerium_v2}.last_version_ch"
recordHashKey = "{pomerium_v2}.records"
changesSetKey = "{pomerium_v2}.changes"
)
// custom errors