{"id":15010003,"url":"https://github.com/theruziev/security_interface","last_synced_at":"2026-03-17T20:35:38.424Z","repository":{"id":37079976,"uuid":"154475498","full_name":"theruziev/security_interface","owner":"theruziev","description":"Simple API for authentication and authorization.","archived":false,"fork":false,"pushed_at":"2023-04-18T18:00:42.000Z","size":355,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T21:41:53.783Z","etag":null,"topics":["python-3-6","python-asyncio","security"],"latest_commit_sha":null,"homepage":"https://security-interface.rtfd.io","language":"Python","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/theruziev.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/security_interface.rst","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-24T09:35:59.000Z","updated_at":"2023-03-13T03:54:15.000Z","dependencies_parsed_at":"2024-10-29T16:36:12.331Z","dependency_job_id":null,"html_url":"https://github.com/theruziev/security_interface","commit_stats":{"total_commits":79,"total_committers":6,"mean_commits":"13.166666666666666","dds":0.620253164556962,"last_synced_commit":"5f4396c597da96a35da58a1fbf36db394a528dcf"},"previous_names":["bruziev/security_interface"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/theruziev/security_interface","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theruziev%2Fsecurity_interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theruziev%2Fsecurity_interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theruziev%2Fsecurity_interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theruziev%2Fsecurity_interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theruziev","download_url":"https://codeload.github.com/theruziev/security_interface/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theruziev%2Fsecurity_interface/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30631346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["python-3-6","python-asyncio","security"],"created_at":"2024-09-24T19:29:27.055Z","updated_at":"2026-03-17T20:35:38.401Z","avatar_url":"https://github.com/theruziev.png","language":"Python","readme":".. image:: https://img.shields.io/travis/com/theruziev/security_interface.svg?style=flat-square\n        :target: https://travis-ci.com/theruziev/security_interface\n.. image:: https://img.shields.io/codecov/c/github/theruziev/security_interface.svg?style=flat-square\n        :target: https://codecov.io/gh/theruziev/security_interface\n.. image:: https://img.shields.io/pypi/v/security_interface.svg?style=flat-square\n        :alt: PyPI\n        :target: https://pypi.org/project/security-interface/\n\nSecurity Interface\n==================\n\nThis library provides an easy API for authentication and authorization.\n\nInstallation\n------------\n\nInstall with the following command\n\n.. code-block:: bash\n\n    pip install security_interface\n\n\nUsage\n-----\n\nFirst of all you need to implement ``IdentityPolicyInterface``\nand ``AuthorizationPolicyInterface`` interfaces. For example, we can implement JWT Security\n\n.. code-block:: python\n\n   import jwt\n   from security_interface import IdentityPolicyInterface, AuthorizationPolicyInterface\n\n   class JwtIdentityPolicy(IdentityPolicyInterface):\n       def __init__(self, secret, algorithm=\"HS256\"):\n           self.algorithm = algorithm\n           self.secret = secret\n\n       async def identify(self, identity):\n           if jwt is None:\n               raise TypeError(\"Please install PyJWT\")\n           try:\n               return jwt.decode(\n                   identity,\n                   self.secret,\n                   algorithms=[self.algorithm],\n                   options={\"verify_exp\": True, \"verify_iat\": True},\n               )\n           except Exception as e:\n               return None\n\n   class JwtAuthPolicy(AuthorizationPolicyInterface):\n       async def can(self, identity, permission):\n           return permission in identity[\"scope\"]\n\n\nCreate security instance with our implementation\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n\n   from security_interface.api import Security\n   jwt_identity = JwtIdentityPolicy(\"SECRET\")\n   jwt_auth_policy = JwtAuthPolicy()\n   security = Security(jwt_identity, jwt_auth_policy)\n   # Checking claim\n   security.identify(CLAIM)\n   # Checking permission\n   security.can(CLAIM, \"read\")\n   security.can(CLAIM, \"write\")\n\nFor full implementation see `DEMO \u003chttps://github.com/bruziev/security_interface/tree/master/demo\u003e`_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheruziev%2Fsecurity_interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheruziev%2Fsecurity_interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheruziev%2Fsecurity_interface/lists"}