Newer
Older
"github.com/zachmann/mytoken/internal/endpoints/token/super/polling"
"github.com/zachmann/mytoken/internal/utils/ctxUtils"
"github.com/gofiber/fiber/v2"
"github.com/zachmann/mytoken/internal/model"
"github.com/zachmann/mytoken/internal/oidc/authcode"
)
func HandleSuperTokenEndpoint(ctx *fiber.Ctx) error {
grantType := ctxUtils.GetGrantType(ctx)
switch grantType {
case model.GrantTypeSuperToken:
case model.GrantTypeOIDCFlow:
return handleOIDCFlow(ctx)
case model.GrantTypePollingCode:
return polling.HandlePollingCode(ctx)
case model.GrantTypeAccessToken:
case model.GrantTypePrivateKeyJWT:
res := model.Response{
Status: fiber.StatusBadRequest,
Response: model.APIErrorUnknownGrantType,
}
return res.Send(ctx)
}
}
func handleOIDCFlow(ctx *fiber.Ctx) error {
flow := ctxUtils.GetOIDCFlow(ctx)
switch flow {
case model.OIDCFlowAuthorizationCode:
res := authcode.InitAuthCodeFlow(ctx.Body())
return res.Send(ctx)
res := model.Response{
Status: fiber.StatusBadRequest,
Response: model.APIErrorUnknownOIDCFlow,
}
return res.Send(ctx)