MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / isCollaborator

Method isCollaborator

providers/github.go:315–335  ·  view source on GitHub ↗
(ctx context.Context, username, accessToken string)

Source from the content-addressed store, hash-verified

313}
314
315func (p *GitHubProvider) isCollaborator(ctx context.Context, username, accessToken string) (bool, error) {
316 //https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
317
318 endpoint := p.makeGitHubAPIEndpoint("/repos/"+p.Repo+"/collaborators/"+username, nil)
319 result := requests.New(endpoint.String()).
320 WithContext(ctx).
321 WithHeaders(makeGitHubHeader(accessToken)).
322 Do()
323 if result.Error() != nil {
324 return false, result.Error()
325 }
326
327 if result.StatusCode() != 204 {
328 return false, fmt.Errorf("got %d from %q %s",
329 result.StatusCode(), endpoint.String(), result.Body())
330 }
331
332 logger.Printf("got %d from %q %s", result.StatusCode(), endpoint.String(), result.Body())
333
334 return true, nil
335}
336
337// getEmail updates the SessionState Email
338func (p *GitHubProvider) getEmail(ctx context.Context, s *sessions.SessionState) error {

Callers 1

getUserMethod · 0.95

Calls 11

makeGitHubAPIEndpointMethod · 0.95
NewFunction · 0.92
PrintfFunction · 0.92
makeGitHubHeaderFunction · 0.85
DoMethod · 0.65
WithHeadersMethod · 0.65
WithContextMethod · 0.65
ErrorMethod · 0.65
StatusCodeMethod · 0.65
BodyMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected