{"id":20138450,"url":"https://github.com/thiagobarradas/stone-banking-jwt","last_synced_at":"2025-04-09T18:08:50.541Z","repository":{"id":94892069,"uuid":"262371793","full_name":"ThiagoBarradas/stone-banking-jwt","owner":"ThiagoBarradas","description":"Creates Jwt Authentication Token and Consent URL by RSA key pair","archived":false,"fork":false,"pushed_at":"2022-02-25T19:22:12.000Z","size":69,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T21:51:24.397Z","etag":null,"topics":["apps","authentication","consent","csharp","dotnet","dotnet-standard2","jwt","open-banking","openbanking","stone","stone-payments","token"],"latest_commit_sha":null,"homepage":"http://nuget.org/packages/StoneBanking.Jwt","language":"C#","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/ThiagoBarradas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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":"2020-05-08T16:22:36.000Z","updated_at":"2025-03-31T14:51:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"b7c3c5cf-cb26-40ba-ab22-8431e35723c5","html_url":"https://github.com/ThiagoBarradas/stone-banking-jwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fstone-banking-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fstone-banking-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fstone-banking-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fstone-banking-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThiagoBarradas","download_url":"https://codeload.github.com/ThiagoBarradas/stone-banking-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085130,"owners_count":21045135,"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":["apps","authentication","consent","csharp","dotnet","dotnet-standard2","jwt","open-banking","openbanking","stone","stone-payments","token"],"created_at":"2024-11-13T21:38:13.922Z","updated_at":"2025-04-09T18:08:50.534Z","avatar_url":"https://github.com/ThiagoBarradas.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NuGet Downloads](https://img.shields.io/nuget/dt/StoneBanking.Jwt.svg)](https://www.nuget.org/packages/StoneBanking.Jwt/)\n[![NuGet Version](https://img.shields.io/nuget/v/StoneBanking.Jwt.svg)](https://www.nuget.org/packages/StoneBanking.Jwt/)\n\n# StoneBanking.Jwt\n\nCreates Jwt Authentication Token and Consent URL by RSA key pair.\n\n## Install via NuGet\n\n```\nPM\u003e Install-Package StoneBanking.Jwt\n```\n\n## Stone Banking Application\n\nSee more here: https://docs.openbank.stone.com.br/docs/guias/integracao/consentimento/\n\n## Creating you RSA 4096 key pair\n\n```\nopenssl genrsa -out myprivatekey.pem 4096\nopenssl rsa -in myprivatekey.pem -pubout \u003e mypublickey.pub\n```\n\n## How to use\n\n### Configuring with your application credentials\n\nAdd in appsettings.json\n\n```\n{\n  \"StoneBankingJwt\": {\n    \"PrivateKey\": \"myprivatekey.pem\",\n    \"PublicKey\": \"mypublickey.pub\",  \n    \"ClientId\": \"f7158598-fcbe-4810-98f5-08d512f42977\",\n    \"Environment\": \"Sandbox\",\n    \"AuthenticationExpiresInSeconds\": 900,\n    \"ConsentExpiresInSeconds\": 300,\n    \"ConsentDefaultRedirectUrl\": \"https://mysite.com/stonebanking/success\"\n  }\n}\n```\n\nNotes:\n- *PrivateKey*: you can change this var with key content. e.g. \"-----BEGIN RSA PRIVATE KEY-----\\nMIIJKAIBAAKCAgEA...\"\n- *PublicKey*: you can change this var with key content. e.g. \"-----BEGIN PUBLIC KEY-----\\nMIICIjANBgkqhkiG9w0BA...\"\n- *Environment*: Possible values `Sandbox` `Production`\n\nAdd in Startup.cs\n\n```\nservices.AddSingleton(configuration); // register IConfigurationRoot before\nservices.AddStoneBankingJwt();\n```\n\nor \n\n```\nservices.AddStoneBankingJwt(configuration);\n```\n\nor ignoring appsettings.json\n\n```\nvar settings = new StoneBankingSettings\n{\n    ClientId = \"xxxx\",\n    PrivateKey = \"key.pem\",\n    PublicKey = \"key.pub\",\n    ConsentDefaultRedirectUrl = \"https://mysite.com/redirect\"\n};\nservices.AddStoneBankingJwt(settings);\n```\n\nwithout IoC:\n\n```\nvar settings = new StoneBankingSettings\n{\n    ClientId = \"xxxx\",\n    PrivateKey = \"key.pem\",\n    PublicKey = \"key.pub\",\n    ConsentDefaultRedirectUrl = \"https://mysite.com/redirect\"\n};\nIStoneBankingJwt stoneBanking = new StoneBankingJwt(settings);\n```\n\n### Creating Authentication Token\n\n```\nstring authenticationToken = stoneBanking.CreateAuthenticationToken();\n```\n\n### Creating Access Token with Authentication Token\n\n```\nstring authenticationToken = stoneBanking.CreateAuthenticationToken();\nstring accessToken = stoneBanking.CreateAccessToken(authenticationToken);\n```\n\n### Creating Access Token with Auto Managed Authentication Token Creation [BEST USAGE]\n\n```\n// this will create a token and reuse it during token expiration time\n// 60 seconds before expiration, next call will generate a new access token\n\nstring accessToken = stoneBanking.CreateAccessToken();\n```\n\n### Creating Consent Url\n\n```\nstring consentUrl = stoneBanking.CreateConsentUrl();\n```\n\n### Creating Consent Url With Metadata\n\n```\nvar metadata = new Dictionary\u003cstring, string\u003e\n{\n    { \"user_id\", \"user123\" },\n    { \"other_data\", \"123\" }\n};\n\nstring consentUrl = stoneBanking.CreateConsentUrl(metadata);\n```\n\n### Decoding Jwt Token (created with your RSA key pair)\n\n```\nDictionary\u003cstring, object\u003e decodedToken = stoneBankingJwt.DecodeToken(token);\n```\n\n## How can I contribute?\nPlease, refer to [CONTRIBUTING](.github/CONTRIBUTING.md)\n\n## Found something strange or need a new feature?\nOpen a new Issue following our issue template [ISSUE TEMPLATE](.github/ISSUE_TEMPLATE.md)\n\n## Changelog\nSee in [nuget version history](https://www.nuget.org/packages/StoneBanking.Jwt)\n\n## Did you like it? Please, make a donate :)\n\nif you liked this project, please make a contribution and help to keep this and other initiatives, send me some Satochis.\n\nBTC Wallet: `1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX`\n\n![1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX](https://i.imgur.com/mN7ueoE.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fstone-banking-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagobarradas%2Fstone-banking-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fstone-banking-jwt/lists"}