{"id":13408181,"url":"https://github.com/multiversx/mx-multi-factor-auth-go-service","last_synced_at":"2025-10-06T14:05:18.347Z","repository":{"id":182786056,"uuid":"526187995","full_name":"multiversx/mx-multi-factor-auth-go-service","owner":"multiversx","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-29T10:34:03.000Z","size":2604,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-10-29T12:29:24.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiversx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-18T11:45:45.000Z","updated_at":"2024-07-12T08:38:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"59b0e337-938e-4364-b953-d905212078c5","html_url":"https://github.com/multiversx/mx-multi-factor-auth-go-service","commit_stats":null,"previous_names":["multiversx/mx-multi-factor-auth-go-service"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-multi-factor-auth-go-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-multi-factor-auth-go-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-multi-factor-auth-go-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-multi-factor-auth-go-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiversx","download_url":"https://codeload.github.com/multiversx/mx-multi-factor-auth-go-service/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243578578,"owners_count":20313858,"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":[],"created_at":"2024-07-30T20:00:51.261Z","updated_at":"2025-10-06T14:05:13.316Z","avatar_url":"https://github.com/multiversx.png","language":"Go","funding_links":[],"categories":["MultiversX official"],"sub_categories":["Dev dApps"],"readme":"# multi-factor-auth-go-service\n\n## Prerequisites\n\nIn order to run the service properly, the configuration options have to be set accordingly.\n\nFor testing purposes, most of the default configuration options should be fine.\nIn particular, `external.toml` config file should be modified to set API url and\nmongoDB connection string, if `mongoDB` persiter type is selected.\n\n## Infrastructure\n\nMFA (multi-factor-auth) service uses MongoDB for persistent storage and Redis for caching.\nThe configuration file for setting up the interaction with external services\n(like MongoDB and Redis) can be found \n[here](https://github.com/multiversx/mx-multi-factor-auth-go-service/blob/main/cmd/multi-factor-auth/config/external.toml).\n\n### Redis caching\n\nRedis is used for rate limiting. If maximum number of failed attempts for two factor\nauthentication codes is reached (based on the specified value in config), the user will\nbe blocked for several minutes (as specified in config). This is done by setting a redis\nkey with TTL for the blocked user.\n\nThe key is composed of `user address` and `IP address`. In order for this key to be set\ncorrectly, we need to make sure that the user IP is as close to the real one as possible.\n\nThere is a separate section in the main configuration file for http headers handling.\nPlease check `HTTPHeaders` section in [external.toml](https://github.com/multiversx/mx-multi-factor-auth-go-service/blob/main/cmd/multi-factor-auth/config/external.toml) for more details.\n\nIf the server is exposed directly to the internet, you can set `ForwardedByClientIP` \nto `false` and `TrustedPlatform` as empty. This way the client IP will be set directly\nfrom the network address that sent the last request (which will be the client in\nthis case, or an untrusted proxy).\n\nIf the server is exposed through one or multiple trusted proxies, make sure to set\n`TrustedPlatform`, `RemoteIPHeaders` and `TrustedProxies` fields accordingly. If\nthey are not set explicitly, the default `gin` values will be set. Please check\nalso `gin` documentation for these fields.\n\n\u003e **Important**\n\u003e For this to work properly, make sure to align `Gin` configuration section \n\u003e with your infrastructure setup.\n\n## Local testing environment\n\nThe `Makefile` commands can be used to manage the testing setup more easily.\nThere are commands for running the service locally, there are commands for running the\nservice with docker containers, there are also commands for running mongoDB and redis setup with\n`docker-compose` deployments. (Check all available `Makefile` commands)\n\n\u003e Tested with:\n\u003e * docker-compose version 1.25.0\n\u003e * Docker version 20.10.12\n\n\u003e **Warning**\n\u003e For production systems make sure to follow the proper infrastructure setup and\n\u003e proper security considerations.\n\nThe local testing environment can be setup in two ways:\n- mongoDB single, redis single\n- mongoDB cluster, redis single\n\n### Single mongoDB instance and redis\n\nThe default setup consists of a single mongoDB and a single redis instance, running with\ndocker on host networking mode. The `mfa` service can be started locally, without docker.\n\nTo start the mongoDB instance run the following:\n```bash\n# It will start and set up the mongoDB instance.\n# It will take several seconds to complete the setup\nmake compose-new\n```\n\nStart the `mfa` service:\n```bash\n# It will start the service locally\nmake run\n\n# It will start the service locally with docker\nmake docker-run\n```\n\n### MongoDB cluster and redis\n\nFirstly, the MongoDB connection string has to be updated accordingly. For the current testing\nsetup the following `URI` can be set in `external.toml` config file: `mongodb://mongodb0:27017,mongodb1:27018,mongodb2:27019/?replicaSet=mongoReplSet`\n\nTo start a setup with mongoDB replica set cluster, use the following Makefile command:\n```bash\n# It will take several seconds to complete the setup\nmake compose-new db_setup=cluster\n```\n\nStart the `mfa` service:\n```bash\n# It will set the docker image and it will launch the container\nmake docker-new db_setup=cluster\n```\n\n\u003e **Note**\n\u003e Make sure to run all related commands with `db_setup=cluster`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-multi-factor-auth-go-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiversx%2Fmx-multi-factor-auth-go-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-multi-factor-auth-go-service/lists"}