• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mindersec / minder / 13912518563

18 Mar 2025 12:19AM UTC coverage: 56.561% (+0.006%) from 56.555%
13912518563

Pull #5518

github

web-flow
Merge 4b09b9980 into a1767e80d
Pull Request #5518: build(deps): bump github.com/containerd/containerd from 1.7.25 to 1.7.27 in /tools

18177 of 32137 relevant lines covered (56.56%)

37.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/auth/oauth.go
1
// SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
package auth
5

6
import (
7
        "context"
8
        "fmt"
9
        "net/http"
10

11
        go_github "github.com/google/go-github/v63/github"
12
        "github.com/spf13/viper"
13
)
14

15
const (
16
        // Github OAuth2 provider
17
        Github = "github"
18
)
19

20
// NewProviderHttpClient creates a new http client for the given provider
21
func NewProviderHttpClient(provider string) *http.Client {
×
22
        if provider == Github {
×
23
                hClient := &http.Client{
×
24
                        Transport: &go_github.BasicAuthTransport{
×
25
                                Username: viper.GetString(fmt.Sprintf("%s.client_id", provider)),
×
26
                                Password: viper.GetString(fmt.Sprintf("%s.client_secret", provider)),
×
27
                        },
×
28
                }
×
29
                return hClient
×
30
        }
×
31
        return nil
×
32
}
33

34
// DeleteAccessToken deletes the access token for a given provider
35
func DeleteAccessToken(ctx context.Context, provider string, token string) error {
×
36
        hClient := NewProviderHttpClient(provider)
×
37
        if hClient == nil {
×
38
                return fmt.Errorf("invalid provider: %s", provider)
×
39
        }
×
40

41
        client := go_github.NewClient(hClient)
×
42
        client_id := viper.GetString(fmt.Sprintf("%s.client_id", provider))
×
43
        _, err := client.Authorizations.Revoke(ctx, client_id, token)
×
44

×
45
        if err != nil {
×
46
                return err
×
47
        }
×
48
        return nil
×
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc