MCPcopy Index your code
hub / github.com/coder/coder / RevokeToken

Method RevokeToken

coderd/externalauth/externalauth.go:583–609  ·  view source on GitHub ↗
(ctx context.Context, link database.ExternalAuthLink)

Source from the content-addressed store, hash-verified

581}
582
583func (c *Config) RevokeToken(ctx context.Context, link database.ExternalAuthLink) (bool, error) {
584 if c.RevokeURL == "" {
585 return false, nil
586 }
587
588 reqCtx, cancel := context.WithTimeout(ctx, c.RevokeTimeout)
589 defer cancel()
590 req, err := c.TokenRevocationRequest(reqCtx, link)
591 if err != nil {
592 return false, err
593 }
594
595 res, err := c.InstrumentedOAuth2Config.Do(ctx, promoauth.SourceRevoke, req)
596 if err != nil {
597 return false, err
598 }
599 defer res.Body.Close()
600 body, err := io.ReadAll(res.Body)
601 if err != nil {
602 return false, err
603 }
604
605 if c.TokenRevocationResponseOk(res) {
606 return true, nil
607 }
608 return false, xerrors.Errorf("failed to revoke token: %d %s", res.StatusCode, string(body))
609}
610
611func (c *Config) TokenRevocationRequest(ctx context.Context, link database.ExternalAuthLink) (*http.Request, error) {
612 if c.Type == codersdk.EnhancedExternalAuthProviderGitHub.String() {

Callers 2

TestRevokeTokenFunction · 0.95

Calls 6

DoMethod · 0.65
CloseMethod · 0.65
ReadAllMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestRevokeTokenFunction · 0.76