@@ -18,15 +18,29 @@ import (
1818 "github.com/gofiber/fiber/v2"
1919)
2020
21+ type OIDCBody struct {
22+ Code string `json:"code"`
23+ State string `json:"state"`
24+ }
25+
2126func APIRoutes (app * fiber.App ) {
2227
2328 // ------- OPEN ROUTES ------
2429 public := app .Group ("/app/public/api" )
25- public .Get ("/oidc/callback" , func (c * fiber.Ctx ) error {
30+ public .Post ("/oidc/callback" , func (c * fiber.Ctx ) error {
2631
2732 ctx := c .Context ()
2833
29- oauth2Token , erra := authoidc .OIDCConfig .Exchange (ctx , c .Query ("code" ))
34+ oidcbody := new (OIDCBody )
35+
36+ if errb := c .BodyParser (oidcbody ); errb != nil {
37+ return c .Status (http .StatusUnauthorized ).JSON (fiber.Map {
38+ "Data Platform" : "Dataplane" ,
39+ "Error" : "Auth token body parse: " + errb .Error (),
40+ })
41+ }
42+
43+ oauth2Token , erra := authoidc .OIDCConfig .Exchange (ctx , oidcbody .Code )
3044 if erra != nil {
3145 return c .Status (http .StatusUnauthorized ).JSON (fiber.Map {
3246 "Data Platform" : "Dataplane" ,
@@ -128,7 +142,7 @@ func APIRoutes(app *fiber.App) {
128142 })
129143 }
130144
131- if nonceCheck .State != c . Query ( "state" ) {
145+ if nonceCheck .State != oidcbody . State {
132146 return c .Status (http .StatusUnauthorized ).JSON (fiber.Map {
133147 "Data Platform" : "Dataplane" ,
134148 "Error" : "Request expired. SSO state not found, please login again." ,
0 commit comments