Use 202 for token polling endpoint instead of 204 (#1103)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-04-12 14:57:14 -04:00
1 parent 71673ea161
commit 90b30bad25
6 files changed
+585 -684

No files matched your search

@@ -16,6 +16,7 @@ import (
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
"github.com/hashicorp/boundary/internal/types/action"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/types/known/structpb"
)
const (
@@ -25,7 +26,8 @@ const (
tokenCommand = "token"
// token request/response fields
tokenField = "token"
tokenField = "token"
statusField = "status"
// field names
issuerField = "attributes.issuer"
@@ -269,7 +271,16 @@ func (s Service) authenticateOidcToken(ctx context.Context, req *pbs.Authenticat
}
}
if token == nil {
return nil, nil
attrs, err := structpb.NewStruct(map[string]interface{}{
statusField: "unknown",
})
if err != nil {
return nil, errors.New(errors.Internal, op, "Error generating response attributes.")
}
return &pbs.AuthenticateResponse{
Command: req.Command,
Attributes: attrs,
}, nil
}
responseToken, err := s.convertInternalAuthTokenToApiAuthToken(
@@ -17,6 +17,7 @@ const (
JsVisibleCookieName = "wt-js-token-cookie"
tokenTypeField = "token_type"
finalRedirectUrlField = "final_redirect_url"
statusField = "status"
)
func OutgoingInterceptor(ctx context.Context, w http.ResponseWriter, m proto.Message) error {
@@ -34,6 +35,15 @@ func OutgoingInterceptor(ctx context.Context, w http.ResponseWriter, m proto.Mes
return nil
}
fields := m.GetAttributes().GetFields()
if m.GetCommand() == "token" {
if _, ok := fields[statusField]; ok {
// For now at least status will never be anything useful so
// don't need to check on it; the mere presence is enough to
// know what to do
w.WriteHeader(http.StatusAccepted)
return nil
}
}
// It's a redirect
if urlField, ok := fields[finalRedirectUrlField]; ok {
u := urlField.GetStringValue()