- Notifications
You must be signed in to change notification settings - Fork1k
chore: add api endpoints to get idp field values#16063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LG, some minor tweaks
codersdk/idpsync.go Outdated
} | ||
func (c*Client)GetIDPSyncFieldValues(ctx context.Context,claimFieldstring) ([]string,error) { | ||
res,err:=c.Request(ctx,http.MethodGet,fmt.Sprintf("/api/v2/settings/idpsync/field-values?claimField=%s",claimField),nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
claimField=%s
will not url encode special characters.
res,err:=c.Request(ctx,http.MethodGet,fmt.Sprintf("/api/v2/settings/idpsync/field-values?claimField=%s",claimField),nil) | |
qv:=url.Values{} | |
qv.Add("claimField",claimField) | |
res,err:=c.Request(ctx,http.MethodGet,fmt.Sprintf("/api/v2/settings/idpsync/field-values?%s",qv.Encode()),nil) |
enterprise/coderd/idpsync.go Outdated
ctx:=r.Context() | ||
fields,err:=api.Database.OIDCClaimFieldValues(ctx, database.OIDCClaimFieldValuesParams{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
just do theclaimField
parsing in here.
ctx:=r.Context() | |
fields,err:=api.Database.OIDCClaimFieldValues(ctx, database.OIDCClaimFieldValuesParams{ | |
ctx:=r.Context() | |
claimField:=r.URL.Query().Get("claimField") | |
fields,err:=api.Database.OIDCClaimFieldValues(ctx, database.OIDCClaimFieldValuesParams{ |
Also you should defend against an empty string here.
if claimField == "" {httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{Message: "claimField query parameter is required",})return}
6ca1e59
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Supportscoder/internal#210