Skip to content

Commit d0ddf74

Browse files
authored
Merge pull request #6 from adohkan/5_IAPFix
[5] Fix for IAP Auth Issues
2 parents 1eca4b6 + 6e61039 commit d0ddf74

File tree

4 files changed

+397
-82
lines changed

4 files changed

+397
-82
lines changed

cmd/git-remote-https+iap/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func execute(cmd *cobra.Command, args []string) {
9292
remote, url := args[0], args[1]
9393
log.Debug().Msgf("%s %s %s", binaryName, remote, url)
9494

95-
handleIAPAuthCookieFor(url)
96-
git.PassThruRemoteHTTPSHelper(remote, url)
95+
c := handleIAPAuthCookieFor(url)
96+
git.PassThruRemoteHTTPSHelper(remote, url, c.Token.Raw)
9797
}
9898

9999
func check(cmd *cobra.Command, args []string) {
@@ -147,7 +147,7 @@ func configureIAP(cmd *cobra.Command, args []string) {
147147
git.SetGlobalConfig(https, "http", "cookieFile", cookiePath)
148148
}
149149

150-
func handleIAPAuthCookieFor(url string) {
150+
func handleIAPAuthCookieFor(url string) *iap.Cookie {
151151
// All our work will be based on the basedomain of the provided URL
152152
// as IAP would be setup for the whole domain.
153153
url, err := toHTTPSBaseDomain(url)
@@ -172,6 +172,8 @@ func handleIAPAuthCookieFor(url string) {
172172
if err != nil {
173173
log.Fatal().Msg(err.Error())
174174
}
175+
176+
return cookie
175177
}
176178

177179
func toHTTPSBaseDomain(addr string) (string, error) {

go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ go 1.17
44

55
require (
66
github.com/dgrijalva/jwt-go v3.2.0+incompatible
7-
github.com/int128/oauth2cli v1.10.0
8-
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
9-
github.com/rs/zerolog v1.18.0
10-
github.com/spf13/cobra v0.0.6
7+
github.com/int128/oauth2cli v1.14.0
8+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
9+
github.com/rs/zerolog v1.26.1
10+
github.com/spf13/cobra v1.3.0
1111
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
12-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
12+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
1313
)
1414

1515
require (
16-
cloud.google.com/go v0.65.0 // indirect
16+
cloud.google.com/go v0.99.0 // indirect
1717
github.com/golang/protobuf v1.5.2 // indirect
1818
github.com/inconshreveable/mousetrap v1.0.0 // indirect
19-
github.com/int128/listener v1.0.0 // indirect
20-
github.com/spf13/pflag v1.0.3 // indirect
21-
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
22-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
19+
github.com/int128/listener v1.1.0 // indirect
20+
github.com/spf13/pflag v1.0.5 // indirect
21+
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
22+
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
2323
google.golang.org/appengine v1.6.7 // indirect
2424
google.golang.org/protobuf v1.27.1 // indirect
2525
)

0 commit comments

Comments
 (0)