mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
internal/directory/okta: fix wrong API query filter
Okta uses space " " instead of plus sign "+" in query filter. See https://developer.okta.com/docs/reference/api-overview/#filtering
This commit is contained in:
parent
9289de9140
commit
a4408ab6cf
3 changed files with 5 additions and 5 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
|
@ -158,7 +159,7 @@ func (p *Provider) getGroups(ctx context.Context) ([]*directory.Group, error) {
|
|||
q := u.Query()
|
||||
q.Set("limit", strconv.Itoa(p.cfg.batchSize))
|
||||
if p.lastUpdated != nil {
|
||||
q.Set("filter", fmt.Sprintf(`lastUpdated+gt+"%[1]s"+or+lastMembershipUpdated+gt+"%[1]s"`, p.lastUpdated.UTC().Format(filterDateFormat)))
|
||||
q.Set("filter", fmt.Sprintf(`lastUpdated gt "%[1]s" or lastMembershipUpdated gt "%[1]s"`, p.lastUpdated.UTC().Format(filterDateFormat)))
|
||||
} else {
|
||||
now := time.Now()
|
||||
p.lastUpdated = &now
|
||||
|
@ -258,7 +259,8 @@ func (p *Provider) apiGet(ctx context.Context, uri string, out interface{}) (htt
|
|||
continue
|
||||
}
|
||||
if res.StatusCode/100 != 2 {
|
||||
return nil, fmt.Errorf("okta: error query api status_code=%d: %s", res.StatusCode, res.Status)
|
||||
buf, _ := ioutil.ReadAll(res.Body)
|
||||
return nil, fmt.Errorf("okta: error query api status_code=%d: %s", res.StatusCode, string(buf))
|
||||
}
|
||||
if err := json.NewDecoder(res.Body).Decode(out); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -40,7 +40,7 @@ func newMockOkta(srv *httptest.Server, userEmailToGroups map[string][]string) ht
|
|||
})
|
||||
})
|
||||
r.Get("/api/v1/groups", func(w http.ResponseWriter, r *http.Request) {
|
||||
lastUpdated := strings.Contains(r.URL.Query().Get("filter"), "lastUpdated")
|
||||
lastUpdated := strings.Contains(r.URL.Query().Get("filter"), "lastUpdated ")
|
||||
var groups []string
|
||||
for group := range allGroups {
|
||||
if lastUpdated && group != "user-updated" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue