Browse Source

fix: Oauth callback url is fixed to host+/api/oidc/callback (#314)

lejianwen 6 months ago
parent
commit
0feee5115f

+ 2 - 2
README.md

@@ -94,8 +94,8 @@
94 94
     - 对于`OIDC`, `Issuer`是必须的。`Scopes`是可选的,默认为 `openid,profile,email`. 确保可以获取 `sub`,`email` 和`preferred_username`
95 95
     - `github oauth app`在`Settings`->`Developer settings`->`OAuth Apps`->`New OAuth App`
96 96
       中创建,地址 [https://github.com/settings/developers](https://github.com/settings/developers)
97
-    - `Authorization callback URL`填写`http://<your server[:port]>/api/oauth/callback`
98
-      ,比如`http://127.0.0.1:21114/api/oauth/callback`
97
+    - `Authorization callback URL`填写`http://<your server[:port]>/api/oidc/callback`
98
+      ,比如`http://127.0.0.1:21114/api/oidc/callback`
99 99
 7. 登录日志
100 100
 8. 链接日志
101 101
 9. 文件传输日志

+ 2 - 2
README_EN.md

@@ -94,8 +94,8 @@ displaying data.Frontend code is available at [rustdesk-api-web](https://github.
94 94
     - For `OIDC`, you must set the `Issuer`. And `Scopes` is optional which default is `openid,email,profile`, please make sure this `Oauth App` can access `sub`, `email` and `preferred_username`
95 95
     - Create a `GitHub OAuth App`
96 96
       at `Settings` -> `Developer settings` -> `OAuth Apps` -> `New OAuth App` [here](https://github.com/settings/developers).
97
-    - Set the `Authorization callback URL` to `http://<your server[:port]>/api/oauth/callback`,
98
-      e.g., `http://127.0.0.1:21114/api/oauth/callback`.
97
+    - Set the `Authorization callback URL` to `http://<your server[:port]>/api/oidc/callback`,
98
+      e.g., `http://127.0.0.1:21114/api/oidc/callback`.
99 99
    
100 100
 7. Login logs
101 101
 8. Connection logs

+ 11 - 11
docs/api/api_docs.go

@@ -954,9 +954,9 @@ const docTemplateapi = `{
954 954
                 }
955 955
             }
956 956
         },
957
-        "/oauth/callback": {
958
-            "get": {
959
-                "description": "OauthCallback",
957
+        "/oidc/auth": {
958
+            "post": {
959
+                "description": "OidcAuth",
960 960
                 "consumes": [
961 961
                     "application/json"
962 962
                 ],
@@ -966,7 +966,7 @@ const docTemplateapi = `{
966 966
                 "tags": [
967 967
                     "Oauth"
968 968
                 ],
969
-                "summary": "OauthCallback",
969
+                "summary": "OidcAuth",
970 970
                 "responses": {
971 971
                     "200": {
972 972
                         "description": "OK",
@@ -983,9 +983,9 @@ const docTemplateapi = `{
983 983
                 }
984 984
             }
985 985
         },
986
-        "/oidc/auth": {
987
-            "post": {
988
-                "description": "OidcAuth",
986
+        "/oidc/auth-query": {
987
+            "get": {
988
+                "description": "OidcAuthQuery",
989 989
                 "consumes": [
990 990
                     "application/json"
991 991
                 ],
@@ -995,7 +995,7 @@ const docTemplateapi = `{
995 995
                 "tags": [
996 996
                     "Oauth"
997 997
                 ],
998
-                "summary": "OidcAuth",
998
+                "summary": "OidcAuthQuery",
999 999
                 "responses": {
1000 1000
                     "200": {
1001 1001
                         "description": "OK",
@@ -1012,9 +1012,9 @@ const docTemplateapi = `{
1012 1012
                 }
1013 1013
             }
1014 1014
         },
1015
-        "/oidc/auth-query": {
1015
+        "/oidc/callback": {
1016 1016
             "get": {
1017
-                "description": "OidcAuthQuery",
1017
+                "description": "OauthCallback",
1018 1018
                 "consumes": [
1019 1019
                     "application/json"
1020 1020
                 ],
@@ -1024,7 +1024,7 @@ const docTemplateapi = `{
1024 1024
                 "tags": [
1025 1025
                     "Oauth"
1026 1026
                 ],
1027
-                "summary": "OidcAuthQuery",
1027
+                "summary": "OauthCallback",
1028 1028
                 "responses": {
1029 1029
                     "200": {
1030 1030
                         "description": "OK",

+ 11 - 11
docs/api/api_swagger.json

@@ -947,9 +947,9 @@
947 947
                 }
948 948
             }
949 949
         },
950
-        "/oauth/callback": {
951
-            "get": {
952
-                "description": "OauthCallback",
950
+        "/oidc/auth": {
951
+            "post": {
952
+                "description": "OidcAuth",
953 953
                 "consumes": [
954 954
                     "application/json"
955 955
                 ],
@@ -959,7 +959,7 @@
959 959
                 "tags": [
960 960
                     "Oauth"
961 961
                 ],
962
-                "summary": "OauthCallback",
962
+                "summary": "OidcAuth",
963 963
                 "responses": {
964 964
                     "200": {
965 965
                         "description": "OK",
@@ -976,9 +976,9 @@
976 976
                 }
977 977
             }
978 978
         },
979
-        "/oidc/auth": {
980
-            "post": {
981
-                "description": "OidcAuth",
979
+        "/oidc/auth-query": {
980
+            "get": {
981
+                "description": "OidcAuthQuery",
982 982
                 "consumes": [
983 983
                     "application/json"
984 984
                 ],
@@ -988,7 +988,7 @@
988 988
                 "tags": [
989 989
                     "Oauth"
990 990
                 ],
991
-                "summary": "OidcAuth",
991
+                "summary": "OidcAuthQuery",
992 992
                 "responses": {
993 993
                     "200": {
994 994
                         "description": "OK",
@@ -1005,9 +1005,9 @@
1005 1005
                 }
1006 1006
             }
1007 1007
         },
1008
-        "/oidc/auth-query": {
1008
+        "/oidc/callback": {
1009 1009
             "get": {
1010
-                "description": "OidcAuthQuery",
1010
+                "description": "OauthCallback",
1011 1011
                 "consumes": [
1012 1012
                     "application/json"
1013 1013
                 ],
@@ -1017,7 +1017,7 @@
1017 1017
                 "tags": [
1018 1018
                     "Oauth"
1019 1019
                 ],
1020
-                "summary": "OidcAuthQuery",
1020
+                "summary": "OauthCallback",
1021 1021
                 "responses": {
1022 1022
                     "200": {
1023 1023
                         "description": "OK",

+ 11 - 11
docs/api/api_swagger.yaml

@@ -792,11 +792,11 @@ paths:
792 792
       summary: 登出
793 793
       tags:
794 794
       - 登录
795
-  /oauth/callback:
796
-    get:
795
+  /oidc/auth:
796
+    post:
797 797
       consumes:
798 798
       - application/json
799
-      description: OauthCallback
799
+      description: OidcAuth
800 800
       produces:
801 801
       - application/json
802 802
       responses:
@@ -808,14 +808,14 @@ paths:
808 808
           description: Internal Server Error
809 809
           schema:
810 810
             $ref: '#/definitions/response.ErrorResponse'
811
-      summary: OauthCallback
811
+      summary: OidcAuth
812 812
       tags:
813 813
       - Oauth
814
-  /oidc/auth:
815
-    post:
814
+  /oidc/auth-query:
815
+    get:
816 816
       consumes:
817 817
       - application/json
818
-      description: OidcAuth
818
+      description: OidcAuthQuery
819 819
       produces:
820 820
       - application/json
821 821
       responses:
@@ -827,14 +827,14 @@ paths:
827 827
           description: Internal Server Error
828 828
           schema:
829 829
             $ref: '#/definitions/response.ErrorResponse'
830
-      summary: OidcAuth
830
+      summary: OidcAuthQuery
831 831
       tags:
832 832
       - Oauth
833
-  /oidc/auth-query:
833
+  /oidc/callback:
834 834
     get:
835 835
       consumes:
836 836
       - application/json
837
-      description: OidcAuthQuery
837
+      description: OauthCallback
838 838
       produces:
839 839
       - application/json
840 840
       responses:
@@ -846,7 +846,7 @@ paths:
846 846
           description: Internal Server Error
847 847
           schema:
848 848
             $ref: '#/definitions/response.ErrorResponse'
849
-      summary: OidcAuthQuery
849
+      summary: OauthCallback
850 850
       tags:
851 851
       - Oauth
852 852
   /peers:

+ 1 - 1
http/controller/api/ouath.go

@@ -143,7 +143,7 @@ func (o *Oauth) OidcAuthQuery(c *gin.Context) {
143 143
 // @Produce  json
144 144
 // @Success 200 {object} apiResp.LoginRes
145 145
 // @Failure 500 {object} response.ErrorResponse
146
-// @Router /oauth/callback [get]
146
+// @Router /oidc/callback [get]
147 147
 func (o *Oauth) OauthCallback(c *gin.Context) {
148 148
 	state := c.Query("state")
149 149
 	if state == "" {

+ 4 - 0
http/router/api.go

@@ -49,6 +49,10 @@ func ApiInit(g *gin.Engine) {
49 49
 		frg.GET("/oauth/callback", o.OauthCallback)
50 50
 		frg.GET("/oauth/login", o.OauthCallback)
51 51
 		frg.GET("/oauth/msg", o.Message)
52
+
53
+		frg.GET("/oidc/callback", o.OauthCallback)
54
+		frg.GET("/oidc/login", o.OauthCallback)
55
+		frg.GET("/oidc/msg", o.Message)
52 56
 	}
53 57
 	{
54 58
 		pe := &api.Peer{}

+ 1 - 1
resources/templates/oauth_fail.html

@@ -62,7 +62,7 @@
62 62
         var title = 'OauthFailed'
63 63
         var msg = '{{.message}}'
64 64
         var btn = 'Close'
65
-        document.writeln('<script src="/api/oauth/msg?lang=' + lang + '&msg=' + msg + '&title=OauthFailed"><\/script>');
65
+        document.writeln('<script src="/api/oidc/msg?lang=' + lang + '&msg=' + msg + '&title=OauthFailed"><\/script>');
66 66
     </script>
67 67
 </head>
68 68
 <body>

+ 1 - 1
resources/templates/oauth_success.html

@@ -61,7 +61,7 @@
61 61
         var title = 'OauthSuccess'
62 62
         var msg = '{{.message}}'
63 63
         var btn = 'Close'
64
-        document.writeln('<script src="/api/oauth/msg?lang=' + lang + '&msg=' + msg + '&title=OauthSuccess"><\/script>');
64
+        document.writeln('<script src="/api/oidc/msg?lang=' + lang + '&msg=' + msg + '&title=OauthSuccess"><\/script>');
65 65
     </script>
66 66
 </head>
67 67
 <body>