-
Notifications
You must be signed in to change notification settings - Fork 55
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
Feat: netlify deployments for frontend #3194
Conversation
✅ Deploy Preview for ecamp3-frontend-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
Woooooooh 🤩😍, nice so cool!
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.
Nice job, but at the same time a lot of alarm bells going off in my head when reading this.
I have to say overall I'm not a fan of opening these multiple security holes just for faster previews. I see the value of the quick frontend previews especially right now that the frontend is being worked on much more than the API. But opening CORS on dev will definitely bite us and community developers in the future, when we (or they) make first steps in developing more API clients on different domains. Such new clients will then work on dev but fail on prod. And also in general, this widens the gap between prod and dev deployments. So in my comments, I am trying to limit on all fronts the amount of security weakening which we perform.
I'd like to say right now, these preview deployments are no alternative to writing frontend tests and E2E tests. I see them only as a cheap and mobile-friendly alternative for previewing some simple UI change. They will not work for all features, and they do not replace a comprehensive code review. And I'd rather invest more time into improving the resource usage and developer setup of our application instead of creating many kinds of feature branch deployments which might or might not work for a new feature.
Is there some way to limit these frontend previews to only PRs which include solely frontend changes and no changes in the API etc.? (And ideally also exclude renovate and dependabot PRs, because these are rarely tested manually, but instead CI should handle them).
--set php.corsAllowOrigin='*' \ | ||
--set php.cookieSameSite='none' \ | ||
--set php.jwt.emptyBody='false' \ | ||
--set print.corsAllowAllOrigin='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.
Can we implement a proper list of allowed origins for print as well, instead of an official "security hole switch"?
--set php.corsAllowOrigin='*' \ | ||
--set php.cookieSameSite='none' \ |
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.
Can we limit these security holes to only the dev deployment, not the feature branch deployments? Or would it make sense to deploy a separate, deliberately insecure backend which is only used for the netlify frontend previews?
@@ -10,6 +12,10 @@ lexik_jwt_authentication: | |||
# Of course it would be even better to have only short-lived tokens but renew them on every request. | |||
token_ttl: 43200 | |||
|
|||
# include token in API response | |||
# remove_token_from_body_when_cookies_used: '%env(bool:JWT_EMPTY_BODY)%' # this is possible after merge & release of https://github.com/lexik/LexikJWTAuthenticationBundle/pull/1092 | |||
remove_token_from_body_when_cookies_used: false |
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.
Can we modify lexik so that it only returns the header and payload information of the token in the response body? The reason that lexik does not want to return the token in the payload is reportedly that JS code should never have access to the full JWT token. I think lexik supports customizing the response body: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/2.x/Resources/doc/2-data-customization.rst#adding-custom-data-or-headers-to-the-jwt
const token = store.state.auth.token | ||
if (token) { | ||
return token.split('.')[1] | ||
} |
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.
I don't really like that we will ship this in production, but I see no quick and easy way around it right now.
@@ -41,6 +41,7 @@ php: | |||
passphrase: | |||
privateKey: | |||
publicKey: | |||
emptyBody: |
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.
Can you set the default in the helm chart to true
? I know it's not respected by lexik yet, but as soon as lexik supports it we should make true
the default.
@@ -30,7 +30,7 @@ php: | |||
appEnv: prod | |||
appDebug: "0" | |||
appSecret: "" | |||
corsAllowOrigin: "^https://.*?\\.chart-example\\.local$" | |||
corsAllowOrigin: |
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.
Maybe add a comment which still indicates (via an example or written description) that this value may be a regex, may assert on the protocol, etc.
return apiStore.post(url, { identifier: email, password: password }).then(() => { | ||
return axios.post(url, { identifier: email, password: password }).then((response) => { | ||
if (response) { | ||
store.commit('setToken', response.data.token) |
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.
Is the store really the correct place for this? This value will be undefined on deployments where we --set php.jwt.emptyBody='false'
(which I expect for any production environment). If you put this value into the store, it signifies to me that any component may use this value, which will then break on production. In this case I would prefer a local let
variable in the top scope of this file, so that only code in this file can access it.
@@ -165,7 +164,7 @@ export default { | |||
}) | |||
.catch((e) => { | |||
this.authenticationInProgress = false | |||
this.error = serverErrorToString(e) | |||
this.error = e.response?.data?.message |
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.
Why this change? Was the old implementation wrong?
@@ -2,6 +2,7 @@ import Vue from 'vue' | |||
import { auth } from '@/plugins/auth' | |||
import storeLoader, { store, apiStore } from '@/plugins/store' | |||
import Cookies from 'js-cookie' | |||
import axios from 'axios' |
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.
If you agree with removing the token from the store, don't forget to revert this
Core Team Decision
Anforderungen an den Deployment Prozess:
Anforderungen an Netlify:
|
can we close this PR? |
As per Santa Claus wish from @manuelmeister:
Allows automatic netlify deployment of the frontend for each pull request. These frontend-deployments are then hard-wired to https://dev-api.ecamp3.ch
CORS is more or less disabled on dev to allow this. This is needed, because Netlify doesn't support custom domains for Preview Deployments (=Deployment for each PR).
Disabling CORS however needs to be triggered explicitly. Default behavior is (almost) the same as before (with the exception of one PR on LexikBundle that still needs to be merged).
A working demo is available under https://vermillion-travesseiro-ea7e4b.netlify.app/ and is connected to my own test API at https://api-ecamp3.mybytes.ch/
Once this PR is merged, I can setup the netlify workflows from our main Netlify account.