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

Auth cookie domain #440

Merged
merged 6 commits into from
Jun 7, 2022
Merged

Auth cookie domain #440

merged 6 commits into from
Jun 7, 2022

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Jun 6, 2022

TL;DR

Allow user of flyteadmin to specify the cookie settings of there flyteadmin user auth cookies
Allowing subdomain access by setting the domain field in the cookie
and allowing to set SameSite preference to allow firstparty or thirdparty cookies to be sent from the browser.

Mode changes are applicable for only the following cookies

  • flyte_at
  • flyte_idt
  • flyte_user_info

One thing i noticed is that dot prefix gets subsituted by the browser seems like .

A cover domain should not contain a leading dot, like in .cats.com; if it does, the client should remove the leading dot.

source : http://bayou.io/draft/cookie.domain.html

So i didn't find any behavior change with domain setting policy for localhost or hosted.cloud-staging.union.ai

Testing done :

With LAX mode for auth cookies

Screenshot 2022-06-07 at 5 10 37 PM

With Strict mode for auth cookies

Screenshot 2022-06-07 at 5 09 17 PM

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

Remove the 'fixes' keyword if there will be multiple PRs to fix the linked issue

fixes flyteorg/flyte#2596

Follow-up issue

NA

Copy link
Contributor

@EngHabu EngHabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! thank you for doing that! a couple of nits

auth/config/config.go Outdated Show resolved Hide resolved
if !c.coverSubDomains {
return ""
}
return fmt.Sprintf(".%s", request.URL.Hostname())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I guess this works because this is an HTTP request not a GRPC request...

Have you tried it behind an ingress? mind doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this both with grpc endpoints through flytectl and through flyteconsole and no issues were discovered

}

type CookieSettings struct {
SameSite http.SameSite `json:"sameSite" pflag:",OPTIONAL: Allows you to declare if your cookie should be restricted to a first-party or same-site context."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this parse well from a yaml config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does if we pass int values. But added an enum wrapper for good UX.

ursucarina
ursucarina previously approved these changes Jun 6, 2022
@pmahindrakar-oss pmahindrakar-oss changed the title WIP : Auth cookie domain Auth cookie domain Jun 7, 2022
Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: Prafulla Mahindrakar <[email protected]>
@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #440 (bd08dcd) into master (6e03bd4) will increase coverage by 0.04%.
The diff coverage is 67.77%.

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
+ Coverage   61.35%   61.39%   +0.04%     
==========================================
  Files         156      158       +2     
  Lines       11111    11181      +70     
==========================================
+ Hits         6817     6865      +48     
- Misses       3589     3607      +18     
- Partials      705      709       +4     
Flag Coverage Δ
unittests 60.33% <69.56%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
auth/auth_context.go 0.00% <0.00%> (ø)
auth/config/config.go 71.42% <ø> (ø)
auth/handlers.go 31.14% <50.00%> (ø)
auth/config/domainmatch_enumer.go 54.16% <54.16%> (ø)
auth/config/samesite_enumer.go 54.16% <54.16%> (ø)
auth/cookie_manager.go 58.26% <86.20%> (+7.74%) ⬆️
auth/authzserver/authorize.go 20.63% <100.00%> (ø)
auth/config/config_flags.go 61.22% <100.00%> (+1.65%) ⬆️
auth/cookie.go 74.71% <100.00%> (+0.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e03bd4...bd08dcd. Read the comment docs.

Signed-off-by: Prafulla Mahindrakar <[email protected]>
@EngHabu EngHabu merged commit 87cc942 into master Jun 7, 2022
@EngHabu EngHabu deleted the auth-cookie-domain branch June 7, 2022 16:27
eapolinario pushed a commit that referenced this pull request Sep 6, 2023
* Adding domain to secure auth cookies

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Adding . suffix to the domain

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Add getCookiedomain

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Added enumers for domainMatch and sameSite and testing done

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Added debug make targets for admin and scheduler

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Added more coverage

Signed-off-by: Prafulla Mahindrakar <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core feature] Support passing auth cookie settings in admin
3 participants