mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-13 16:24:16 +02:00
* directory: add explicit RefreshUser endpoint for faster sync * add test * implement azure * update api call * add test for azure User * implement github * implement AccessToken, gitlab * implement okta * implement onelogin * fix test * fix inconsistent test * implement auth0
32 lines
879 B
Go
32 lines
879 B
Go
// Package databroker contains databroker protobuf definitions.
|
|
package databroker
|
|
|
|
import "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
|
|
if offset < len(records) {
|
|
records = records[offset:]
|
|
} else {
|
|
records = nil
|
|
}
|
|
if limit <= len(records) {
|
|
records = records[:limit]
|
|
}
|
|
return records, len(all)
|
|
}
|