seclient

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewRemoteAuthClient

func NewRemoteAuthClient(opts ...AuthClientOptions) *remoteAuthClient

func Use

func Use()

func WithNonEmptyURLValues

func WithNonEmptyURLValues(mappedValues map[string][]string) url.Values

WithNonEmptyURLValues will accept a map[key][values] and convert it to a url.Values. The function will check that the values, typed []string has a length > 0. Otherwise, will not insert the key into the url.Values

Types

type AuthClientOption

type AuthClientOption struct {
	Client            httpclient.Client
	ServiceName       string
	BaseUrl           string
	PwdLoginPath      string
	SwitchContextPath string
	ClientId          string
	ClientSecret      string
}

type AuthClientOptions

type AuthClientOptions func(opt *AuthClientOption)

type AuthOption

type AuthOption struct {
	Password         string   // Password is used by password login
	AccessToken      string   // AccessToken is used by switch user/tenant
	Username         string   // Username is used by password login and switch user
	UserId           string   // UserId is used by switch user
	TenantId         string   // TenantId is used by password login and switch user/tenant
	TenantExternalId string   // TenantExternalId is used by password login and switch user/tenant
	Scopes           []string // OAuth Scopes option
	ClientID         string   // ClientID that is used for the client credentials auth flow
	ClientSecret     string   // ClientSecret that is used for the client credentials auth flow
}

type AuthOptions

type AuthOptions func(opt *AuthOption)

func WithAccessToken

func WithAccessToken(accessToken string) AuthOptions

func WithAuthentication

func WithAuthentication(auth security.Authentication) AuthOptions

func WithClientAuth

func WithClientAuth(clientID, secret string) AuthOptions

func WithCredentials

func WithCredentials(username, password string) AuthOptions

func WithCurrentSecurity

func WithCurrentSecurity(ctx context.Context) AuthOptions

func WithScope

func WithScope(scope []string) AuthOptions

func WithTenant

func WithTenant(tenantId string, tenantExternalId string) AuthOptions

WithTenant create an options that specify tenant by either tenantId or tenantExternalId username and userId are exclusive, cannot be both empty

func WithTenantExternalId

func WithTenantExternalId(tenantExternalId string) AuthOptions

func WithTenantId

func WithTenantId(tenantId string) AuthOptions

func WithUser

func WithUser(userId string, username string) AuthOptions

WithUser create an options that specify user by either username or userId username and userId are exclusive, cannot be both empty

func WithUserId

func WithUserId(userId string) AuthOptions

func WithUsername

func WithUsername(username string) AuthOptions

type AuthenticationClient

type AuthenticationClient interface {
	PasswordLogin(ctx context.Context, opts ...AuthOptions) (*Result, error)
	ClientCredentials(ctx context.Context, opts ...AuthOptions) (*Result, error)
	SwitchUser(ctx context.Context, opts ...AuthOptions) (*Result, error)
	SwitchTenant(ctx context.Context, opts ...AuthOptions) (*Result, error)
}

type Result

type Result struct {
	Request oauth2.OAuth2Request
	Token   oauth2.AccessToken
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL