Skip to content
Snippets Groups Projects
Commit 138bf72f authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

fix redirect endpoint returning json

parent 066ec76d
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ require (
github.com/jinzhu/copier v0.3.2
github.com/jmoiron/sqlx v1.3.4
github.com/lestrrat-go/jwx v1.2.4
github.com/oidc-mytoken/api v0.0.0-20210727075713-4c9550f98088
github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1
github.com/oidc-mytoken/lib v0.2.1-0.20210611134913-0c477174fc1f
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
......
......@@ -414,8 +414,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/nishanths/exhaustive v0.0.0-20200525081945-8e46705b6132 h1:NjznefjSrral0MiR4KlB41io/d3OklvhcgQUdfZTqJE=
github.com/nishanths/exhaustive v0.0.0-20200525081945-8e46705b6132/go.mod h1:wBEpHwM2OdmeNpdCvRPUlkEbBuaFmcK4Wv8Q7FuGW3c=
github.com/oidc-mytoken/api v0.0.0-20210610140005-29f166a942ec/go.mod h1:S8t1XA42EFAgc3vUfis0g1LPGA4TXH0nfDynvgo6cwk=
github.com/oidc-mytoken/api v0.0.0-20210727075713-4c9550f98088 h1:ruAqdiWOdbCGc47/a2I80kCviVpentvNL/Ux9lVbsyM=
github.com/oidc-mytoken/api v0.0.0-20210727075713-4c9550f98088/go.mod h1:S8t1XA42EFAgc3vUfis0g1LPGA4TXH0nfDynvgo6cwk=
github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1 h1:i1LIDAuTm4SR65iPjVq+elXHSKNju3Yt61+jreULTuE=
github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1/go.mod h1:S8t1XA42EFAgc3vUfis0g1LPGA4TXH0nfDynvgo6cwk=
github.com/oidc-mytoken/lib v0.2.1-0.20210611134913-0c477174fc1f h1:EqbUYQ45C2iTLHZ0mqtAK9+SxMSemj9gaAv9/csN9D0=
github.com/oidc-mytoken/lib v0.2.1-0.20210611134913-0c477174fc1f/go.mod h1:kwotzLmyV5WEsvU50JoF8Q5+rjLFhjQKAgBGoEw7FRE=
github.com/oidc-mytoken/server v0.2.0/go.mod h1:6uFm+Za9NMK3gq4OOIeX3gs3T6leluVIWsGiM1zlQbA=
......
package redirect
import (
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/jmoiron/sqlx"
"github.com/oidc-mytoken/api/v0"
log "github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
"github.com/oidc-mytoken/server/internal/db"
"github.com/oidc-mytoken/server/internal/db/dbrepo/authcodeinforepo"
......@@ -42,5 +46,13 @@ func HandleOIDCRedirect(ctx *fiber.Ctx) error {
}
code := ctx.Query("code")
res := authcode.CodeExchange(oState, code, *ctxUtils.ClientMetaData(ctx))
return res.Send(ctx)
if fasthttp.StatusCodeIsRedirect(res.Status) {
return res.Send(ctx)
}
return ctx.Render("sites/error", map[string]interface{}{
"empty-navbar": true,
"error-heading": http.StatusText(res.Status),
"msg": res.Response.(api.Error).CombinedMessage(),
}, "layouts/main")
}
......@@ -142,8 +142,6 @@ func StartAuthCodeFlow(ctx *fiber.Ctx, oidcReq response.OIDCFlowRequest) *model.
}
}
//TODO don't return json
// CodeExchange performs an oidc code exchange it creates the mytoken and stores it in the database
func CodeExchange(oState *state.State, code string, networkData api.ClientMetaData) *model.Response {
log.Debug("Handle code exchange")
......
<h3>Site not found!</h3>
<p>
Oh no! We could not find that site on our server. <br>
We could not find that site on our server. <br>
We really tried our best. It's just not here.
</p>
\ No newline at end of file
<h3>Not Implemented</h3>
<p>
mytoken is still under active development.
Mytoken is still under active development.
This feature is currently not implemented. We give our best, to have it ready soon.
</p>
\ No newline at end of file
<h3>{{ error-heading }}</h3>
<p>
{{ msg }}
</p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment