-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add an annotations to inject the API key into the action context. #4284
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
Changes from all commits
3738fd1
f7a49cd
12cf462
c77d1cf
7adbee5
4d89ac4
013eb47
e7dce59
4ef54fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -560,7 +560,13 @@ class ContainerProxy( | |
| } | ||
| val parameters = job.msg.content getOrElse JsObject.empty | ||
|
|
||
| val authEnvironment = job.msg.user.authkey.toEnvironment | ||
| // if the action requests the api key to be injected into the action context, add it here; | ||
| // treat a missing annotation as requesting the api key for backward compatibility | ||
| val authEnvironment = { | ||
| if (job.action.annotations.isTruthy(WhiskAction.provideApiKeyAnnotationName, valueForNonExistent = true)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I second to stay backwards compatible. |
||
| job.msg.user.authkey.toEnvironment | ||
| } else JsObject.empty | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do suggest to move the decision what to hide as sensitive information to each If we stay backwards compatible , I would be willing to implement this change implement in a following PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you send a comment to the dev list with the proposal. It is reasonable to me. Do you have an example you can attach?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will address it once this PR is merged. No need to delay.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
| } | ||
|
|
||
| val environment = JsObject( | ||
| "namespace" -> job.msg.user.namespace.name.toJson, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -616,9 +616,9 @@ or set an internal alarm when the action is about to use up its allotted time bu | |
| The properties are accessible via the system environment for all supported runtimes: | ||
| Node.js, Python, Swift, Java and Docker actions when using the OpenWhisk Docker skeleton. | ||
|
|
||
| * `__OW_API_HOST` the API host for the OpenWhisk deployment running this action | ||
| * `__OW_API_KEY` the API key for the subject invoking the action, this key may be a restricted API key | ||
| * `__OW_NAMESPACE` the namespace for the _activation_ (this may not be the same as the namespace for the action) | ||
| * `__OW_ACTION_NAME` the fully qualified name of the running action | ||
| * `__OW_ACTIVATION_ID` the activation id for this running action instance | ||
| * `__OW_DEADLINE` the approximate time when this action will have consumed its entire duration quota (measured in epoch milliseconds) | ||
| * `__OW_API_HOST` the API host for the OpenWhisk deployment running this action. | ||
| * `__OW_API_KEY` the API key for the subject invoking the action, this key may be a restricted API key. This property is absent unless explicitly [requested](./annotations.md#annotations-for-all-actions). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May want to update the docs explaining the reverse compatibility feature you added.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in last commit. |
||
| * `__OW_NAMESPACE` the namespace for the _activation_ (this may not be the same as the namespace for the action). | ||
| * `__OW_ACTION_NAME` the fully qualified name of the running action. | ||
| * `__OW_ACTIVATION_ID` the activation id for this running action instance. | ||
| * `__OW_DEADLINE` the approximate time when this action will have consumed its entire duration quota (measured in epoch milliseconds). | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM