{"id":520,"date":"2016-08-11T16:49:17","date_gmt":"2016-08-11T08:49:17","guid":{"rendered":"http:\/\/julyclyde.org\/?p=520"},"modified":"2016-08-11T18:01:12","modified_gmt":"2016-08-11T10:01:12","slug":"sentry%e6%96%b0%e7%89%88sso-provider%e8%ae%b2%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/julyclyde.org\/?p=520","title":{"rendered":"Sentry\u65b0\u7248SSO Provider\u8bb2\u89e3"},"content":{"rendered":"<p>\u4eceGH-1372 issue\u5b8c\u6210\u65f6\u5f00\u59cb\uff0cSentry 7.x\u8f6c\u5411\u4f7f\u7528\u81ea\u5bb6\u5b9a\u4e49\u7684SSO Provider\uff0c\u9010\u6e10\u629b\u5f03django-social-auth\u7ed3\u6784\u3002\u56e0\u4e3a\u7f3a\u4e4f\u6587\u6863\uff0c\u6211\u5728\u6b64\u4e8b\u4e0a\u6d88\u8017\u4e86\u5927\u91cf\u7684\u65f6\u95f4\u3002\u73b0\u5728\u5199\u8fd9\u7bc7Wiki\u7528\u4e8e\u8bb0\u5f55\uff1a<\/p>\n<p>\u57fa\u7c7b\uff1asentry\/auth\/provider.py \u4e2d\u7684 Provider \u865a\u57fa\u7c7b<\/p>\n<p>\u6837\u4f8b\uff1asentry\/auth\/providers\/ \u76ee\u5f55\u4e0b\u7684dummy.py\u548coauth2.py \u4e24\u4e2a\uff0c\u4ee5\u53casentry-sso-google \u57fa\u4e8eSentry\u81ea\u5e26\u7684OAuth2Provider<\/p>\n<p>&nbsp;<\/p>\n<p>\u57fa\u672c\u6267\u884c\u6d41\u7a0b\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7django\u673a\u5236\u52a0\u8f7dapp\uff0c\u5728\u521d\u59cb\u5316\u65f6\u8c03\u7528sentry.auth.manager\u7684register\u65b9\u6cd5\uff0c\u6ce8\u518c\u81ea\u5df1\u7684\u540d\u5b57\u548cclass<\/li>\n<li>\u7ba1\u7406\u5458\u5728 Organization \u7684Auth\u9875\u5f00\u542fSSO\u65f6\uff0c\u4f1a\u751f\u6210\u4e0a\u8ff0\u7c7b\u7684\u4e00\u4e2a\u5b9e\u4f8b\u3002Sentry\u7684helper.py\u8d1f\u8d23\u6b64\u6d41\u7a0b\uff0c\u5148\u8c03\u7528get_auth_pipeline()\u51fd\u6570\uff0c\u53d6\u5f97\u4e00\u4e2a\u6210\u5458\u4e3a\u591a\u4e2a AuthView\u7684\u8d85\u7c7b \u7684list\uff0c\u7136\u540e\u5bf9\u7740\u8fd9\u4e2alist\u4f9d\u6b21\u6267\u884c\u6210\u5458\u7684 dispatch()\u51fd\u6570<\/li>\n<li>\u6bcf\u4e2a\u6b65\u9aa4\u6309\u7167pipeline\u7684\u987a\u5e8f\u6267\u884c\u4e00\u4e2aAuthView.dispatch(self,request,helper)\u51fd\u6570\uff0c\u5176\u4e2drequest\u53ef\u4ee5\u8bfb\u5230\u5f53\u524d\u7684django request\u5185\u5bb9\u3002\u56e0\u4e3aURL\u90fd\u4e3a\/auth\/sso\/ \u6240\u4ee5\u9700\u8981\u6839\u636equerystring\u6765\u5224\u65ad\u6267\u884c\u5230\u54ea\u4e00\u6b65\u4e86\uff0c\u5e76\u6536\u96c6\u672c\u6b65\u7684\u4fe1\u606f\uff0c\u8c03\u7528 helper.bind_state() \u4fdd\u5b58\u8d77\u6765\uff0c\u7136\u540ereturn help.next_step()\u8df3\u5230\u4e0b\u4e00\u6b65\u6267\u884c<\/li>\n<li>\u6700\u540ebuild_identify()\u4f1a\u88ab\u6267\u884c\uff0c\u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u81f3\u5c11\u5305\u542bid\u3001email\u3001name\u7684dict\uff0c\u6b64dict\u88abSentry\u7528\u6765\u6784\u9020\u7528\u6237\u4fe1\u606f\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4eceGH-1372 issue\u5b8c\u6210\u65f6\u5f00\u59cb\uff0cSentry 7.x\u8f6c\u5411\u4f7f\u7528\u81ea\u5bb6\u5b9a\u4e49\u7684SSO Provider\uff0c\u9010\u6e10\u629b\u5f03django-social-auth\u7ed3\u6784\u3002\u56e0\u4e3a\u7f3a\u4e4f\u6587\u6863\uff0c\u6211\u5728\u6b64\u4e8b\u4e0a\u6d88\u8017\u4e86\u5927\u91cf\u7684\u65f6\u95f4\u3002\u73b0\u5728\u5199\u8fd9\u7bc7Wiki\u7528\u4e8e\u8bb0\u5f55\uff1a \u57fa\u7c7b\uff1asentry\/auth\/provider.py \u4e2d\u7684 Provider \u865a\u57fa\u7c7b \u6837\u4f8b\uff1asentry\/auth\/providers\/ \u76ee\u5f55\u4e0b\u7684dummy.py\u548coauth2.py \u4e24\u4e2a\uff0c\u4ee5\u53casentry-sso-google \u57fa\u4e8eSentry\u81ea\u5e26\u7684OAuth2Provider &nbsp; \u57fa\u672c\u6267\u884c\u6d41\u7a0b\uff1a \u901a\u8fc7django\u673a\u5236\u52a0\u8f7dapp\uff0c\u5728\u521d\u59cb\u5316\u65f6\u8c03\u7528sentry.auth.manager\u7684register\u65b9\u6cd5\uff0c\u6ce8\u518c\u81ea\u5df1\u7684\u540d\u5b57\u548cclass \u7ba1\u7406\u5458\u5728 Organization \u7684Auth\u9875\u5f00\u542fSSO\u65f6\uff0c\u4f1a\u751f\u6210\u4e0a\u8ff0\u7c7b\u7684\u4e00\u4e2a\u5b9e\u4f8b\u3002Sentry\u7684helper.py\u8d1f\u8d23\u6b64\u6d41\u7a0b\uff0c\u5148\u8c03\u7528get_auth_pipeline()\u51fd\u6570\uff0c\u53d6\u5f97\u4e00\u4e2a\u6210\u5458\u4e3a\u591a\u4e2a AuthView\u7684\u8d85\u7c7b \u7684list\uff0c\u7136\u540e\u5bf9\u7740\u8fd9\u4e2alist\u4f9d\u6b21\u6267\u884c\u6210\u5458\u7684 dispatch()\u51fd\u6570 \u6bcf\u4e2a\u6b65\u9aa4\u6309\u7167pipeline\u7684\u987a\u5e8f\u6267\u884c\u4e00\u4e2aAuthView.dispatch(self,request,helper)\u51fd\u6570\uff0c\u5176\u4e2drequest\u53ef\u4ee5\u8bfb\u5230\u5f53\u524d\u7684django request\u5185\u5bb9\u3002\u56e0\u4e3aURL\u90fd\u4e3a\/auth\/sso\/ \u6240\u4ee5\u9700\u8981\u6839\u636equerystring\u6765\u5224\u65ad\u6267\u884c\u5230\u54ea\u4e00\u6b65\u4e86\uff0c\u5e76\u6536\u96c6\u672c\u6b65\u7684\u4fe1\u606f\uff0c\u8c03\u7528 helper.bind_state() \u4fdd\u5b58\u8d77\u6765\uff0c\u7136\u540ereturn help.next_step()\u8df3\u5230\u4e0b\u4e00\u6b65\u6267\u884c \u6700\u540ebuild_identify()\u4f1a\u88ab\u6267\u884c\uff0c\u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u81f3\u5c11\u5305\u542bid\u3001email\u3001name\u7684dict\uff0c\u6b64dict\u88abSentry\u7528\u6765\u6784\u9020\u7528\u6237\u4fe1\u606f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,61],"class_list":["post-520","post","type-post","status-publish","format-standard","hentry","category-default","tag-python","tag-sentry"],"_links":{"self":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts\/520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=520"}],"version-history":[{"count":0,"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts\/520\/revisions"}],"wp:attachment":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}