loginv2

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package loginv2 provides the REST AuthN v2 explicit login client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod is the explicit REST AuthN v2 login method.

const (
	AuthMethodPassword AuthMethod = "password"
	AuthMethodPhoneOTP AuthMethod = "phone_otp"
	AuthMethodWechat   AuthMethod = "wechat"
	AuthMethodWecom    AuthMethod = "wecom"
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the REST AuthN v2 login endpoint.

func NewClient

func NewClient(baseURL string, opts ...Option) (*Client, error)

NewClient creates a REST AuthN v2 login client.

baseURL may be the IAM origin or an IAM /api/v2 URL. The client normalizes it to call POST /api/v2/authn/login.

func (*Client) Login

func (c *Client) Login(ctx context.Context, req LoginRequest) (*TokenPair, error)

Login posts an explicit REST AuthN v2 login request.

type LoginRequest

type LoginRequest struct {
	AuthMethod    AuthMethod `json:"auth_method"`
	MethodPayload any        `json:"method_payload"`
	DeviceID      string     `json:"device_id,omitempty"`
}

LoginRequest is the REST AuthN v2 login request.

func (LoginRequest) Validate

func (r LoginRequest) Validate() error

Validate checks only the public REST v2 contract boundary.

type Option

type Option func(*Client)

Option customizes the REST AuthN v2 login client.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the HTTP client used for requests.

func WithHeader

func WithHeader(key, value string) Option

WithHeader adds a static header to every request.

type PasswordPayload

type PasswordPayload struct {
	Username string `json:"username"`
	Password string `json:"password"`
	TenantID uint64 `json:"tenant_id,omitempty"`
}

PasswordPayload is the password login payload.

type PhoneOTPPayload

type PhoneOTPPayload struct {
	Phone   string `json:"phone"`
	OTPCode string `json:"otp_code"`
}

PhoneOTPPayload is the phone OTP login payload.

type TokenPair

type TokenPair struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

TokenPair is the successful login token pair.

type WechatPayload

type WechatPayload struct {
	AppID string `json:"app_id"`
	Code  string `json:"code"`
}

WechatPayload is the WeChat mini program login payload.

type WecomPayload

type WecomPayload struct {
	CorpID   string `json:"corp_id"`
	AuthCode string `json:"auth_code"`
}

WecomPayload is the WeCom login payload.

Jump to

Keyboard shortcuts

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