add configuration files and update docker-compose for hydra and redis services
This commit is contained in:
337
internal/api/auth/handler/gen.go
Normal file
337
internal/api/auth/handler/gen.go
Normal file
@ -0,0 +1,337 @@
|
||||
// Package handler provides primitives to interact with the openapi HTTP API.
|
||||
//
|
||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
// AcceptConsentRequest defines model for AcceptConsentRequest.
|
||||
type AcceptConsentRequest struct {
|
||||
// ConsentChallenge The consent challenge to accept
|
||||
ConsentChallenge string `json:"consent_challenge"`
|
||||
}
|
||||
|
||||
// AcceptConsentResponse defines model for AcceptConsentResponse.
|
||||
type AcceptConsentResponse struct {
|
||||
Message string `json:"message"`
|
||||
|
||||
// Ok Status of the consent acceptance
|
||||
Ok bool `json:"ok"`
|
||||
|
||||
// RedirectUrl URL to redirect to after accepting consent
|
||||
RedirectUrl string `json:"redirect_url"`
|
||||
}
|
||||
|
||||
// RequestOTPRequest defines model for RequestOTPRequest.
|
||||
type RequestOTPRequest struct {
|
||||
// PhoneNumber Phone number to send OTP to
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
}
|
||||
|
||||
// RequestOTPResponse defines model for RequestOTPResponse.
|
||||
type RequestOTPResponse struct {
|
||||
// Message Confirmation message
|
||||
Message string `json:"message"`
|
||||
|
||||
// Ok Status of the request
|
||||
Ok bool `json:"ok"`
|
||||
}
|
||||
|
||||
// VerifyOTPRequest defines model for VerifyOTPRequest.
|
||||
type VerifyOTPRequest struct {
|
||||
// LoginChallenge Login challenge for verification
|
||||
LoginChallenge string `json:"login_challenge"`
|
||||
|
||||
// Otp One-time password to verify
|
||||
Otp string `json:"otp"`
|
||||
|
||||
// PhoneNumber Phone number to verify OTP for
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
}
|
||||
|
||||
// VerifyOTPResponse defines model for VerifyOTPResponse.
|
||||
type VerifyOTPResponse struct {
|
||||
// Ok Status of the verification
|
||||
Ok bool `json:"ok"`
|
||||
|
||||
// RedirectUrl URL to redirect to after successful verification
|
||||
RedirectUrl string `json:"redirect_url"`
|
||||
}
|
||||
|
||||
// PostAuthConsentAcceptJSONRequestBody defines body for PostAuthConsentAccept for application/json ContentType.
|
||||
type PostAuthConsentAcceptJSONRequestBody = AcceptConsentRequest
|
||||
|
||||
// PostAuthOtpRequestJSONRequestBody defines body for PostAuthOtpRequest for application/json ContentType.
|
||||
type PostAuthOtpRequestJSONRequestBody = RequestOTPRequest
|
||||
|
||||
// PostAuthOtpVerifyJSONRequestBody defines body for PostAuthOtpVerify for application/json ContentType.
|
||||
type PostAuthOtpVerifyJSONRequestBody = VerifyOTPRequest
|
||||
|
||||
// ServerInterface represents all server handlers.
|
||||
type ServerInterface interface {
|
||||
// Accept consent
|
||||
// (POST /auth/consent/accept)
|
||||
PostAuthConsentAccept(c *fiber.Ctx) error
|
||||
// Request OTP
|
||||
// (POST /auth/otp/request)
|
||||
PostAuthOtpRequest(c *fiber.Ctx) error
|
||||
// Verify OTP
|
||||
// (POST /auth/otp/verify)
|
||||
PostAuthOtpVerify(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
// ServerInterfaceWrapper converts contexts to parameters.
|
||||
type ServerInterfaceWrapper struct {
|
||||
Handler ServerInterface
|
||||
}
|
||||
|
||||
type MiddlewareFunc fiber.Handler
|
||||
|
||||
// PostAuthConsentAccept operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthConsentAccept(c *fiber.Ctx) error {
|
||||
|
||||
return siw.Handler.PostAuthConsentAccept(c)
|
||||
}
|
||||
|
||||
// PostAuthOtpRequest operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthOtpRequest(c *fiber.Ctx) error {
|
||||
|
||||
return siw.Handler.PostAuthOtpRequest(c)
|
||||
}
|
||||
|
||||
// PostAuthOtpVerify operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthOtpVerify(c *fiber.Ctx) error {
|
||||
|
||||
return siw.Handler.PostAuthOtpVerify(c)
|
||||
}
|
||||
|
||||
// FiberServerOptions provides options for the Fiber server.
|
||||
type FiberServerOptions struct {
|
||||
BaseURL string
|
||||
Middlewares []MiddlewareFunc
|
||||
}
|
||||
|
||||
// RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
|
||||
func RegisterHandlers(router fiber.Router, si ServerInterface) {
|
||||
RegisterHandlersWithOptions(router, si, FiberServerOptions{})
|
||||
}
|
||||
|
||||
// RegisterHandlersWithOptions creates http.Handler with additional options
|
||||
func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions) {
|
||||
wrapper := ServerInterfaceWrapper{
|
||||
Handler: si,
|
||||
}
|
||||
|
||||
for _, m := range options.Middlewares {
|
||||
router.Use(fiber.Handler(m))
|
||||
}
|
||||
|
||||
router.Post(options.BaseURL+"/auth/consent/accept", wrapper.PostAuthConsentAccept)
|
||||
|
||||
router.Post(options.BaseURL+"/auth/otp/request", wrapper.PostAuthOtpRequest)
|
||||
|
||||
router.Post(options.BaseURL+"/auth/otp/verify", wrapper.PostAuthOtpVerify)
|
||||
|
||||
}
|
||||
|
||||
type PostAuthConsentAcceptRequestObject struct {
|
||||
Body *PostAuthConsentAcceptJSONRequestBody
|
||||
}
|
||||
|
||||
type PostAuthConsentAcceptResponseObject interface {
|
||||
VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error
|
||||
}
|
||||
|
||||
type PostAuthConsentAccept200JSONResponse AcceptConsentResponse
|
||||
|
||||
func (response PostAuthConsentAccept200JSONResponse) VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(200)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
type PostAuthConsentAccept400JSONResponse AcceptConsentResponse
|
||||
|
||||
func (response PostAuthConsentAccept400JSONResponse) VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(400)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
type PostAuthOtpRequestRequestObject struct {
|
||||
Body *PostAuthOtpRequestJSONRequestBody
|
||||
}
|
||||
|
||||
type PostAuthOtpRequestResponseObject interface {
|
||||
VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error
|
||||
}
|
||||
|
||||
type PostAuthOtpRequest200JSONResponse RequestOTPResponse
|
||||
|
||||
func (response PostAuthOtpRequest200JSONResponse) VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(200)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
type PostAuthOtpRequest400JSONResponse RequestOTPResponse
|
||||
|
||||
func (response PostAuthOtpRequest400JSONResponse) VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(400)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
type PostAuthOtpVerifyRequestObject struct {
|
||||
Body *PostAuthOtpVerifyJSONRequestBody
|
||||
}
|
||||
|
||||
type PostAuthOtpVerifyResponseObject interface {
|
||||
VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error
|
||||
}
|
||||
|
||||
type PostAuthOtpVerify200JSONResponse VerifyOTPResponse
|
||||
|
||||
func (response PostAuthOtpVerify200JSONResponse) VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(200)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
type PostAuthOtpVerify400JSONResponse VerifyOTPResponse
|
||||
|
||||
func (response PostAuthOtpVerify400JSONResponse) VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error {
|
||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||
ctx.Status(400)
|
||||
|
||||
return ctx.JSON(&response)
|
||||
}
|
||||
|
||||
// StrictServerInterface represents all server handlers.
|
||||
type StrictServerInterface interface {
|
||||
// Accept consent
|
||||
// (POST /auth/consent/accept)
|
||||
PostAuthConsentAccept(ctx context.Context, request PostAuthConsentAcceptRequestObject) (PostAuthConsentAcceptResponseObject, error)
|
||||
// Request OTP
|
||||
// (POST /auth/otp/request)
|
||||
PostAuthOtpRequest(ctx context.Context, request PostAuthOtpRequestRequestObject) (PostAuthOtpRequestResponseObject, error)
|
||||
// Verify OTP
|
||||
// (POST /auth/otp/verify)
|
||||
PostAuthOtpVerify(ctx context.Context, request PostAuthOtpVerifyRequestObject) (PostAuthOtpVerifyResponseObject, error)
|
||||
}
|
||||
|
||||
type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error)
|
||||
|
||||
type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc
|
||||
|
||||
func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface {
|
||||
return &strictHandler{ssi: ssi, middlewares: middlewares}
|
||||
}
|
||||
|
||||
type strictHandler struct {
|
||||
ssi StrictServerInterface
|
||||
middlewares []StrictMiddlewareFunc
|
||||
}
|
||||
|
||||
// PostAuthConsentAccept operation middleware
|
||||
func (sh *strictHandler) PostAuthConsentAccept(ctx *fiber.Ctx) error {
|
||||
var request PostAuthConsentAcceptRequestObject
|
||||
|
||||
var body PostAuthConsentAcceptJSONRequestBody
|
||||
if err := ctx.BodyParser(&body); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
request.Body = &body
|
||||
|
||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.PostAuthConsentAccept(ctx.UserContext(), request.(PostAuthConsentAcceptRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "PostAuthConsentAccept")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else if validResponse, ok := response.(PostAuthConsentAcceptResponseObject); ok {
|
||||
if err := validResponse.VisitPostAuthConsentAcceptResponse(ctx); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
} else if response != nil {
|
||||
return fmt.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PostAuthOtpRequest operation middleware
|
||||
func (sh *strictHandler) PostAuthOtpRequest(ctx *fiber.Ctx) error {
|
||||
var request PostAuthOtpRequestRequestObject
|
||||
|
||||
var body PostAuthOtpRequestJSONRequestBody
|
||||
if err := ctx.BodyParser(&body); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
request.Body = &body
|
||||
|
||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.PostAuthOtpRequest(ctx.UserContext(), request.(PostAuthOtpRequestRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "PostAuthOtpRequest")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else if validResponse, ok := response.(PostAuthOtpRequestResponseObject); ok {
|
||||
if err := validResponse.VisitPostAuthOtpRequestResponse(ctx); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
} else if response != nil {
|
||||
return fmt.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PostAuthOtpVerify operation middleware
|
||||
func (sh *strictHandler) PostAuthOtpVerify(ctx *fiber.Ctx) error {
|
||||
var request PostAuthOtpVerifyRequestObject
|
||||
|
||||
var body PostAuthOtpVerifyJSONRequestBody
|
||||
if err := ctx.BodyParser(&body); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
request.Body = &body
|
||||
|
||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.PostAuthOtpVerify(ctx.UserContext(), request.(PostAuthOtpVerifyRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "PostAuthOtpVerify")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else if validResponse, ok := response.(PostAuthOtpVerifyResponseObject); ok {
|
||||
if err := validResponse.VisitPostAuthOtpVerifyResponse(ctx); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
} else if response != nil {
|
||||
return fmt.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user