{"id":22908553,"url":"https://github.com/rarimo/web3-auth-svc","last_synced_at":"2025-04-01T09:52:03.248Z","repository":{"id":266779994,"uuid":"898565123","full_name":"rarimo/web3-auth-svc","owner":"rarimo","description":"Decentralized auth service based on Web3 provider data ","archived":false,"fork":false,"pushed_at":"2024-12-11T15:39:41.000Z","size":40345,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T05:26:30.543Z","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/rarimo.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":"2024-12-04T16:12:00.000Z","updated_at":"2024-12-11T15:37:03.000Z","dependencies_parsed_at":"2024-12-06T05:14:52.793Z","dependency_job_id":"933e279e-aec2-4ab9-9fca-2dd92c2c6613","html_url":"https://github.com/rarimo/web3-auth-svc","commit_stats":null,"previous_names":["rarimo/web3-auth-svc"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarimo%2Fweb3-auth-svc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarimo%2Fweb3-auth-svc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarimo%2Fweb3-auth-svc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarimo%2Fweb3-auth-svc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rarimo","download_url":"https://codeload.github.com/rarimo/web3-auth-svc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620267,"owners_count":20806721,"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-12-14T03:29:34.300Z","updated_at":"2025-04-01T09:52:03.226Z","avatar_url":"https://github.com/rarimo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web3-auth-svc\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Description\n\nRariMe Auth service designed to authorize users with Iden3 AuthV2 ZK-proofs and issue JWT tokens based on it.\nThis JWT can be used on other internal or external service to authenticate user for executing endpoints.\n\nFrontend firstly should request Base64-encoded challenge using `v1/authorize/{address}/challenge` request.\nThen generate AuthV2 ZK proof with received challenge as decoded big-endian value. Using this proof\nexecute `v1/authorize` request and receive JWT (refresh and access) tokens in response and also in cookies.\n\n## Usage\n\nTo integrate on other service use the [pkg/auth](./pkg/auth) package.\nIt contains client and client config to execute `v1/validate` requests and example of `grants` that can be used\nwith `Authenticates` method to check uses access.\n\nExample:\n\nAdd middleware to endpoints that require auth:\n\n```go\npackage middleware\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/rarimo/web3-auth-svc/pkg/auth\"\n\t\"gitlab.com/distributed_lab/ape\"\n\t\"gitlab.com/distributed_lab/ape/problems\"\n)\n\nfunc AuthMiddleware(client *auth.Client) func(http.Handler) http.Handler {\n\treturn func(next http.Handler) http.Handler {\n\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tclaim, err := client.ValidateJWT(r)\n\t\t\tif err != nil {\n\t\t\t\tape.RenderErr(w, problems.Unauthorized())\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Save claims somewhere (probably in request context)\n\t\t\tctx := handlers.CtxClaim(claim)(r.Context())\n\t\t\tnext.ServeHTTP(w, r.WithContext(ctx))\n\t\t})\n\t}\n}\n```\n\nHow protected endpoints definition looks like:\n\n```go\nr.Route(\"/integrations/your-service\", func (r chi.Router) {\n    r.Route(\"/v1\", func (r chi.Router) {\n        r.Post(\"/unprotected\", handlers.Unprotected)\n        r.With(middleware.AuthMiddleware(s.client)).Get(\"/protected\", handlers.Protected)\n    })\n})\n```\n\nThen, use parsed claims in handler to allow users execute business logic:\n\n```go\nif !auth.Authenticates([]resources.Claim{claim}, auth.UserGrant(\"address\")) {\n    ape.RenderErr(w, problems.Unauthorized())\n    return\n}\n```\n\n## Install\n\n  ```\n  git clone github.com/rarimo/web3-auth-svc\n  cd web3-auth-svc\n  go build main.go\n  export KV_VIPER_FILE=./config.yaml\n  ./main run service\n  ```\n\n## Documentation\n\nWe do use openapi:json standard for API. We use swagger for documenting our API.\n\nTo open online documentation, go to [swagger editor](http://localhost:8080/swagger-editor/) here is how you can start it\n\n```\n  cd docs\n  npm install\n  npm start\n```\n\nTo build documentation use `npm run build` command,\nthat will create open-api documentation in `web_deploy` folder.\n\nTo generate resources for Go models run `./generate.sh` script in root folder.\nuse `./generate.sh --help` to see all available options.\n\nNote: if you are using Gitlab for building project `docs/spec/paths` folder must not be\nempty, otherwise only `Build and Publish` job will be passed.\n\n## Running from docker\n\nMake sure that docker installed.\n\nuse `docker run ` with `-p 8080:80` to expose port 80 to 8080\n\n  ```\n  docker build -t github.com/rarimo/web3-auth-svc .\n  docker run -e KV_VIPER_FILE=/config.yaml github.com/rarimo/web3-auth-svc\n  ```\n\n## Running from Source\n\n* Set up environment value with config file path `KV_VIPER_FILE=./config.yaml`\n* Provide valid config file\n* Launch the service with `run service` command\n\n## Contact\n\nResponsible Oleg Fomenko\nThe primary contact for this project is t.me/of_dl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frarimo%2Fweb3-auth-svc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frarimo%2Fweb3-auth-svc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frarimo%2Fweb3-auth-svc/lists"}