-
Notifications
You must be signed in to change notification settings - Fork 126
feat: add support for allowUnauthenticated and custom IAM definitions #219
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
Conversation
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.
Thank you @edaniszewski ! Please check few minor style suggestions
package/lib/compileFunctions.js
Outdated
@@ -83,6 +89,14 @@ module.exports = { | |||
|
|||
funcTemplate.properties.httpsTrigger = {}; | |||
funcTemplate.properties.httpsTrigger.url = url; | |||
|
|||
if (_.get(funcObject, 'allowUnauthenticated') === true) { |
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.
Let's write it naturally without lodash
package/lib/compileFunctions.js
Outdated
@@ -95,6 +109,10 @@ module.exports = { | |||
funcTemplate.properties.eventTrigger.resource = resource; | |||
} | |||
|
|||
if (!_.size(funcTemplate.accessControl.gcpIamPolicy.bindings)) { |
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.
Let's check naturally for .length
package/lib/compileFunctions.js
Outdated
].join(''); | ||
throw new Error(errorMessage); | ||
} | ||
if (!binding.members || binding.members.length === 0) { |
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.
More accurate would be if (!Array.isArray(binding.members) || !binding.members.length)
@medikoo Thanks for the review & suggestions. I don't use JS that often, so I'm glad to have another pair of eyes on it and to help me clean it up. I made updates for your suggestions - happy to make any more changes as needed. |
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.
Thanks @edaniszewski it looks really good now! Just one minor style suggestion and we should be good to go
package/lib/compileFunctions.js
Outdated
@@ -83,6 +89,14 @@ module.exports = { | |||
|
|||
funcTemplate.properties.httpsTrigger = {}; | |||
funcTemplate.properties.httpsTrigger.url = url; | |||
|
|||
if (funcObject.allowUnauthenticated === true) { |
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.
Let's simply put it as if (funcObject.allowUnauthenticated)
(it's not natural in JS to confirm on true
specifically)
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.
🤦
Well thats super obvious now that you said it. Thanks for catching this (:
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.
Thank you @edaniszewski !
I got this error with this config:
My config is:
|
@thucnc it's not published yet |
actually I overwrote my local |
Same issue for me using the code in master
… Le 25 juin 2020 à 11:46, Thuc Nguyen Canh ***@***.***> a écrit :
actually I overwrote my local package/lib/compileFunctions.js with the latest version in github.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
* feat: Add support for allowUnauthenticated and custom IAM definitions (PR serverless#219) * feat: preserve function name * added failurePolicy Co-authored-by: Erick Daniszewski <[email protected]>
This PR:
allowUnauthenticated
property to a function as a shortcut for adding theroles/cloudfunctions.invoker
role forallUsers
, making the function public (see: https://cloud.google.com/functions/docs/securing/managing-access-iam#gcloud_4)Note that I haven't tested this with an actual deploy because I'm not sure how use my fork of this plugin in a serverless configuration, but I can look into how to get that set up tomorrow.
Relates to: