Documentation ¶
Index ¶
- Constants
- func DieIf(err error)
- func IndentedJSON(originalJSON interface{}) ([]byte, error)
- func JSONBodyDecoder(resp *http.Response, out interface{}) error
- func JSONReader(v interface{}) (io.Reader, error)
- func LoadAPIKeyFromEnvOrConfig(configFile string) string
- func LoadCompanyIDFromEnvOrConfig(configFile string) string
- func LoadEndPointURL(configFile string) string
- func Log(prefix, message string)
- func PrintIndentedJSON(originalJSON interface{}) error
- type APIResultStatus
- type APIResultStatusForPasswordResetting
- type DeactivationMode
- type Event
- type EventService
- type Events
- type FolderService
- type JSONLastPassTime
- type LastPassClient
- type LastPassConfig
- type Service
- type SharedFolder
- type User
- type UserService
- func (s *UserService) BatchAdd(users []User) error
- func (s *UserService) DeleteUser(name string, mode DeactivationMode) error
- func (s *UserService) DisableMultifactor(username string) (*APIResultStatus, error)
- func (s *UserService) GetAdminUserData() ([]User, error)
- func (s *UserService) GetAllUsers() ([]User, error)
- func (s *UserService) GetDisabledUsers() ([]User, error)
- func (s *UserService) GetInactiveUsers() ([]User, error)
- func (s *UserService) GetNon2faUsers() ([]User, error)
- func (s *UserService) GetUserData(userName string) (user User, err error)
- func (s *UserService) ResetPassword(username string) (*APIResultStatusForPasswordResetting, error)
- func (s *UserService) UpdateUser(user User) error
Constants ¶
const ( // LastPassFormat is a format used LastPass Provisioning API LastPassFormat = "2006-01-02 15:04:05" // LastPassTimeZone is only location acceptable to LastPass Provisioning API LastPassTimeZone = "US/Eastern" )
Variables ¶
This section is empty.
Functions ¶
func IndentedJSON ¶
IndentedJSON returns api.
func JSONBodyDecoder ¶
JSONBodyDecoder reads the next JSON-encoded value from its input and stores it in the value pointed to by out.
func JSONReader ¶
JSONReader reads the value and converts it to JSON-encoded value
func LoadAPIKeyFromEnvOrConfig ¶
LoadAPIKeyFromEnvOrConfig returns API Key from either Env or LastPassConfig file If Env `LASTPASS_APIKEY` exists, that will be prioritized.
func LoadCompanyIDFromEnvOrConfig ¶
LoadCompanyIDFromEnvOrConfig returns Company ID provided by Lastpass.
func LoadEndPointURL ¶
LoadEndPointURL returns endpoint url
func PrintIndentedJSON ¶
func PrintIndentedJSON(originalJSON interface{}) error
PrintIndentedJSON output indented json via stdout.
Types ¶
type APIResultStatus ¶
type APIResultStatus struct { Status string `json:"status,omitempty"` Errors string `json:"error,omitempty"` }
APIResultStatus is a status of response from LastPass API {"status":"FAIL","error":"No such user: masayoshi.umeda@moneyforward.co.jp"}
func (*APIResultStatus) Error ¶
func (s *APIResultStatus) Error() error
func (*APIResultStatus) IsOK ¶
func (s *APIResultStatus) IsOK() bool
IsOK checks status of response from LastPass
func (*APIResultStatus) String ¶
func (s *APIResultStatus) String() string
type APIResultStatusForPasswordResetting ¶
type APIResultStatusForPasswordResetting struct { Status string `json:"status,omitempty"` Errors []string `json:"error,omitempty"` }
APIResultStatusForPasswordResetting has different format... {"status":"FAIL","error":["user not found: masayoshi.umeda@moneyforward.co.jp"]}
func (*APIResultStatusForPasswordResetting) Error ¶
func (s *APIResultStatusForPasswordResetting) Error() error
func (*APIResultStatusForPasswordResetting) String ¶
func (s *APIResultStatusForPasswordResetting) String() string
type DeactivationMode ¶
type DeactivationMode int
DeactivationMode is enum which deactivate/delete users
const ( // Deactivate deactivates user Deactivate DeactivationMode = iota // Remove removes user from Org Remove // Delete deletes user account (completely) Delete )
type Event ¶
type Event struct { Time time.Time `json:"JSONTime"` Username string `json:"Username,omitempty"` IPAddress string `json:"IP_Address,omitempty"` Action string `json:"Action,omitempty"` Data string `json:"Data,omitempty"` ID string `json:"ID,omitempty"` }
Event represents event data in LastPass
func (Event) IsAuditEvent ¶
IsAuditEvent checks whether Event is one to be audited.
func (*Event) UnmarshalJSON ¶
UnmarshalJSON is written because it has a value(time) in a special format.
type EventService ¶
type EventService struct {
// contains filtered or unexported fields
}
EventService is a service class that handles event objects in LastPass.
func NewEventService ¶
func NewEventService(client *LastPassClient) (s *EventService)
NewEventService creates a new EventService
func (*EventService) GetAPIEventReports ¶
func (s *EventService) GetAPIEventReports(from, to JSONLastPassTime) (*Events, error)
GetAPIEventReports retrieves events triggered by API. We first call s.GetEventReport("api", "", from, to) will return error "Please select a valid user."
func (*EventService) GetAllEventReports ¶
func (s *EventService) GetAllEventReports(from, to JSONLastPassTime) (*Events, error)
GetAllEventReports fetches event of all users in certain period of time. Filtering is also available by setting search string.
func (*EventService) GetEventReport ¶
func (s *EventService) GetEventReport(username, search string, from, to JSONLastPassTime) (*Events, error)
GetEventReport fetches event of an user in certain period of time. Filtering is also available by setting search string.
type Events ¶
type Events struct {
Events []Event `json:"events"`
}
Events structure represents LastPass events.
func (*Events) ConvertTimezone ¶
ConvertTimezone overwrite events in new timezone.
func (*Events) GetUserEvents ¶
GetUserEvents get events from users
type FolderService ¶
type FolderService struct {
// contains filtered or unexported fields
}
FolderService is a service class that handles folder objects in LastPass.
func NewFolderService ¶
func NewFolderService(client *LastPassClient) (s *FolderService)
NewFolderService creates a new NewFolderService
func (*FolderService) GetSharedFolders ¶
func (s *FolderService) GetSharedFolders() ([]SharedFolder, error)
GetSharedFolders returns a JSON object containing information on all Shared Folders in the enterprise and the permissions granted to them. # Request
{ "cid": "8771312", "provhash": "<Your API secret>", "cmd": "getsfdata" }
Response ¶
{ "101": { "sharedfoldername": "ThisSFName", "score": 99, "users": [ { "username": "joe.user@lastpass.com", "readonly": 0, "give": 1, "can_administer": 1 }, { "username": "jane.user@lastpass.com", "readonly": 1, "give": 0, "can_administer": 0 } ] } }
type JSONLastPassTime ¶
JSONLastPassTime is a golang structure used in LastPass
func (JSONLastPassTime) Format ¶
func (j JSONLastPassTime) Format() string
Format returns a textual representation of the time value formatted in LastPass Format
func (JSONLastPassTime) MarshalJSON ¶
func (j JSONLastPassTime) MarshalJSON() ([]byte, error)
MarshalJSON encodes golang structure into json format
type LastPassClient ¶
type LastPassClient struct { URL *url.URL APIKey string Verbose bool UserAgent string Logger *log.Logger Headers http.Header CompanyID string }
LastPassClient is a Client that
func NewClient ¶
func NewClient(apiKey, endpointURL, companyID string, verbose bool) (*LastPassClient, error)
NewClient returns a general Client structure.
func NewLastPassClient ¶
func NewLastPassClient(configFilePath string) (*LastPassClient, error)
NewLastPassClient returns LastPass Client from confFile
type LastPassConfig ¶
type LastPassConfig struct { CompanyID string `yaml:"company_id"` EndPoint string `yaml:"end_point_url"` Secret string `yaml:"secret"` // API Key TimeZone string `yaml:"timezone,omitempty"` }
LastPassConfig is config structure for LastPass
func LoadConfig ¶
func LoadConfig(configFile string) (*LastPassConfig, error)
LoadConfig loads config file in YAML format.
type SharedFolder ¶
type SharedFolder struct {}
SharedFolder is a LastPass Object in which users share accounts.
type User ¶
type User struct { UserName string `json:"username"` FullName string `json:"fullname,omitempty"` MasterPasswordStrength string `json:"mpstrength,omitempty"` Created string `json:"created,omitempty"` LastPasswordChange string `json:"last_pw_change,omitempty"` LastLogin string `json:"lastlogin,omitempty"` Disabled bool `json:"disabled,omitempty"` NeverLoggedIn bool `json:"neverloggedin,omitempty"` LinkedAccount string `json:"linked,omitempty"` NumberOfSites float64 `json:"sites,omitempty"` NumberOfNotes float64 `json:"notes,omitempty"` NumberOfFormFills float64 `json:"formfills,omitempty"` NumberOfApplications float64 `json:"applications,omitempty"` NumberOfAttachments float64 `json:"attachment,omitempty"` Groups []string `json:"groups,omitempty"` Readonly string `json:"readonly,omitempty"` // ShareFolderの設定に利用. BoolでもなくIntでもない... Give string `json:"give,omitempty"` // ShareFolderの設定に利用 CanAdminister string `json:"can_administer,omitempty"` // ShareFolderの設定に利用 IsAdmin bool `json:"admin,omitempty"` Duousername string `json:"duousername,omitempty"` LastPwChange string `json:"last_pw_change,omitempty"` Mpstrength string `json:"mpstrength,omitempty"` Multifactor string `json:"multifactor,omitempty"` }
User is a structure
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService is a service class that sends a request to LastPass provisioning API.
func NewUserService ¶
func NewUserService(client *LastPassClient) (s *UserService)
NewUserService creates a new UserService
func (*UserService) BatchAdd ¶
func (s *UserService) BatchAdd(users []User) error
BatchAdd - add users.
func (*UserService) DeleteUser ¶
func (s *UserService) DeleteUser(name string, mode DeactivationMode) error
DeleteUser - delete individual users.
0 - Deactivate user. This blocks logins but retains data and enterprise membership 1 - Remove user. This removed the user from the enterprise but otherwise keeps the account itself active. 2 - Delete user. This will delete the account entirely.
func (*UserService) DisableMultifactor ¶
func (s *UserService) DisableMultifactor(username string) (*APIResultStatus, error)
DisableMultifactor disables multifactor setting of user
func (*UserService) GetAdminUserData ¶
func (s *UserService) GetAdminUserData() ([]User, error)
GetAdminUserData gets admin users
func (*UserService) GetAllUsers ¶
func (s *UserService) GetAllUsers() ([]User, error)
GetAllUsers simply retrieves all users
func (*UserService) GetDisabledUsers ¶
func (s *UserService) GetDisabledUsers() ([]User, error)
GetDisabledUsers gets Deactivated user(Deleted user in mode 0)
func (*UserService) GetInactiveUsers ¶
func (s *UserService) GetInactiveUsers() ([]User, error)
GetInactiveUsers is Deactivated user(Deleted user in mode 0)
func (*UserService) GetNon2faUsers ¶
func (s *UserService) GetNon2faUsers() ([]User, error)
GetNon2faUsers retrieves users without 2 factor authentication setting.
func (*UserService) GetUserData ¶
func (s *UserService) GetUserData(userName string) (user User, err error)
GetUserData gets information on users enterprise. Request
{ "cid": "8771312", "provhash": "<Your API secret>", "cmd": "getuserdata", "data": { "username": "user1@lastpass.com" // This can be either UserName, disabled, or admin } }
Response ¶
{ "Users": { "101": { "username": "user1@lastpass.com", "fullname": "Ned Flanders", "mpstrength": "100", "created": "2014-03-12 10:02:56", "last_pw_change": "2015-05-19 10:58:33", "last_login": "2015-05-29 11:45:05", "disabled": false, "neverloggedin": false, "linked": "personal.account@mydomain.com", "sites": 72, "notes": 19, "formfills": 2, "applications": 0, "attachments": 1, "groups": [ "Domain Admins", "Dev Team", "Support Team" ] } }, "Groups": { "Domain Admins": [ "user1@lastpass.com" ], "Dev Team": [ "user1@lastpass.com" ], "Support Team": [ "user1@lastpass.com" ] } }
func (*UserService) ResetPassword ¶
func (s *UserService) ResetPassword(username string) (*APIResultStatusForPasswordResetting, error)
ResetPassword reset password for the user
func (*UserService) UpdateUser ¶
func (s *UserService) UpdateUser(user User) error
UpdateUser updates user's info.