{"id":18842694,"url":"https://github.com/dotenv-org/dotenv-vault-kotlin","last_synced_at":"2025-04-14T07:31:52.975Z","repository":{"id":155160305,"uuid":"630990152","full_name":"dotenv-org/dotenv-vault-kotlin","owner":"dotenv-org","description":"Load environment variables from encrypted .env.vault files","archived":false,"fork":false,"pushed_at":"2023-05-21T00:03:46.000Z","size":154,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T21:21:59.922Z","etag":null,"topics":["configuration","dotenv","dotenv-vault","encryption","environment-variables","vault"],"latest_commit_sha":null,"homepage":"https://www.dotenv.org/docs/languages/kotlin","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotenv-org.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-21T16:27:09.000Z","updated_at":"2024-02-20T09:54:34.000Z","dependencies_parsed_at":"2023-10-03T10:28:55.936Z","dependency_job_id":null,"html_url":"https://github.com/dotenv-org/dotenv-vault-kotlin","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.24390243902439024","last_synced_commit":"b2a8e5078dc9d042ddd473354a159135c0b111a2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fdotenv-vault-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fdotenv-vault-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fdotenv-vault-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fdotenv-vault-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotenv-org","download_url":"https://codeload.github.com/dotenv-org/dotenv-vault-kotlin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248839446,"owners_count":21169817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","dotenv","dotenv-vault","encryption","environment-variables","vault"],"created_at":"2024-11-08T02:55:29.003Z","updated_at":"2025-04-14T07:31:52.673Z","avatar_url":"https://github.com/dotenv-org.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotenv-vault-kotlin ![Release](https://jitpack.io/v/dotenv-org/dotenv-vault-kotlin.svg) ![](https://img.shields.io/badge/license-Apache%202.0-orange.svg)\n\n\u003cimg src=\"https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.svg\" alt=\"dotenv-vault\" align=\"right\" width=\"200\" /\u003e\n\nExtends the proven \u0026 trusted foundation of [dotenv-kotlin](https://github.com/cdimascio/dotenv-kotlin), with `.env.vault` file support.\n\nThe extended standard lets you load encrypted secrets from your `.env.vault` file in production (and other) environments. \n\n* [🌱 Install](#-install)\n* [🏗️ Usage (.env)](#%EF%B8%8F-usage)\n* [🚀 Deploying (.env.vault) 🆕](#-deploying)\n* [🌴 Multiple Environments](#-manage-multiple-environments)\n* [📚 Examples](#-examples)\n* [❓ FAQ](#-faq)\n* [⏱️ Changelog](./CHANGELOG.md)\n\n## 🌱 Install\n\nAdd jitpack repository to your `build.gradle` or `build.gradle.kts` and require the `com.github.dotenv-org:dotenv-vault-kotlin:x.x.x` implementation dependency.\n\n```groovy\n// build.gradle\n...\nrepositories {\n    ...\n    maven { url 'https://jitpack.io' }\n}\n\ndependencies {\n    ...\n    implementation 'com.github.dotenv-org:dotenv-vault-kotlin:0.0.2'\n}\n```\n\nor\n\n```kotlin\n// build.gradle.kts\n...\nrepositories {\n    ...\n    maven { url = uri(\"https://jitpack.io\") }\n}\n\ndependencies {\n    ...\n    implementation(\"com.github.dotenv-org:dotenv-vault-kotlin:0.0.2\")\n}\n```\n\n## 🏗️ Usage\n\nDevelopment usage works just like [dotenv-kotlin](https://github.com/cdimascio/dotenv-kotlin). \n\nAdd your application configuration to your `.env` file in the root of your project:\n\n```\nS3_BUCKET=YOURS3BUCKET\nSECRET_KEY=YOURSECRETKEYGOESHERE\n```\n\nAs early as possible in your application code, load .env:\n\n#### Kotlin\n\n```kotlin\nimport org.dotenv.vault.dotenvVault\n\nval dotenv = dotenvVault()\ndotenv[\"S3_BUCKET\"]\n```\n\n#### Android\n\n- Create an assets folder in `app/src/main/assets`\n- Add `env.vault` *(no dot)* to the assets folder\n\n\n- Configure dotenv to search `/assets` for a file with name `env.vault` and provide the key via BuildConfig\n\n  ```kotlin\n  val dotenv = dotenvVault(BuildConfig.DOTENV_KEY) {\n      directory = \"/assets\"\n      filename = \"env.vault\" // instead of '.env', use 'env'\n  }\n  dotenv[\"S3_BUCKET\"]\n  ```\n\n**Note:** The above configuration is required because dot files in `/assets` do not appear to resolve on Android. *(Seeking recommendations from the Android community on how `dotenv-kotlin` configuration should work in order to provide the best experience for Android developers)*\n\nAlternatively, if you are using Provider `android.resource` you may specify\n\n```\n directory = \"android.resource://com.example.myapp/raw\"\n```\n\n##### Add Dotenv Key\n\nAdd `DOTENV_KEY` to your build system environment variables.\n\nAdd key into your build config in your build.grade inside the android-\u003ebuilt types\n```kotlin\nandroid {\n    buildTypes {\n        debug {\n            buildConfigField \"String\", \"DOTENV_KEY\", System.getenv(\"DOTENV_KEY\") ?: \"\"    \n        }\n    } \n}\n\n```\n\n## 🚀 Deploying\n\n[Install](https://www.dotenv.org/install) dotenv-vault.\n\n```\nSee install instructions at https://www.dotenv.org/install\n```\n\nThen encrypt your environment variables by doing:\n\n```shell\n$ dotenv-vault local build\n```\n\nThis will create an encrypted `.env.vault` file along with a `.env.keys` file containing the encryption keys.\n\nSet the `DOTENV_KEY` environment variable by copying and pasting the key value from the `.env.keys` file onto your server or cloud provider. For example in heroku:\n\n```\n$ heroku config:set DOTENV_KEY=\u003ckey string from .env.keys\u003e\n```\n\nCommit your .env.vault file safely to code and deploy. Your .env.vault fill be decrypted on boot, its environment variables injected, and your app work as expected.\n\n## 🌴 Manage Multiple Environments\n\nYou have two options for managing multiple environments - locally managed or vault managed - both use \u003ca href=\"https://github.com/dotenv-org/dotenv-vault\"\u003edotenv-vault\u003c/a\u003e.\n\nLocally managed never makes a remote API call. It is completely managed on your machine. Vault managed adds conveniences like backing up your .env file, secure sharing across your team, access permissions, and version history. Choose what works best for you.\n\n#### 💻 Locally Managed\n\nCreate a `.env.production` file in the root of your project and put your production values there.\n\n```\n# .env.production\nS3_BUCKET=\"PRODUCTION_S3BUCKET\"\nSECRET_KEY=\"PRODUCTION_SECRETKEYGOESHERE\"\n```\n\nRebuild your `.env.vault` file.\n\n```bash\n$ dotenv-vault local build\n```\n\nCheck your `.env.keys` file. There is a production `DOTENV_KEY` that coincides with the additional `DOTENV_VAULT_PRODUCTION` cipher in your `.env.vault` file.\n\nSet the production `DOTENV_KEY` on your server, recommit your `.env.vault` file to code, and deploy. That's it!\n\n#### 🔐 Vault Managed\n\nSync your .env file. Run the push command and follow the instructions. [learn more](/docs/sync/quickstart)\n\n```bash\n$ dotenv-vault push\n```\n\nManage multiple environments with the included UI. [learn more](/docs/tutorials/environments)\n\n```bash\n$ dotenv-vault open\n```\n\nBuild your `.env.vault` file with multiple environments.\n\n```bash\n$ dotenv-vault build\n```\n\nAccess your `DOTENV_KEY`.\n\n```bash\n$ dotenv-vault keys\n```\n\nSet the production `DOTENV_KEY` on your server, recommit your `.env.vault` file to code, and deploy. That's it!\n\n## 📚 Examples\n\n* [Android example app](https://github.com/marcel-rf/DotenvVaultAndroidExample)\n* [Kotlin example app](https://github.com/dotenv-org/hello-kotlin)\n* [Kotlin tests](https://github.com/dotenv-org/dotenv-vault-kotlin/blob/master/lib/src/test/kotlin/org/dotenv/vault/VaultTest.kt#L11)\n\n## ❓ FAQ\n\n#### What happens if `DOTENV_KEY` is not set?\n\nDotenv Vault gracefully falls back to [dotenv-kotlin](https://github.com/cdimascio/dotenv-kotlin) when `DOTENV_KEY` is not set. This is the default for development so that you can focus on editing your `.env` file and save the `build` command until you are ready to deploy those environment variables changes.\n\n#### Should I commit my `.env` file?\n\nNo. We **strongly** recommend against committing your `.env` file to version control. It should only include environment-specific values such as database passwords or API keys. Your production database should have a different password than your development database.\n\n#### Should I commit my `.env.vault` file?\n\nYes. It is safe and recommended to do so. It contains your encrypted envs, and your vault identifier.\n\n#### Can I share the `DOTENV_KEY`?\n\nNo. It is the key that unlocks your encrypted environment variables. Be very careful who you share this key with. Do not let it leak.\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md)\n\n## License\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenv-org%2Fdotenv-vault-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotenv-org%2Fdotenv-vault-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenv-org%2Fdotenv-vault-kotlin/lists"}