Skip to content

Commit 26c1299

Browse files
authored
Merge pull request #672 from dataplane-app/sso-login
fix header too large 421
2 parents 4e5d5a9 + 2ccbe69 commit 26c1299

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

app/mainapp/routes/apiroutes.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
2126
func 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.",

frontend/src/pages/SSORedirect.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ const SSORedirect = () => {
1515
try {
1616
// loop through each query parameter and add all of them to api endpoint
1717
const queryParams = new URLSearchParams(window.location.search);
18-
const apiEndpoint = '/oidc/callback?' + queryParams.toString();
18+
// + queryParams.toString()
19+
const apiEndpoint = '/oidc/callback';
20+
const body = {
21+
code: queryParams.get('code'),
22+
state: queryParams.get('state'),
23+
};
1924
// console.log(apiEndpoint);
2025

21-
PublicAPI(apiEndpoint, {}, 'GET').then((response) => {
26+
PublicAPI(apiEndpoint, JSON.stringify(body), 'POST').then((response) => {
2227
if (response.status === 200) {
2328
setAuthStrategy('success');
2429
localStorage.setItem('refresh_token', response.body.refresh_token);

0 commit comments

Comments
 (0)