Documentation
¶
Index ¶
- func HasRealAppSecret(secret string) bool
- func RuntimeAppSecret(secret string) string
- type Account
- type AccountProvider
- type CredentialProvider
- func (p *CredentialProvider) ResolveAccount(ctx context.Context) (*Account, error)
- func (p *CredentialProvider) ResolveIdentityHint(ctx context.Context) (*IdentityHint, error)
- func (p *CredentialProvider) ResolveToken(ctx context.Context, req TokenSpec) (*TokenResult, error)
- func (p *CredentialProvider) SetWarnOut(warnOut io.Writer) *CredentialProvider
- type DefaultAccountProvider
- type DefaultAccountResolver
- type DefaultTokenProvider
- type DefaultTokenResolver
- type IdentityHint
- type MalformedTokenResultError
- type TokenProvider
- type TokenResult
- type TokenSpec
- type TokenType
- type TokenUnavailableError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasRealAppSecret ¶
HasRealAppSecret reports whether secret is an actual app secret rather than an empty/token-only marker or the internal runtime placeholder.
func RuntimeAppSecret ¶
RuntimeAppSecret returns the SDK-compatible app secret used at runtime. Token-only sources intentionally have no real secret; this helper injects a private placeholder so downstream SDK validation can proceed while callers still distinguish real secrets with HasRealAppSecret.
Types ¶
type Account ¶
type Account struct {
ProfileName string
AppID string
AppSecret string
Brand core.LarkBrand
DefaultAs core.Identity
UserOpenId string
UserName string
SupportedIdentities uint8
}
Account is the credential-layer view of the active runtime account. It intentionally mirrors only the resolved fields needed by runtime auth and identity selection, without exposing core.CliConfig as a dependency.
func AccountFromCliConfig ¶
AccountFromCliConfig copies the resolved config view into a credential.Account.
func (*Account) ToCliConfig ¶
ToCliConfig copies the credential-layer account into the downstream config shape.
type AccountProvider ¶
AccountProvider resolves app credentials. Returns nil, nil to indicate "I don't handle this, try next provider".
type CredentialProvider ¶
type CredentialProvider struct {
// contains filtered or unexported fields
}
CredentialProvider is the unified entry point for all credential resolution.
func NewCredentialProvider ¶
func NewCredentialProvider(providers []extcred.Provider, defaultAcct DefaultAccountResolver, defaultToken DefaultTokenResolver, httpClient func() (*http.Client, error)) *CredentialProvider
NewCredentialProvider creates a CredentialProvider.
func (*CredentialProvider) ResolveAccount ¶
func (p *CredentialProvider) ResolveAccount(ctx context.Context) (*Account, error)
ResolveAccount resolves app credentials. Result is cached after first call. NOTE: Uses sync.Once — only the context from the first call is used for resolution. Subsequent calls return the cached result regardless of their context. This is acceptable for CLI (single invocation per process) but not for long-running servers.
func (*CredentialProvider) ResolveIdentityHint ¶
func (p *CredentialProvider) ResolveIdentityHint(ctx context.Context) (*IdentityHint, error)
ResolveIdentityHint resolves default/auto identity guidance from the selected source. NOTE: Uses sync.Once — only the context from the first call is used for resolution. This matches ResolveAccount and keeps identity decisions stable within one CLI invocation.
func (*CredentialProvider) ResolveToken ¶
func (p *CredentialProvider) ResolveToken(ctx context.Context, req TokenSpec) (*TokenResult, error)
ResolveToken resolves an access token.
func (*CredentialProvider) SetWarnOut ¶
func (p *CredentialProvider) SetWarnOut(warnOut io.Writer) *CredentialProvider
type DefaultAccountProvider ¶
type DefaultAccountProvider struct {
// contains filtered or unexported fields
}
DefaultAccountProvider resolves account from config.json via keychain.
func NewDefaultAccountProvider ¶
func NewDefaultAccountProvider(kc keychain.KeychainAccess, profile string) *DefaultAccountProvider
func (*DefaultAccountProvider) ResolveAccount ¶
func (p *DefaultAccountProvider) ResolveAccount(ctx context.Context) (*Account, error)
type DefaultAccountResolver ¶
DefaultAccountResolver is implemented by the default account provider.
type DefaultTokenProvider ¶
type DefaultTokenProvider struct {
// contains filtered or unexported fields
}
DefaultTokenProvider resolves UAT/TAT using keychain + direct HTTP calls. No SDK/LarkClient dependency — eliminates circular dependency with Factory.
func NewDefaultTokenProvider ¶
func NewDefaultTokenProvider(defaultAcct *DefaultAccountProvider, httpClient func() (*http.Client, error), errOut io.Writer) *DefaultTokenProvider
func (*DefaultTokenProvider) ResolveToken ¶
func (p *DefaultTokenProvider) ResolveToken(ctx context.Context, req TokenSpec) (*TokenResult, error)
type DefaultTokenResolver ¶
type DefaultTokenResolver interface {
ResolveToken(ctx context.Context, req TokenSpec) (*TokenResult, error)
}
DefaultTokenResolver is implemented by the default token provider.
type IdentityHint ¶
IdentityHint is credential-layer guidance for resolving the effective identity.
type MalformedTokenResultError ¶
MalformedTokenResultError reports that a source returned an invalid token payload.
func (*MalformedTokenResultError) Error ¶
func (e *MalformedTokenResultError) Error() string
type TokenProvider ¶
type TokenProvider interface {
ResolveToken(ctx context.Context, req TokenSpec) (*TokenResult, error)
}
TokenProvider resolves a runtime access token. Top-level resolvers should return a non-nil token or an error. Chain participants may use nil, nil internally to indicate "try next source".
type TokenResult ¶
type TokenResult struct {
Token string
Scopes string // optional, space-separated; empty = skip scope pre-check
}
TokenResult is the output of TokenProvider.ResolveToken.
type TokenSpec ¶
type TokenSpec struct {
Type TokenType
AppID string // identifies which app (multi-account); not sensitive
}
TokenSpec is the input to TokenProvider.ResolveToken.
type TokenType ¶
type TokenType string
TokenType distinguishes UAT from TAT. Uses string constants matching extension/credential.TokenType for zero-cost conversion.
func ParseTokenType ¶
ParseTokenType converts a string to TokenType.
type TokenUnavailableError ¶
type TokenUnavailableError struct {
}
TokenUnavailableError reports that no usable token was available.
func (*TokenUnavailableError) Error ¶
func (e *TokenUnavailableError) Error() string