* auth provider mock interface * Auth Provider Options * Implement API Server Auth Package * Add weh utils * Add Login URL * Auth Provider Options * Add auth provider scope and setting token in cookie * Remove auth_login_url flag Co-authored-by: Asim Aslam <asim@aslam.me> Co-authored-by: Ben Toogood <ben@micro.mu>
		
			
				
	
	
		
			48 lines
		
	
	
		
			945 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			945 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package provider
 | 
						|
 | 
						|
// Option returns a function which sets an option
 | 
						|
type Option func(*Options)
 | 
						|
 | 
						|
// Options a provider can have
 | 
						|
type Options struct {
 | 
						|
	// ClientID is the application's ID.
 | 
						|
	ClientID string
 | 
						|
	// ClientSecret is the application's secret.
 | 
						|
	ClientSecret string
 | 
						|
	// Endpoint for the provider
 | 
						|
	Endpoint string
 | 
						|
	// Redirect url incase of UI
 | 
						|
	Redirect string
 | 
						|
	// Scope of the oauth request
 | 
						|
	Scope string
 | 
						|
}
 | 
						|
 | 
						|
// Credentials is an option which sets the client id and secret
 | 
						|
func Credentials(id, secret string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.ClientID = id
 | 
						|
		o.ClientSecret = secret
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// Endpoint sets the endpoint option
 | 
						|
func Endpoint(e string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Endpoint = e
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// Redirect sets the Redirect option
 | 
						|
func Redirect(r string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Redirect = r
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// Scope sets the oauth scope
 | 
						|
func Scope(s string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Scope = s
 | 
						|
	}
 | 
						|
}
 |