Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Merge lyft flyte #155

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5014bba
OAuth workaround for L5 (#60)
wild-endeavor Feb 3, 2020
b7ea1f8
Use host matching for L5 OAuth workaround (#62)
wild-endeavor Feb 3, 2020
f23975c
Merge branch 'master' into Lyft-Flyte
katrogan Feb 3, 2020
787edbc
need to special case the callback logic too (#64)
wild-endeavor Feb 4, 2020
82671f3
Merge branch 'master' into Lyft-Flyte
katrogan Feb 4, 2020
ccd6f53
Merge remote-tracking branch 'origin/master' into Lyft-Flyte
Feb 6, 2020
03565cf
Merge branch 'master' into Lyft-Flyte
katrogan Feb 10, 2020
1e68322
Merge branch 'Lyft-Flyte' of github.com:lyft/flyteadmin into Lyft-Flyte
katrogan Feb 10, 2020
9cd0c3c
Merge branch 'master' into Lyft-Flyte
katrogan Feb 13, 2020
6b4fd0a
Merge branch 'latest_master' into latest_merge
anandswaminathan Feb 28, 2020
138752e
Merge branch 'latest_master' into latest_merge
anandswaminathan Mar 6, 2020
cb5ede1
Merge remote-tracking branch 'origin/master' into Lyft-Flyte
Mar 9, 2020
e4560ed
Merge branch 'master' into Lyft-Flyte
katrogan Mar 10, 2020
bd5c585
Merge branch 'Lyft-Flyte' of github.com:lyft/flyteadmin into Lyft-Flyte
katrogan Mar 10, 2020
31fd6a5
Merge branch 'master' into Lyft-Flyte
katrogan Mar 13, 2020
8331766
Merge branch 'master' into Lyft-Flyte
katrogan Mar 16, 2020
1090c6b
Merge branch 'master' into Lyft-Flyte
katrogan Mar 18, 2020
d611bac
Merge branch 'master' into Lyft-Flyte
katrogan Mar 30, 2020
9e038ac
Merge branch 'master' into Lyft-Flyte
katrogan Apr 2, 2020
a538b2e
Merge branch 'newb' into latest_merge
anandswaminathan Apr 6, 2020
ece6781
Merge branch 'master' into Lyft-Flyte
katrogan Apr 7, 2020
85386a1
Merge branch 'master' into Lyft-Flyte
katrogan Apr 20, 2020
539d401
Merge branch 'master' into Lyft-Flyte
katrogan Apr 23, 2020
424af21
Merge branch 'master' into Lyft-Flyte
katrogan Apr 24, 2020
6a72a7a
Merge branch 'master' into Lyft-Flyte
May 4, 2020
d65d53b
[do not use] Raise gRPC limit to 16 MB (#100)
wild-endeavor May 29, 2020
6cbedc2
Merge branch 'master' into Lyft-Flyte
katrogan Jun 4, 2020
9cc1057
Removing Gopkg
katrogan Jun 4, 2020
867f69a
Merge branch 'master' of github.com:lyft/flyteadmin into lyft-flyte
EngHabu Jun 18, 2020
33f5cae
Merge remote-tracking branch 'origin/master' into Lyft-Flyte
Jun 24, 2020
0705030
Merge branch 'master' into Lyft-Flyte
katrogan Jun 30, 2020
db34f3c
Merge branch 'master' into Lyft-Flyte
Jul 30, 2020
4186ed5
Merge remote-tracking branch 'origin/master' into Lyft-Flyte
Jul 30, 2020
e3b4758
Merge branch 'Lyft-Flyte' of github.com:lyft/flyteadmin into Lyft-Flyte
Jul 30, 2020
70d19fe
Merge branch 'master' of github.com:lyft/flyteadmin into Lyft-Flyte
EngHabu Aug 12, 2020
e2c0f51
Merge branch 'master' into Lyft-Flyte
katrogan Aug 12, 2020
84a4337
Merge branch 'master' into latest_merge
anandswaminathan Aug 14, 2020
a0d8121
Merge branch 'master' of github.com:lyft/flyteadmin into Lyft-Flyte
katrogan Aug 19, 2020
23cb9d3
Merge branch 'Lyft-Flyte' of github.com:lyft/flyteadmin into Lyft-Flyte
katrogan Aug 19, 2020
1742782
Merge branch 'master' into Lyft-Flyte
katrogan Aug 19, 2020
9cd682d
Merge branch 'master' into Lyft-Flyte
schottra Sep 8, 2020
27cb574
Merge remote-tracking branch 'origin/master' into Lyft-Flyte
schottra Sep 8, 2020
85296b2
Merge branch 'master' into Lyft-Flyte
katrogan Oct 12, 2020
cd655bd
Double header limit size
katrogan Nov 11, 2020
69fd84d
Merge in master
katrogan Nov 13, 2020
068b0ab
Merge branch 'master' into Lyft-Flyte
katrogan Nov 23, 2020
d65105c
Merge branch 'master' into latest_merge
anandswaminathan Mar 3, 2021
0d1cc1d
Fixes for L5
anandswaminathan Mar 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/entrypoints/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import (
"google.golang.org/grpc/reflection"
)

const SixteenMegabytes int = 16777216 // 16 * 2^20
const SixteenKibibytes uint32 = 16384 // 16 * 2^10

var defaultCorsHeaders = []string{"Content-Type"}

// serveCmd represents the serve command
Expand Down Expand Up @@ -217,6 +220,7 @@ func serveGatewayInsecure(ctx context.Context, cfg *config.ServerConfig) error {

logger.Infof(ctx, "Starting HTTP/1 Gateway server on %s", cfg.GetHostAddress())
httpServer, err := newHTTPServer(ctx, cfg, authContext, cfg.GetGrpcHostAddress(), grpc.WithInsecure(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(SixteenMegabytes)),
grpc.WithMaxHeaderListSize(common.MaxResponseStatusBytes))
if err != nil {
return err
Expand Down
13 changes: 13 additions & 0 deletions pkg/auth/auth_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,16 @@ func GetOauth2Config(options config.OAuthOptions) (oauth2.Config, error) {
},
}, nil
}

func GetL5Oauth2Config(mainConfig *oauth2.Config) oauth2.Config {
return oauth2.Config{
RedirectURL: "https://flyte-rs.av.lyft.net/callback",
ClientID: mainConfig.ClientID,
ClientSecret: mainConfig.ClientSecret,
Scopes: mainConfig.Scopes,
Endpoint: oauth2.Endpoint{
AuthURL: mainConfig.Endpoint.AuthURL,
TokenURL: mainConfig.Endpoint.TokenURL,
},
}
}
32 changes: 27 additions & 5 deletions pkg/auth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"time"

"github.com/lyft/flyteadmin/pkg/audit"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/lyft/flytestdlib/contextutils"
"github.com/lyft/flytestdlib/errors"
"github.com/lyft/flytestdlib/logger"
"golang.org/x/oauth2"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -65,6 +67,7 @@ func RefreshTokensIfExists(ctx context.Context, authContext interfaces.Authentic
}

func GetLoginHandler(ctx context.Context, authContext interfaces.AuthenticationContext) http.HandlerFunc {
l5OauthConfig := GetL5Oauth2Config(authContext.OAuth2Config())
return func(writer http.ResponseWriter, request *http.Request) {
csrfCookie := NewCsrfCookie()
csrfToken := csrfCookie.Value
Expand All @@ -74,6 +77,13 @@ func GetLoginHandler(ctx context.Context, authContext interfaces.AuthenticationC
logger.Debugf(ctx, "Setting CSRF state cookie to %s and state to %s\n", csrfToken, state)
url := authContext.OAuth2Config().AuthCodeURL(state)
queryParams := request.URL.Query()

// Special hack for L5 to last til the end of Q1
if strings.Contains(request.Host, "flyte-rs.av.lyft.net") {
logger.Debugf(ctx, "Changing the callback in the /authorize call to point to L5")
url = l5OauthConfig.AuthCodeURL(state)
}

if flowEndRedirectURL := queryParams.Get(RedirectURLParameter); flowEndRedirectURL != "" {
redirectCookie := NewRedirectCookie(ctx, flowEndRedirectURL)
if redirectCookie != nil {
Expand All @@ -87,6 +97,7 @@ func GetLoginHandler(ctx context.Context, authContext interfaces.AuthenticationC
}

func GetCallbackHandler(ctx context.Context, authContext interfaces.AuthenticationContext) http.HandlerFunc {
l5OauthConfig := GetL5Oauth2Config(authContext.OAuth2Config())
return func(writer http.ResponseWriter, request *http.Request) {
logger.Debugf(ctx, "Running callback handler...")
authorizationCode := request.FormValue(AuthorizationResponseCodeType)
Expand All @@ -98,11 +109,22 @@ func GetCallbackHandler(ctx context.Context, authContext interfaces.Authenticati
return
}

token, err := authContext.OAuth2Config().Exchange(ctx, authorizationCode)
if err != nil {
logger.Errorf(ctx, "Error when exchanging code %s", err)
writer.WriteHeader(http.StatusForbidden)
return
var token *oauth2.Token
// Additional hacks for L5
if strings.Contains(request.Host, "flyte-rs.av.lyft.net") {
token, err = l5OauthConfig.Exchange(ctx, authorizationCode)
if err != nil {
logger.Errorf(ctx, "Error when exchanging code %s", err)
writer.WriteHeader(http.StatusForbidden)
return
}
} else {
token, err = authContext.OAuth2Config().Exchange(ctx, authorizationCode)
if err != nil {
logger.Errorf(ctx, "Error when exchanging code %s", err)
writer.WriteHeader(http.StatusForbidden)
return
}
}

err = authContext.CookieManager().SetTokenCookies(ctx, writer, token)
Expand Down