Skip to content

Commit

Permalink
Send app instance index when checking ssh_access from CC
Browse files Browse the repository at this point in the history
[#103827886]

Signed-off-by: Andrew Edgar <[email protected]>
  • Loading branch information
jfmyers9 authored and andrew-edgar committed Sep 23, 2015
1 parent b88aead commit bcca109
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions authenticators/cf_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (cfa *CFAuthenticator) Authenticate(metadata ssh.ConnMetadata, password []b
return nil, err
}

processGuid, err := cfa.checkAccess(logger, appGuid, string(cred))
processGuid, err := cfa.checkAccess(logger, appGuid, index, string(cred))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,8 +128,8 @@ func (cfa *CFAuthenticator) exchangeAccessCodeForToken(logger lager.Logger, code
return fmt.Sprintf("%s %s", tokenResponse.TokenType, tokenResponse.AccessToken), nil
}

func (cfa *CFAuthenticator) checkAccess(logger lager.Logger, appGuid string, token string) (string, error) {
path := fmt.Sprintf("%s/internal/apps/%s/ssh_access", cfa.ccURL, appGuid)
func (cfa *CFAuthenticator) checkAccess(logger lager.Logger, appGuid string, index int, token string) (string, error) {
path := fmt.Sprintf("%s/internal/apps/%s/ssh_access/%d", cfa.ccURL, appGuid, index)

req, err := http.NewRequest("GET", path, nil)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions authenticators/cf_authenticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("CFAuthenticator", func() {

fakeCC.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access"),
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access/1"),
ghttp.VerifyHeader(http.Header{"Authorization": []string{"bearer exchanged-token"}}),
ghttp.RespondWithJSONEncodedPtr(&sshAccessResponseCode, sshAccessResponse),
),
Expand Down Expand Up @@ -220,8 +220,8 @@ var _ = Describe("CFAuthenticator", func() {

Context("when the cc ssh_access response cannot be parsed", func() {
BeforeEach(func() {
fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access", ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access"),
fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access/1", ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access/1"),
ghttp.VerifyHeader(http.Header{"Authorization": []string{"bearer exchanged-token"}}),
ghttp.RespondWith(http.StatusOK, "{{"),
))
Expand All @@ -236,7 +236,7 @@ var _ = Describe("CFAuthenticator", func() {
Context("the the cc ssh_access check times out", func() {
BeforeEach(func() {
ccTempClientTimeout := httpClientTimeout
fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access",
fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access/1",
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(ccTempClientTimeout * 2)
w.Write([]byte(`[]`))
Expand Down
4 changes: 2 additions & 2 deletions cmd/ssh-proxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ var _ = Describe("SSH proxy", func() {
}),
))

fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access", ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access"),
fakeCC.RouteToHandler("GET", "/internal/apps/app-guid/ssh_access/99", ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/internal/apps/app-guid/ssh_access/99"),
ghttp.VerifyHeader(http.Header{"Authorization": []string{"bearer proxy-token"}}),
ghttp.RespondWithJSONEncoded(http.StatusOK, authenticators.AppSSHResponse{
ProcessGuid: processGuid,
Expand Down

0 comments on commit bcca109

Please sign in to comment.