github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/apiguard/tykgen/configuration.go (about)

     1  /*
     2   * Tyk Gateway API
     3   *
     4   * The Tyk Gateway API is the primary means for integrating your application with the Tyk API Gateway system. This API is very small, and has no granular permissions system. It is intended to be used purely for internal automation and integration.  **Warning: Under no circumstances should outside parties be granted access to this API.**  The Tyk Gateway API is capable of:  * Managing session objects (key generation) * Managing and listing policies * Managing and listing API Definitions (only when not using the Dashboard) * Hot reloads / reloading a cluster configuration * OAuth client creation (only when not using the Dashboard)   In order to use the Gateway API, you'll need to set the `secret` parameter in your tyk.conf file.  The shared secret you set should then be sent along as a header with each Gateway API Request in order for it to be successful:  ``` x-tyk-authorization: <your-secret> ``` <br/> <b>The Tyk Gateway API is subsumed by the Tyk Dashboard API in Pro installations.</b>
     5   *
     6   * API version: 5.5.0
     7   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     8   */
     9  package swagger
    10  
    11  import (
    12  	"net/http"
    13  )
    14  
    15  // contextKeys are used to identify the type of value in the context.
    16  // Since these are string, it is possible to get a short description of the
    17  // context key for logging and debugging using key.String().
    18  
    19  type contextKey string
    20  
    21  func (c contextKey) String() string {
    22  	return "auth " + string(c)
    23  }
    24  
    25  var (
    26  	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
    27  	ContextOAuth2 = contextKey("token")
    28  
    29  	// ContextBasicAuth takes BasicAuth as authentication for the request.
    30  	ContextBasicAuth = contextKey("basic")
    31  
    32  	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
    33  	ContextAccessToken = contextKey("accesstoken")
    34  
    35  	// ContextAPIKey takes an APIKey as authentication for the request
    36  	ContextAPIKey = contextKey("apikey")
    37  )
    38  
    39  // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
    40  type BasicAuth struct {
    41  	UserName string `json:"userName,omitempty"`
    42  	Password string `json:"password,omitempty"`
    43  }
    44  
    45  // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
    46  type APIKey struct {
    47  	Key    string
    48  	Prefix string
    49  }
    50  
    51  type Configuration struct {
    52  	BasePath      string            `json:"basePath,omitempty"`
    53  	Host          string            `json:"host,omitempty"`
    54  	Scheme        string            `json:"scheme,omitempty"`
    55  	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
    56  	UserAgent     string            `json:"userAgent,omitempty"`
    57  	HTTPClient    *http.Client
    58  }
    59  
    60  func NewConfiguration() *Configuration {
    61  	cfg := &Configuration{
    62  		BasePath:      "http://localhost/",
    63  		DefaultHeader: make(map[string]string),
    64  		UserAgent:     "Swagger-Codegen/1.0.0/go",
    65  	}
    66  	return cfg
    67  }
    68  
    69  func (c *Configuration) AddDefaultHeader(key string, value string) {
    70  	c.DefaultHeader[key] = value
    71  }