-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graph: Pass parsed odata request to the identity backend
In preparation for some more advanced queries pass the parse odata request tVo the identity backend methods instead of the raw url.Values{}. This also add some helpers for validating $expand and $search queries to reject some unsupported queries. Also remove support for `$select=memberOf` and `$select=drive|drives` queries and stick to the technically correct `$expand=...`.
- Loading branch information
Showing
8 changed files
with
176 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package identity | ||
|
||
import "github.com/CiscoM31/godata" | ||
|
||
// GetExpandValues extracts the values of the $expand query parameter and | ||
// returns them in a []string, rejects any $expand value that consists of more | ||
// than just a single path segment | ||
func GetExpandValues(req *godata.GoDataQuery) ([]string, error) { | ||
if req == nil || req.Expand == nil { | ||
return []string{}, nil | ||
} | ||
expand := make([]string, 0, len(req.Expand.ExpandItems)) | ||
for _, item := range req.Expand.ExpandItems { | ||
if item.Filter != nil || item.At != nil || item.Search != nil || | ||
item.OrderBy != nil || item.Skip != nil || item.Top != nil || | ||
item.Select != nil || item.Compute != nil || item.Expand != nil || | ||
item.Levels != 0 { | ||
return []string{}, godata.NotImplementedError("options for $expand not supported") | ||
} | ||
if len(item.Path) > 1 { | ||
return []string{}, godata.NotImplementedError("multiple segments in $expand not supported") | ||
} | ||
expand = append(expand, item.Path[0].Value) | ||
} | ||
return expand, nil | ||
} | ||
|
||
// GetSearchValues extracts the value of the $search query parameter and returns | ||
// it as a string. Rejects any search query that is more than just a simple string | ||
func GetSearchValues(req *godata.GoDataQuery) (string, error) { | ||
if req == nil || req.Search == nil { | ||
return "", nil | ||
} | ||
|
||
// Only allow simple search queries for now | ||
if len(req.Search.Tree.Children) != 0 { | ||
return "", godata.NotImplementedError("complex search queries are not supported") | ||
} | ||
|
||
return req.Search.Tree.Token.Value, nil | ||
} |
Oops, something went wrong.