Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI sending authorized request #4327

Conversation

iamrodrigo
Copy link
Contributor

@iamrodrigo iamrodrigo commented Jul 25, 2021

What changed?
--jwt flag added to CLI

Why?
Requested in this proposal

How did you test it?
Tested locally

./cadence-server --env development_oauth start

and

./cadence --do samples-domain --jwt eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicGVybWlzc2lvbiI6InJlYWQiLCJkb21haW4iOiJzYW1wbGVzLWRvbWFpbiIsImlhdCI6MTYyNjMzNjQ2MywiVFRMIjoxMDAwMDAwfQ.ELjxoLPBIIBf3eUEQy-sl0yarhZJ4oj0Bc9ozs79I-5cvg5VKBULxZSomTkc0fZS4en91ZwmLpckXbUzlnEk3WWbKvHqWYBqfuf7DxxxiH8OMaB4wu5NPJ24lz3lYmBbJZGI333FxX9AweC2-Ac3TmMp-E7U1go6LaLSELaXLse__fk8vQMC61COnwu5YGc9fOhaIQ3U9N7qIIGv_oCp3UFOBcUkwQdMHjk3zTrQ60bboGQBMOCBUpe9nz_m_2Bxx4B39qB9DH3fgMPG_-Rsp4M5YT01cW4WujP1QqeGW8rhkUDE2GqjGQi9yla0M7mjJmNjFeRsVTPtBTly1fHANQ domain desc

Potential risks
Nothing as long as oauth file is not loaded

Release notes
When the whole proposal is implemented

Documentation Changes
When the whole proposal is implemented

@@ -41,6 +41,9 @@ const (

// CtxKeyCadenceClient is the name of the context key for the cadence client this cadence worker listens to
CtxKeyCadenceClient = ContextKey("ctxKeyCadenceClient")

// CtxKeyJWT is the name of the context key for the JWT
CtxKeyJWT = ContextKey("ctxKeyJWT")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is bech/lib the right place to kave a context key ? I suspect it might be better in the cli folder but just placed it there because I found the other ones

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah should not be here. You can put it int factory.go under cli/

tools/cli/app.go Show resolved Hide resolved
@@ -63,7 +63,7 @@ type (
// Blobstore is the config for setting up blobstore
Blobstore Blobstore `yaml:"blobstore"`
// Authorization is the config for setting up authorization
Authorization Authorization `yaml:authorization`
Authorization Authorization `yaml:"authorization""`
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like there is one more double quote at the end. Probably this cause the config doesn’t work

@@ -453,3 +453,7 @@ func getConfigDir(c *cli.Context) string {
}
return dirPath
}

func getJWT(c *cli.Context) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe in factory.go or others as this will be shared for all commands

@@ -287,6 +288,10 @@ var flagsForExecution = []cli.Flag{
Name: FlagRunIDWithAlias,
Usage: "RunID",
},
cli.StringFlag{
Name: FlagJWT,
Usage: "JWT token for authentication",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is authorization not authentication :D

We have a different story for authentication: #4095

@coveralls
Copy link

coveralls commented Jul 26, 2021

Pull Request Test Coverage Report for Build 91b798e2-7339-4a6d-aaa8-600c2837bafb

  • 14 of 16 (87.5%) changed or added relevant lines in 3 files are covered.
  • 12 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.08%) to 56.836%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tools/cli/factory.go 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
common/task/weightedRoundRobinTaskScheduler.go 1 89.64%
service/history/execution/mutable_state_task_refresher.go 1 74.4%
service/history/queue/timer_queue_processor.go 2 58.77%
service/history/queue/timer_gate.go 3 95.83%
common/task/fifoTaskScheduler.go 5 84.54%
Totals Coverage Status
Change from base Build e87caaaf-cb4f-4a2b-b34e-157c5854b244: 0.08%
Covered Lines: 77933
Relevant Lines: 137120

💛 - Coveralls

maxJwtTTL: 600000000
jwtCredentials:
algorithm: "RS256"
publicKey: "common/authorization/keytest.pub"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let’s move the two files into a new folder under config/ , eg “credentials”. Because docker and home brew will automatically copy everything under config/ and will not keep the source code after binaries are built. That way users and test this feature with docker compose and homebrew with these test credentials

@longquanzheng longquanzheng changed the title [WIP] Cli sending authorized request CLI sending authorized request Jul 26, 2021
@longquanzheng longquanzheng merged commit 0085b7a into cadence-workflow:master Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants