8000 [lexik/jwt-authentication-bundle] gitignore JWT keys by teohhanhui · Pull Request #89 · symfony/recipes · GitHub
[go: up one dir, main page]

Skip to content

[lexik/jwt-authentication-bundle] gitignore JWT keys #89

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lexik/jwt-authentication-bundle/2.3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ generate-jwt-keys:
ifndef OPENSSL_BIN
$(error "Unable to generate keys (needs OpenSSL)")
endif
mkdir -p config/jwt
mkdir -p secrets/jwt
openssl genrsa -passout pass:${JWT_PASSPHRASE} -out ${JWT_PRIVATE_KEY_PATH} -aes256 4096
openssl rsa -passin pass:${JWT_PASSPHRASE} -pubout -in ${JWT_PRIVATE_KEY_PATH} -out ${JWT_PUBLIC_KEY_PATH}
@echo "\033[32mRSA key pair successfully generated\033[39m"
7 changes: 4 additions & 3 deletions lexik/jwt-authentication-bundle/2.3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"Lexik\\Bundle\\JWTAuthenticationBundle\\LexikJWTAuthenticationBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%"
"config/": "%CONFIG_DIR%",
"secrets/": "secrets"
},
"aliases": ["jwt-auth"],
"env": {
"#1": "Key paths should be relative to the project directory",
"JWT_PRIVATE_KEY_PATH": "%CONFIG_DIR%/jwt/private.pem",
"JWT_PUBLIC_KEY_PATH": "%CONFIG_DIR%/jwt/public.pem",
"JWT_PRIVATE_KEY_PATH": "secrets/jwt/private.pem",
"JWT_PUBLIC_KEY_PATH": "secrets/jwt/public.pem",
Copy link
Member

Choose a reason for hiding this comment

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

Shoudn't it be %PROJECT_DIR%/secrets/jwt/...

Copy link
Contributor Author
@teohhanhui teohhanhui Sep 11, 2017

Choose a reason for hiding this comment

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

No, unless we want to support storing the key pair outside of the project directory? (Out of scope for this PR anyway...)

Copy link
Contributor Author
@teohhanhui teohhanhui Sep 11, 2017

Choose a reason for hiding this comment

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

But if we go ahead with this, we should probably add a secrets-dir option in Flex?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Fabien. This looks really strange. It should be %CONFIG_DIR%/secrets/jwt/... or %PROJECT_DIR%/secrets/jwt/...

Copy link
Contributor Author
@teohhanhui teohhanhui Sep 11, 2017

Choose a reason for hiding this comment

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

%CONFIG_DIR% resolves to config.
%PROJECT_DIR% resolves to the full path of the project directory.

What we might want to add is a %SECRETS_DIR% which resolves to secrets. But I still find it weird to see a %SECRETS_DIR% in an environment variable... I think the resolving should happen when Flex updates the .env (and .env.dist) files. oh wait it already does...

Copy link
Contributor Author
@teohhanhui teohhanhui Sep 11, 2017

Choose a reason for hiding this comment

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

symfony/symfony#23901 introduced the file prefix for %env(...)% processing.

Copy link
Member
@dunglas dunglas Sep 11, 2017

Choose a reason for hiding this comment

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

@javiereguiluz managing secret's encryption at this level looks like a bad idea to me. There are already plenty dedicated tools to do it like Docker and Kubernetes. IMO the best thing to to is to make it easy to use them in Symfony (and it's achieved with symfony/symfony#23901), not to reinvent the wheel.

I'm 👍 to introduce a new secrets directory and store things like JWT keys and Doctrine passwords in it (and retrieve them with symfony/symfony#23901).

Copy link
Contributor

Choose a reason for hiding this comment

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

The risk of the secrets directory is that people would be tempted to directly commit their credentials in the code repository... You use the example of Docker/Kubernetes and the secrets management is exactly meant to prevent people to add their secrets within the Docker image directly. As long as we give a very clear documentation that these secrets have to be development secrets and overwritten by production secrets while deploying production, then I'm 👍 with such secrets directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding an empty directory with a .gitignore which ignores everything else should help.

Copy link
Member

Choose a reason for hiding this comment

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

We can add this directory to the .gitignore file.

"JWT_PASSPHRASE": "%generate(secret)%"
}
}
2 changes: 2 additions & 0 deletions lexik/jwt-authentication-bundle/2.3/secrets/jwt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
0