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

Method hasUser

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

Source from the content-addressed store, hash-verified

288}
289
290func (p *GitHubProvider) hasUser(ctx context.Context, accessToken string) (bool, error) {
291 // https://developer.github.com/v3/users/#get-the-authenticated-user
292
293 var user struct {
294 Login string `json:"login"`
295 Email string `json:"email"`
296 }
297
298 endpoint := p.makeGitHubAPIEndpoint("/user", nil)
299
300 err := requests.New(endpoint.String()).
301 WithContext(ctx).
302 WithHeaders(makeGitHubHeader(accessToken)).
303 Do().
304 UnmarshalInto(&user)
305 if err != nil {
306 return false, err
307 }
308
309 if p.isVerifiedUser(user.Login) {
310 return true, nil
311 }
312 return false, nil
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

Callers 1

checkUserRestrictionMethod · 0.95

Calls 9

makeGitHubAPIEndpointMethod · 0.95
isVerifiedUserMethod · 0.95
NewFunction · 0.92
makeGitHubHeaderFunction · 0.85
UnmarshalIntoMethod · 0.65
DoMethod · 0.65
WithHeadersMethod · 0.65
WithContextMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected