Documentation
¶
Overview ¶
Package mobile holds the profile manager implementation shared by the Android and iOS gomobile bindings. The platform packages (client/android, client/ios/NetBirdSDK) only adapt this API to gomobile-friendly types.
Index ¶
- func ReadProfileEmail(configPath string) string
- func WriteProfileEmail(configPath string, email string) error
- type Profile
- type ProfileManager
- func (pm *ProfileManager) AddProfile(displayName string) (*Profile, error)
- func (pm *ProfileManager) GetActiveConfigPath() (string, error)
- func (pm *ProfileManager) GetActiveProfile() (*Profile, error)
- func (pm *ProfileManager) GetActiveStateFilePath() (string, error)
- func (pm *ProfileManager) GetConfigPath(id string) (string, error)
- func (pm *ProfileManager) GetStateFilePath(id string) (string, error)
- func (pm *ProfileManager) ListProfiles() ([]Profile, error)
- func (pm *ProfileManager) LogoutProfile(id string) error
- func (pm *ProfileManager) ProfilePrefs(id string) (*profilemanager.Prefs, error)
- func (pm *ProfileManager) RemoveProfile(id string) error
- func (pm *ProfileManager) RenameProfile(id string, newName string) error
- func (pm *ProfileManager) SwitchProfile(id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadProfileEmail ¶
ReadProfileEmail returns the account email stored for the profile whose config lives at configPath. A missing or unreadable file yields "", which leaves the account choice to the IdP.
func WriteProfileEmail ¶
WriteProfileEmail records the account email for the profile whose config lives at configPath, so later logins can pass it as an OIDC login_hint. An empty email is ignored rather than blanking what is already stored.
Types ¶
type Profile ¶
type Profile struct {
ID string
Name string
// Email is the account this profile last logged in with, "" if it never
// completed an SSO login. Kept across logouts; cleared when the profile is
// removed. See profile_state.go.
Email string
IsActive bool
}
Profile is the platform-independent profile view handed to the bindings.
type ProfileManager ¶
type ProfileManager struct {
// contains filtered or unexported fields
}
ProfileManager manages profiles for the mobile platforms. It wraps the internal profilemanager.ServiceManager with mobile-specific path handling. All profile identity is ID-based; the human-readable name lives inside the profile config's Name field.
func NewProfileManager ¶
func NewProfileManager(configDir, username string) *ProfileManager
NewProfileManager creates a profile manager rooted at configDir, the app-writable directory that every process of the app can reach. username is the platform's fixed single-user context (a non-empty username is required by ServiceManager for non-default profiles).
func (*ProfileManager) AddProfile ¶
func (pm *ProfileManager) AddProfile(displayName string) (*Profile, error)
AddProfile creates a new profile with the given display name and a generated ID. It returns the created profile so the caller learns the ID.
func (*ProfileManager) GetActiveConfigPath ¶
func (pm *ProfileManager) GetActiveConfigPath() (string, error)
GetActiveConfigPath returns the config file path for the currently active profile.
func (*ProfileManager) GetActiveProfile ¶
func (pm *ProfileManager) GetActiveProfile() (*Profile, error)
GetActiveProfile returns the currently active profile, resolving its ID to the full profile so callers get the real display name.
func (*ProfileManager) GetActiveStateFilePath ¶
func (pm *ProfileManager) GetActiveStateFilePath() (string, error)
GetActiveStateFilePath returns the state file path for the currently active profile.
func (*ProfileManager) GetConfigPath ¶
func (pm *ProfileManager) GetConfigPath(id string) (string, error)
GetConfigPath returns the config file path for the given profile ID. The platform code should call this instead of constructing paths itself.
func (*ProfileManager) GetStateFilePath ¶
func (pm *ProfileManager) GetStateFilePath(id string) (string, error)
GetStateFilePath returns the state file path for the given profile ID.
func (*ProfileManager) ListProfiles ¶
func (pm *ProfileManager) ListProfiles() ([]Profile, error)
ListProfiles returns all available profiles, including the default profile, with their active status set.
func (*ProfileManager) LogoutProfile ¶
func (pm *ProfileManager) LogoutProfile(id string) error
LogoutProfile clears authentication data for a profile by removing its private key and SSH key from the config, forcing a re-login. The management URL and other settings are preserved.
func (*ProfileManager) ProfilePrefs ¶
func (pm *ProfileManager) ProfilePrefs(id string) (*profilemanager.Prefs, error)
ProfilePrefs returns the namespaced per-profile preference store of the profile identified by id.
func (*ProfileManager) RemoveProfile ¶
func (pm *ProfileManager) RemoveProfile(id string) error
RemoveProfile deletes a profile. The default profile and the active profile cannot be removed.
func (*ProfileManager) RenameProfile ¶
func (pm *ProfileManager) RenameProfile(id string, newName string) error
RenameProfile changes the display name of the profile identified by id. The on-disk filename (the ID) is left unchanged.
func (*ProfileManager) SwitchProfile ¶
func (pm *ProfileManager) SwitchProfile(id string) error
SwitchProfile records the given profile ID as the active profile. The caller must stop the VPN tunnel before switching.