Skip to content

Commit

Permalink
Allow authing using repo-scoped token
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Apr 27, 2024
1 parent 6d9afc5 commit be0b2dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/auth/github/pat.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ type identity struct {
}

func (pa *PATAuthenticator) Authenticate(secret string, s *terraform.State) (bool, error) {
// check access to repo that matches project in org
_, err := makeRequest(fmt.Sprintf("https://api.github.com/repos/%s/%s", pa.org, s.Project), secret)
if err == nil {
// allow when there is no error
return true, nil
}

// check if org matches username
resp, err := makeRequest("https://api.github.com/user", secret)
if err != nil {
Expand Down

0 comments on commit be0b2dd

Please sign in to comment.