@@ -546,17 +546,19 @@ func registerRoutes(m *web.Router) {
546
546
547
547
m .Any ("/user/events" , routing .MarkLongPolling , events .Events )
548
548
549
- m .Group ("/login/oauth" , func () {
550
- m .Get ("/authorize" , web .Bind (forms.AuthorizationForm {}), auth .AuthorizeOAuth )
551
- m .Post ("/grant" , web .Bind (forms.GrantApplicationForm {}), auth .GrantApplicationOAuth )
552
- // TODO manage redirection
553
- m .Post ("/authorize" , web .Bind (forms.AuthorizationForm {}), auth .AuthorizeOAuth )
554
- }, ignSignInAndCsrf , reqSignIn )
555
-
556
- m .Methods ("GET, OPTIONS" , "/login/oauth/userinfo" , optionsCorsHandler (), ignSignInAndCsrf , auth .InfoOAuth )
557
- m .Methods ("POST, OPTIONS" , "/login/oauth/access_token" , optionsCorsHandler (), web .Bind (forms.AccessTokenForm {}), ignSignInAndCsrf , auth .AccessTokenOAuth )
558
- m .Methods ("GET, OPTIONS" , "/login/oauth/keys" , optionsCorsHandler (), ignSignInAndCsrf , auth .OIDCKeys )
559
- m .Methods ("POST, OPTIONS" , "/login/oauth/introspect" , optionsCorsHandler (), web .Bind (forms.IntrospectTokenForm {}), ignSignInAndCsrf , auth .IntrospectOAuth )
549
+ if setting .OAuth2 .Enabled {
550
+ m .Group ("/login/oauth" , func () {
551
+ m .Get ("/authorize" , web .Bind (forms.AuthorizationForm {}), auth .AuthorizeOAuth )
552
+ m .Post ("/grant" , web .Bind (forms.GrantApplicationForm {}), auth .GrantApplicationOAuth )
553
+ // TODO manage redirection
554
+ m .Post ("/authorize" , web .Bind (forms.AuthorizationForm {}), auth .AuthorizeOAuth )
555
+ }, ignSignInAndCsrf , reqSignIn )
556
+
557
+ m .Methods ("GET, OPTIONS" , "/login/oauth/userinfo" , optionsCorsHandler (), ignSignInAndCsrf , auth .InfoOAuth )
558
+ m .Methods ("POST, OPTIONS" , "/login/oauth/access_token" , optionsCorsHandler (), web .Bind (forms.AccessTokenForm {}), ignSignInAndCsrf , auth .AccessTokenOAuth )
559
+ m .Methods ("GET, OPTIONS" , "/login/oauth/keys" , optionsCorsHandler (), ignSignInAndCsrf , auth .OIDCKeys )
560
+ m .Methods ("POST, OPTIONS" , "/login/oauth/introspect" , optionsCorsHandler (), web .Bind (forms.IntrospectTokenForm {}), ignSignInAndCsrf , auth .IntrospectOAuth )
561
+ }
560
562
561
563
m .Group ("/user/settings" , func () {
562
564
m .Get ("" , user_setting .Profile )
@@ -597,16 +599,20 @@ func registerRoutes(m *web.Router) {
597
599
}, openIDSignInEnabled )
598
600
m .Post ("/account_link" , linkAccountEnabled , security .DeleteAccountLink )
599
601
})
600
- m .Group ("/applications/oauth2" , func () {
601
- m .Get ("/{id}" , user_setting .OAuth2ApplicationShow )
602
- m .Post ("/{id}" , web .Bind (forms.EditOAuth2ApplicationForm {}), user_setting .OAuthApplicationsEdit )
603
- m .Post ("/{id}/regenerate_secret" , user_setting .OAuthApplicationsRegenerateSecret )
604
- m .Post ("" , web .Bind (forms.EditOAuth2ApplicationForm {}), user_setting .OAuthApplicationsPost )
605
- m .Post ("/{id}/delete" , user_setting .DeleteOAuth2Application )
606
- m .Post ("/{id}/revoke/{grantId}" , user_setting .RevokeOAuth2Grant )
607
- })
608
- m .Combo ("/applications" ).Get (user_setting .Applications ).
609
- Post (web .Bind (forms.NewAccessTokenForm {}), user_setting .ApplicationsPost )
602
+
603
+ if setting .OAuth2 .Enabled {
604
+ m .Group ("/applications/oauth2" , func () {
605
+ m .Get ("/{id}" , user_setting .OAuth2ApplicationShow )
606
+ m .Post ("/{id}" , web .Bind (forms.EditOAuth2ApplicationForm {}), user_setting .OAuthApplicationsEdit )
607
+ m .Post ("/{id}/regenerate_secret" , user_setting .OAuthApplicationsRegenerateSecret )
608
+ m .Post ("" , web .Bind (forms.EditOAuth2ApplicationForm {}), user_setting .OAuthApplicationsPost )
609
+ m .Post ("/{id}/delete" , user_setting .DeleteOAuth2Application )
610
+ m .Post ("/{id}/revoke/{grantId}" , user_setting .RevokeOAuth2Grant )
611
+ })
612
+ m .Combo ("/applications" ).Get (user_setting .Applications ).
613
+ Post (web .Bind (forms.NewAccessTokenForm {}), user_setting .ApplicationsPost )
614
+ }
615
+
610
616
m .Post ("/applications/delete" , user_setting .DeleteApplication )
611
617
m .Combo ("/keys" ).Get (user_setting .Keys ).
612
618
Post (web .Bind (forms.AddKeyForm {}), user_setting .KeysPost )
@@ -773,20 +779,17 @@ func registerRoutes(m *web.Router) {
773
779
m .Post ("/empty" , admin .EmptyNotices )
774
780
})
775
781
776
- m .Group ("/applications" , func () {
777
- m .Get ("" , admin .Applications )
778
- m .Post ("/oauth2" , web .Bind (forms.EditOAuth2ApplicationForm {}), admin .ApplicationsPost )
779
- m .Group ("/oauth2/{id}" , func () {
780
- m .Combo ("" ).Get (admin .EditApplication ).Post (web .Bind (forms.EditOAuth2ApplicationForm {}), admin .EditApplicationPost )
781
- m .Post ("/regenerate_secret" , admin .ApplicationsRegenerateSecret )
782
- m .Post ("/delete" , admin .DeleteApplication )
782
+ if setting .OAuth2 .Enabled {
783
+ m .Group ("/applications" , func () {
784
+ m .Get ("" , admin .Applications )
785
+ m .Post ("/oauth2" , web .Bind (forms.EditOAuth2ApplicationForm {}), admin .ApplicationsPost )
786
+ m .Group ("/oauth2/{id}" , func () {
787
+ m .Combo ("" ).Get (admin .EditApplication ).Post (web .Bind (forms.EditOAuth2ApplicationForm {}), admin .EditApplicationPost )
788
+ m .Post ("/regenerate_secret" , admin .ApplicationsRegenerateSecret )
789
+ m .Post ("/delete" , admin .DeleteApplication )
790
+ })
783
791
})
784
- }, func (ctx * context.Context ) {
785
- if ! setting .OAuth2 .Enabled {
786
- ctx .Error (http .StatusForbidden )
787
- return
788
- }
789
- })
792
+ }
790
793
791
794
m .Group ("/actions" , func () {
792
795
m .Get ("" , admin .RedirectToDefaultSetting )
0 commit comments