
Description
Feature Description
Objective
We propose the following features added to the Gitea release cycle (release/v1.22
):
- Merge the credential chain reference for the Minio client credentials from the
main
branch into the current release cycle - Stretch goal: Add the Minio.Credential.IAM_AWS function
getEKSPodIdentityCredentials
to this credential chain at the end, this way native Kubernetes authentication is handled.
Details
We have deployed Gitea using the Helm Chart on our AWS EKS cluster. We’ve been able to stand it up with supporting infrastructure and figure out configurations, but we’ve discovered that the implementation of the Minio client under the Gitea release branch is only looking at AWS Access Keys (long term credentials) for authentication with AWS. The recommended best practice from AWS prefers relying on temporary credentials instead of long-term credentials, such as access keys where possible.
We hope to see implementation of short-lived tokens to authenticate the Minio client with AWS APIs, as this would provide better security and simplified implementation.
- The current latest release client, this only configures credentials using access keys - https://github.com/go-gitea/gitea/blob/v1.22.3/modules/storage/minio.go#L88-L92
- Compare this to the main branch where it calls the credential chain - https://github.com/go-gitea/gitea/blob/main/modules/storage/minio.go#L99-L105
- This chain contains
FileAwsCredentials
, which would allow us to be able to move off of access keys - https://github.com/go-gitea/gitea/blob/main/modules/storage/minio.go#L174-L192 - This is possible due to the credential_process, which thanks to this medium article we found is a working solution to grab
aws_session_token
via the Web Identity Token file
- This chain contains
Expanding on the credential chain, this currently does not import other supported features from the minio-go
SDK. Notably, as we are on AWS EKS, the ideal solution we were hoping to implement is using IRSA roles which would allow direct usage of the token file generated by the Service Account.
- This is the EKS function which would directly support short-lived access tokens using native Kubernetes features - https://github.com/minio/minio-go/blob/cca410398dd20409180d4ff2d017e34bea17c27c/pkg/credentials/iam_aws.go#L318
- To also confirm, the environment variable
AWS_WEB_IDENTITY_TOKEN_FILE
is set on the pods associated with our service account, pointing to the web identity token - https://github.com/minio/minio-go/blob/cca410398dd20409180d4ff2d017e34bea17c27c/pkg/credentials/iam_aws.go#L124-L127 - If this solution is implemented, then we do not need to manually configure any further logic into the Gitea deployment since all authentication will be natively handled by the Kubernetes Service Account
References
-
Current release for minio client, only contains access keys not the credential chain - https://github.com/go-gitea/gitea/blob/v1.22.3/modules/storage/minio.go#L88-L92
-
Main branch, this calls the credential chain - https://github.com/go-gitea/gitea/blob/main/modules/storage/minio.go#L99-L105
-
Found here, and contains the
FileAwsCredentials
, which allows us to use credential_process to convert our web identity token -> session token - https://github.com/go-gitea/gitea/blob/main/modules/storage/minio.go#L174-L192 -
This is the Minio-Go SDK code, where ideally we'd like to see this EKS function imported as well - https://github.com/minio/minio-go/blob/cca410398dd20409180d4ff2d017e34bea17c27c/pkg/credentials/iam_aws.go#L318
-
Which directly looks at the env variable to grab our web identity token, as defined by associated a Kubernetes Service Account paired with an AWS IAM role - https://github.com/minio/minio-go/blob/cca410398dd20409180d4ff2d017e34bea17c27c/pkg/credentials/iam_aws.go#L124-L127
Screenshots
No response