{"id":13813831,"url":"https://github.com/globocom/oauth2u","last_synced_at":"2025-05-15T01:31:51.321Z","repository":{"id":2222902,"uuid":"3173127","full_name":"globocom/oauth2u","owner":"globocom","description":"OAuth 2 server implementation","archived":true,"fork":false,"pushed_at":"2012-07-03T13:05:05.000Z","size":247,"stargazers_count":18,"open_issues_count":10,"forks_count":3,"subscribers_count":100,"default_branch":"master","last_synced_at":"2025-04-06T08:36:38.765Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/globocom.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}},"created_at":"2012-01-13T18:09:21.000Z","updated_at":"2023-01-28T10:39:42.000Z","dependencies_parsed_at":"2022-09-20T08:21:51.445Z","dependency_job_id":null,"html_url":"https://github.com/globocom/oauth2u","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Foauth2u","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Foauth2u/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Foauth2u/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Foauth2u/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globocom","download_url":"https://codeload.github.com/globocom/oauth2u/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254256207,"owners_count":22040252,"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-08-04T04:01:32.003Z","updated_at":"2025-05-15T01:31:50.872Z","avatar_url":"https://github.com/globocom.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# OAuth 2 server and client implementation\n\nThis project aims to implement the complete\n[OAuth 2.0 Authorization Protocol Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-22).\n\n\n# Server\n\nThe first part is a oauth 2.0 server. It provides the endpoints specified\nby oauth 2.0 specification with possibilities to plug code to customize\nspecific behaviours (see plugins bellow).\nYou can also extend the server adding additional urls.\n\nHere is an example on how to start the server:\n\n    from oauth2u.server import Server\n\n    server = Server(port=8080)\n    server.start()\n\n**Available parameters**\n\n- `port`: specify which port the server will listen (default is 8000)\n- `plugins_directories`: a list of absolute directories the server executes to register\n   plugins\n- `handlers_directories`: a list of absolute directories the server executes to register\n   new urls handlers\n\nThere is a server on tests/servertest.py.\n\n## Extending the Server\n\nThere are two possible ways to extend the server: new urls and plugins\n\n### Plugins\n\nWith plugins is possible to customize specific behaviours from the server.\nIt's similar to a Template Method pattern, but doesn't require you to extend\n(or even know) the class that calls it.\n\nYou cannot create new plugins, unless you want to call them yourself. But\nthere are some pre-defined plugins called on specific parts of the server.\n\nTo let the server load your plugins automatically you can provide\na list of directories to `Server()` parameter: `plugins_directories`.\n\n##### `authorization_GET`\n\n- __Parameters__\n - `handler`: tornado Request Handler reference\n\nIs called on the Authorization Request handler GET HTTP method, after all\nvalidations are made and the authorization code has already been generated\nand saved on database.\n\nIf no plugin is registered here the server redirects to `redirect_uri`\nwithout any specific verification.\n\nThere is an example usage on how to build a login window using this plugin\nand `authorization-POST` on [examples folder](https://github.com/globocom/oauth2u/blob/master/examples/server_with_plugin_to_login.py)\n\n##### `authorization_POST`\n\n- __Parameters__\n - `handler`: tornado Request Handler reference\n\nIs called on the Authorization Request handler POST HTTP method. There is\nnot default behaviour, if no plugins is registered a `405` status code response is\ngenerated\n\n##### `access_token_response`\n\n- __Parameters__\n - `handler`: tornado Request Handler reference\n - `response`: the default dict to build the json response, with keys: `access_token`,\n    `token_type` and `expires_in`\n\nIs called in the end of Access Token request handler, when the json is about to be\nwritten in the HTTP response.\nThe plugin callback can edit the response dict adding, removing or editing keys.\nJust be careful to don't remove [required OAuth 2.0 parameters](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.1.4)\n\nExample:\n\n        @plugins.access_token_response\n        def customize_response(handler, response):\n            response.pop('expires_in')   # it's optional, and I don't want it...\n            response['user_name'] = 'Bob'\n\n\n### New urls handlers\n\nSince the server is written using [tornado web framework](http://tornadoweb.org), is\nnatural that you can register new handlers.\n\nExample:\n\n        import tornado\n        from oauth2u.server import handlers\n\n        @handlers.register('/my/custom/url')\n        class DummyHandler(tornado.web.RequestHandler):\n            def get(self):\n                self.write(\"hello world\")\n\nRead the tornado docs for more information on Request Handlers\n\nTo let the server load your new url handlers automatically you can provide\na list of directories to `Server()` parameter: `handlers_directories`.\n\n# How to contribute\n\n- Create a fork on github: https://github.com/globocom/oauth2u\n\n- Install the package for development (preferably\n  using [virtualenv](http://pypi.python.org/pypi/virtualenv)):\n\n   `$ pip install -e oauth2u`\n\n- Run tests (this command will install test specific dependencies):\n\n   `$ ./runtests`\n\n- Open an [issue](https://github.com/globocom/oauth2u/issues),\n  if it doesn't exist yet, assign it to you and commit your changes\n  in your fork.\n\n- Send a pull request\n\n- Your commits must have tests, we have 100% coverage, so any code without\n  tests is aren't welcome :).\n  If your changes modifies API or adds a new feature, you must update the docs too\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Foauth2u","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobocom%2Foauth2u","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Foauth2u/lists"}