github.com/annwntech/go-micro/v2@v2.9.5/auth/provider/options.go (about)

     1  package provider
     2  
     3  // Option returns a function which sets an option
     4  type Option func(*Options)
     5  
     6  // Options a provider can have
     7  type Options struct {
     8  	// ClientID is the application's ID.
     9  	ClientID string
    10  	// ClientSecret is the application's secret.
    11  	ClientSecret string
    12  	// Endpoint for the provider
    13  	Endpoint string
    14  	// Redirect url incase of UI
    15  	Redirect string
    16  	// Scope of the oauth request
    17  	Scope string
    18  }
    19  
    20  // Credentials is an option which sets the client id and secret
    21  func Credentials(id, secret string) Option {
    22  	return func(o *Options) {
    23  		o.ClientID = id
    24  		o.ClientSecret = secret
    25  	}
    26  }
    27  
    28  // Endpoint sets the endpoint option
    29  func Endpoint(e string) Option {
    30  	return func(o *Options) {
    31  		o.Endpoint = e
    32  	}
    33  }
    34  
    35  // Redirect sets the Redirect option
    36  func Redirect(r string) Option {
    37  	return func(o *Options) {
    38  		o.Redirect = r
    39  	}
    40  }
    41  
    42  // Scope sets the oauth scope
    43  func Scope(s string) Option {
    44  	return func(o *Options) {
    45  		o.Scope = s
    46  	}
    47  }