{"id":13408893,"url":"https://github.com/openshift/osin","last_synced_at":"2025-05-12T13:16:02.602Z","repository":{"id":10542717,"uuid":"12739005","full_name":"openshift/osin","owner":"openshift","description":"Golang OAuth2 server library","archived":false,"fork":false,"pushed_at":"2025-05-08T13:09:27.000Z","size":553,"stargazers_count":1921,"open_issues_count":3,"forks_count":398,"subscribers_count":69,"default_branch":"master","last_synced_at":"2025-05-12T13:15:51.640Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openshift.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2013-09-10T19:52:00.000Z","updated_at":"2025-05-11T15:43:16.000Z","dependencies_parsed_at":"2024-01-08T14:30:42.602Z","dependency_job_id":"b0624b1f-c4b1-4a7b-939a-995f0e6068b2","html_url":"https://github.com/openshift/osin","commit_stats":{"total_commits":125,"total_committers":54,"mean_commits":2.314814814814815,"dds":0.752,"last_synced_commit":"0f4d38c6e53fa6b5631fb3942222a9238e8e1be9"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openshift%2Fosin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openshift%2Fosin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openshift%2Fosin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openshift%2Fosin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openshift","download_url":"https://codeload.github.com/openshift/osin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"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:56.187Z","updated_at":"2025-05-12T13:16:02.196Z","avatar_url":"https://github.com/openshift.png","language":"Go","readme":"OSIN\n====\n\n[![GoDoc](https://godoc.org/github.com/openshift/osin?status.svg)](https://godoc.org/github.com/openshift/osin)\n\n\nGolang OAuth2 server library\n----------------------------\n\nOSIN is an OAuth2 server library for the Go language, as specified at\nhttp://tools.ietf.org/html/rfc6749 and http://tools.ietf.org/html/draft-ietf-oauth-v2-10.\n\nIt also includes support for PKCE, as specified at https://tools.ietf.org/html/rfc7636,\nwhich increases security for code-exchange flows for public OAuth clients.\n\nUsing it, you can build your own OAuth2 authentication service.\n\nThe library implements the majority of the specification, like authorization and token endpoints, and authorization code, implicit, resource owner and client credentials grant types.\n\n### Example Server\n\n````go\nimport (\n\t\"github.com/openshift/osin\"\n\tex \"github.com/openshift/osin/example\"\n)\n\n// ex.NewTestStorage implements the \"osin.Storage\" interface\nserver := osin.NewServer(osin.NewServerConfig(), ex.NewTestStorage())\n\n// Authorization code endpoint\nhttp.HandleFunc(\"/authorize\", func(w http.ResponseWriter, r *http.Request) {\n\tresp := server.NewResponse()\n\tdefer resp.Close()\n\n\tif ar := server.HandleAuthorizeRequest(resp, r); ar != nil {\n\n\t\t// HANDLE LOGIN PAGE HERE\n\n\t\tar.Authorized = true\n\t\tserver.FinishAuthorizeRequest(resp, r, ar)\n\t}\n\tosin.OutputJSON(resp, w, r)\n})\n\n// Access token endpoint\nhttp.HandleFunc(\"/token\", func(w http.ResponseWriter, r *http.Request) {\n\tresp := server.NewResponse()\n\tdefer resp.Close()\n\n\tif ar := server.HandleAccessRequest(resp, r); ar != nil {\n\t\tar.Authorized = true\n\t\tserver.FinishAccessRequest(resp, r, ar)\n\t}\n\tosin.OutputJSON(resp, w, r)\n})\n\nhttp.ListenAndServe(\":14000\", nil)\n````\n\n### Example Access\n\nOpen in your web browser:\n\n````\nhttp://localhost:14000/authorize?response_type=code\u0026client_id=1234\u0026redirect_uri=http%3A%2F%2Flocalhost%3A14000%2Fappauth%2Fcode\n````\n\n### Storage backends\n\nThere is a mock available at [example/teststorage.go](/example/teststorage.go) which you can use as a guide for writing your own.  \n\nYou might want to check out other implementations for common database management systems as well:\n\n* [PostgreSQL](https://github.com/ory-am/osin-storage)\n* [MongoDB](https://github.com/martint17r/osin-mongo-storage)\n* [RethinkDB](https://github.com/ahmet/osin-rethinkdb)\n* [DynamoDB](https://github.com/uniplaces/osin-dynamodb)\n* [Couchbase](https://github.com/elgris/osin-couchbase-storage)\n* [MySQL](https://github.com/felipeweb/osin-mysql)\n* [Redis](https://github.com/ShaleApps/osinredis)\n\n### License\n\nThe code is licensed using \"New BSD\" license.\n\n### Author\n\nRangel Reale\nrangelreale@gmail.com\n\n### Changes\n2019-05-13\n==========\n* NON-BREAKING CHANGES\n  - Updated imports in examples to use github.com/openshift/osin instead of github.com/RangelReale/osin\n\n2014-06-25\n==========\n* BREAKING CHANGES:\n\t- Storage interface has 2 new methods, Clone and Close, to better support storages\n\t  that need to clone / close in each connection (mgo)\n\t- Client was changed to be an interface instead of an struct. Because of that,\n\t  the Storage interface also had to change, as interface is already a pointer.\n\n\t- HOW TO FIX YOUR CODE:\n\t\t+ In your Storage, add a Clone function returning itself, and a do nothing Close.\n\t\t+ In your Storage, replace all *osin.Client with osin.Client (remove the pointer reference)\n\t\t+ If you used the osin.Client struct directly in your code, change it to osin.DefaultClient,\n\t\t  which is a struct with the same fields that implements the interface.\n\t\t+ Change all accesses using osin.Client to use the methods instead of the fields directly.\n\t\t+ You MUST defer Response.Close in all your http handlers, otherwise some\n\t\t  Storages may not clean correctly.\n\n\t\t\t\tresp := server.NewResponse()\n\t\t\t\tdefer resp.Close()\n","funding_links":[],"categories":["Authentication and Authorization","认证和OAuth授权","Authentication and OAuth","身份验证和OAuth","Uncategorized","Web Framework Hardening","Go"],"sub_categories":["Contents"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenshift%2Fosin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenshift%2Fosin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenshift%2Fosin/lists"}