github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/well_known/get_well_known_openid_configuration.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Code generated by go-swagger; DO NOT EDIT.
    13  
    14  package well_known
    15  
    16  // This file was generated by the swagger tool.
    17  // Editing this file might prove futile when you re-run the generate command
    18  
    19  import (
    20  	"context"
    21  	"net/http"
    22  
    23  	"github.com/go-openapi/runtime/middleware"
    24  	"github.com/go-openapi/strfmt"
    25  	"github.com/go-openapi/swag"
    26  
    27  	"github.com/weaviate/weaviate/entities/models"
    28  )
    29  
    30  // GetWellKnownOpenidConfigurationHandlerFunc turns a function with the right signature into a get well known openid configuration handler
    31  type GetWellKnownOpenidConfigurationHandlerFunc func(GetWellKnownOpenidConfigurationParams, *models.Principal) middleware.Responder
    32  
    33  // Handle executing the request and returning a response
    34  func (fn GetWellKnownOpenidConfigurationHandlerFunc) Handle(params GetWellKnownOpenidConfigurationParams, principal *models.Principal) middleware.Responder {
    35  	return fn(params, principal)
    36  }
    37  
    38  // GetWellKnownOpenidConfigurationHandler interface for that can handle valid get well known openid configuration params
    39  type GetWellKnownOpenidConfigurationHandler interface {
    40  	Handle(GetWellKnownOpenidConfigurationParams, *models.Principal) middleware.Responder
    41  }
    42  
    43  // NewGetWellKnownOpenidConfiguration creates a new http.Handler for the get well known openid configuration operation
    44  func NewGetWellKnownOpenidConfiguration(ctx *middleware.Context, handler GetWellKnownOpenidConfigurationHandler) *GetWellKnownOpenidConfiguration {
    45  	return &GetWellKnownOpenidConfiguration{Context: ctx, Handler: handler}
    46  }
    47  
    48  /*
    49  	GetWellKnownOpenidConfiguration swagger:route GET /.well-known/openid-configuration well-known oidc discovery getWellKnownOpenidConfiguration
    50  
    51  # OIDC discovery information if OIDC auth is enabled
    52  
    53  OIDC Discovery page, redirects to the token issuer if one is configured
    54  */
    55  type GetWellKnownOpenidConfiguration struct {
    56  	Context *middleware.Context
    57  	Handler GetWellKnownOpenidConfigurationHandler
    58  }
    59  
    60  func (o *GetWellKnownOpenidConfiguration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
    61  	route, rCtx, _ := o.Context.RouteInfo(r)
    62  	if rCtx != nil {
    63  		*r = *rCtx
    64  	}
    65  	var Params = NewGetWellKnownOpenidConfigurationParams()
    66  	uprinc, aCtx, err := o.Context.Authorize(r, route)
    67  	if err != nil {
    68  		o.Context.Respond(rw, r, route.Produces, route, err)
    69  		return
    70  	}
    71  	if aCtx != nil {
    72  		*r = *aCtx
    73  	}
    74  	var principal *models.Principal
    75  	if uprinc != nil {
    76  		principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
    77  	}
    78  
    79  	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
    80  		o.Context.Respond(rw, r, route.Produces, route, err)
    81  		return
    82  	}
    83  
    84  	res := o.Handler.Handle(Params, principal) // actually handle the request
    85  	o.Context.Respond(rw, r, route.Produces, route, res)
    86  
    87  }
    88  
    89  // GetWellKnownOpenidConfigurationOKBody get well known openid configuration o k body
    90  //
    91  // swagger:model GetWellKnownOpenidConfigurationOKBody
    92  type GetWellKnownOpenidConfigurationOKBody struct {
    93  
    94  	// OAuth Client ID
    95  	ClientID string `json:"clientId,omitempty" yaml:"clientId,omitempty"`
    96  
    97  	// The Location to redirect to
    98  	Href string `json:"href,omitempty" yaml:"href,omitempty"`
    99  
   100  	// OAuth Scopes
   101  	Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
   102  }
   103  
   104  // Validate validates this get well known openid configuration o k body
   105  func (o *GetWellKnownOpenidConfigurationOKBody) Validate(formats strfmt.Registry) error {
   106  	return nil
   107  }
   108  
   109  // ContextValidate validates this get well known openid configuration o k body based on context it is used
   110  func (o *GetWellKnownOpenidConfigurationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   111  	return nil
   112  }
   113  
   114  // MarshalBinary interface implementation
   115  func (o *GetWellKnownOpenidConfigurationOKBody) MarshalBinary() ([]byte, error) {
   116  	if o == nil {
   117  		return nil, nil
   118  	}
   119  	return swag.WriteJSON(o)
   120  }
   121  
   122  // UnmarshalBinary interface implementation
   123  func (o *GetWellKnownOpenidConfigurationOKBody) UnmarshalBinary(b []byte) error {
   124  	var res GetWellKnownOpenidConfigurationOKBody
   125  	if err := swag.ReadJSON(b, &res); err != nil {
   126  		return err
   127  	}
   128  	*o = res
   129  	return nil
   130  }