Help us shape the future of Go! Take the 2026 Go Developer Survey

localauthentication

package
v0.0.0-...-1c168f8 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package localauthentication binds LAContext of Apple's LocalAuthentication framework without cgo, to authenticate the user with Touch ID or the device password.

It works only on macOS.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = cf.ErrUnavailable

ErrUnavailable reports a function or class missing from the running macOS.

Functions

This section is empty.

Types

type Code

type Code int

Code is an LAError code. It can be compared with an *Error through errors.Is.

const (
	ErrAuthenticationFailed  Code = -1
	ErrUserCancel            Code = -2
	ErrUserFallback          Code = -3
	ErrSystemCancel          Code = -4
	ErrPasscodeNotSet        Code = -5
	ErrBiometryNotAvailable  Code = -6
	ErrBiometryNotEnrolled   Code = -7
	ErrBiometryLockout       Code = -8
	ErrAppCancel             Code = -9
	ErrInvalidContext        Code = -10
	ErrCompanionNotAvailable Code = -11
	ErrBiometryNotPaired     Code = -12
	ErrBiometryDisconnected  Code = -13
	ErrInvalidDimensions     Code = -14
	ErrNotInteractive        Code = -1004
)

func (Code) Error

func (c Code) Error() string

type Context

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

Context is an LAContext. It is released when it becomes unreachable.

func NewContext

func NewContext() (*Context, error)

NewContext creates an LAContext.

func (*Context) CFTypeRef

func (c *Context) CFTypeRef() uintptr

CFTypeRef returns the underlying LAContext, such as for calls through purego/objc. The caller must keep c reachable while using it. Pass c itself as the value of security.UseAuthenticationContext.

func (*Context) CanEvaluatePolicy

func (c *Context) CanEvaluatePolicy(policy Policy) error

CanEvaluatePolicy calls canEvaluatePolicy:error: and returns nil when the policy can be evaluated.

func (*Context) EvaluatePolicy

func (c *Context) EvaluatePolicy(policy Policy, reason string) error

EvaluatePolicy calls evaluatePolicy:localizedReason:reply: and waits for the reply. It returns nil when the user is authenticated.

func (*Context) Invalidate

func (c *Context) Invalidate()

Invalidate calls invalidate, which cancels a pending evaluation.

func (*Context) SetLocalizedCancelTitle

func (c *Context) SetLocalizedCancelTitle(title string)

SetLocalizedCancelTitle sets localizedCancelTitle.

func (*Context) SetLocalizedFallbackTitle

func (c *Context) SetLocalizedFallbackTitle(title string)

SetLocalizedFallbackTitle sets localizedFallbackTitle. An empty title hides the fallback button.

func (*Context) SetTouchIDAuthenticationAllowableReuseDuration

func (c *Context) SetTouchIDAuthenticationAllowableReuseDuration(d time.Duration)

SetTouchIDAuthenticationAllowableReuseDuration sets touchIDAuthenticationAllowableReuseDuration.

type Error

type Error struct {
	Domain      string
	Code        int
	Description string
}

Error is an NSError returned by LocalAuthentication.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is reports whether target is the Code of an LAError.

type Policy

type Policy int

Policy is an LAPolicy.

const (
	PolicyDeviceOwnerAuthenticationWithBiometrics            Policy = 1
	PolicyDeviceOwnerAuthentication                          Policy = 2
	PolicyDeviceOwnerAuthenticationWithCompanion             Policy = 3
	PolicyDeviceOwnerAuthenticationWithBiometricsOrCompanion Policy = 4
)

Jump to

Keyboard shortcuts

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