Documentation
¶
Overview ¶
Package ipa is a Go client library for FreeIPA
Package ipa is a Go client library for FreeIPA
Index ¶
- Constants
- Variables
- func ParseDateTime(str string) *time.Time
- type Client
- func (c *Client) AddOTPToken(token *OTPToken) (*OTPToken, error)
- func (c *Client) ChangePassword(username, old_passwd, new_passwd, otpcode string) error
- func (c *Client) CheckGroupExist(cn string) (bool, error)
- func (c *Client) CheckUserMemberOfGroup(userName, groupName string) (bool, error)
- func (c *Client) ClearSession()
- func (c *Client) DisableOTPToken(tokenUUID string) error
- func (c *Client) EnableOTPToken(tokenUUID string) error
- func (c *Client) FetchOTPTokens(owner string) ([]*OTPToken, error)
- func (c *Client) GroupAdd(cn string) (*GroupRecord, error)
- func (c *Client) GroupAddMember(groupCn string, userName string) (*GroupRecord, error)
- func (c *Client) GroupDelete(cn string) error
- func (c *Client) GroupRemoveMember(groupCn string, userUid string) error
- func (c *Client) GroupShow(cn string) (*GroupRecord, error)
- func (c *Client) HbacRuleAdd(name string) error
- func (c *Client) HbacRuleAddHost(hbacRuleName, hostgroupName string) error
- func (c *Client) HbacRuleAddService(hbacRuleName, hbacsvcgroup string) error
- func (c *Client) HbacRuleAddUser(hbacName string, groupName ...string) error
- func (c *Client) HbacRuleDelete(name string) error
- func (c *Client) HbacRuleRemoveUser(hbacName string, groupName ...string) error
- func (c *Client) Host() string
- func (c *Client) HostAdd(fqdn string, force bool, ipAddress string) error
- func (c *Client) HostDel(fqdn string) error
- func (c *Client) HostExists(name string) (bool, error)
- func (c *Client) HostGroupAdd(cn string) (*GroupRecord, error)
- func (c *Client) HostGroupAddMember(groupCn string, host string) (*GroupRecord, error)
- func (c *Client) HostGroupDelete(cn string) error
- func (c *Client) HostGroupRemoveMember(groupCn string, host string) error
- func (c *Client) Login(username, password string) error
- func (c *Client) LoginFromCCache(cpath string) error
- func (c *Client) LoginWithKeytab(ktab, username string) error
- func (c *Client) Passwd(userName, newPassword string) error
- func (c *Client) Ping() (*Response, error)
- func (c *Client) Realm() string
- func (c *Client) RefreshSessionID() error
- func (c *Client) RemoteLogin(uid, passwd string) error
- func (c *Client) RemoveOTPToken(tokenUUID string) error
- func (c *Client) ResetPassword(username string) (string, error)
- func (c *Client) SessionID() string
- func (c *Client) SetAuthTypes(username string, types []string) error
- func (c *Client) SetPassword(username, old_passwd, new_passwd, otpcode string) error
- func (c *Client) StickySession(enable bool)
- func (c *Client) SudoRuleAddUser(ruleName, groupName string) error
- func (c *Client) UserAdd(user *User, random bool) (*User, error)
- func (c *Client) UserAddWithPassword(user *User, password string) (*User, error)
- func (c *Client) UserDelete(preserve, stopOnError bool, usernames ...string) error
- func (c *Client) UserDisable(username string) error
- func (c *Client) UserEnable(username string) error
- func (c *Client) UserFind(options Options) ([]*User, error)
- func (c *Client) UserMod(user *User) (*User, error)
- func (c *Client) UserShow(username string) (*User, error)
- type GroupRecord
- type IpaError
- type OTPToken
- type Options
- type Response
- type Result
- type SSHAuthorizedKey
- type User
Constants ¶
const ( DefaultKerbConf = "/etc/krb5.conf" IpaClientVersion = "2.237" IpaDatetimeFormat = "20060102150405Z" )
const ( AlgorithmSHA1 string = "sha1" AlgorithmSHA256 = "sha256" AlgorithmSHA384 = "sha384" AlgorithmSHA512 = "sha512" )
OTP Token hash Algorithms supported by FreeIPA
const ( TokenTypeTOTP = "totp" TokenTypeHOTP = "hotp" )
OTP Token types supported by FreeIPA
Variables ¶
var ( // ErrPasswordPolicy is returned when a password does not conform to the password policy ErrPasswordPolicy = errors.New("password does not conform to policy") // ErrInvalidPassword is returned when a password is invalid ErrInvalidPassword = errors.New("invalid current password") // ErrExpiredPassword is returned when a password is expired ErrExpiredPassword = errors.New("password expired") ErrUnauthorized = errors.New("unauthorized") // ErrUserExists is returned when user account already exists ErrUserExists = errors.New("user exists") )
var ErrorGroupRecordNotInitialized = errors.New("group record is not initialized")
Functions ¶
func ParseDateTime ¶
Parse a FreeIPA datetime. Datetimes in FreeIPA are returned using a class-hint system. Values are stored as an array with a single element indicating the type and value, for example, '[{"__datetime__": "YYYY-MM-DDTHH:MM:SSZ"]}'
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
FreeIPA Client
func NewClientCustomHttp ¶
New IPA Client with host, realm and custom http client
func NewDefaultClient ¶
New default IPA Client using host and realm from /etc/ipa/default.conf
func NewDefaultClientWithSession ¶
New default IPA Client with existing sessionID using host and realm from /etc/ipa/default.conf
func (*Client) AddOTPToken ¶
Add OTP token. Returns new OTPToken
func (*Client) ChangePassword ¶
Change user password. This will run the passwd ipa command. Optionally provide an OTP if required
func (*Client) CheckUserMemberOfGroup ¶
func (*Client) DisableOTPToken ¶
Disable OTP token.
func (*Client) EnableOTPToken ¶
Enable OTP token.
func (*Client) FetchOTPTokens ¶
Fetch OTP tokens by owner.
func (*Client) GroupAddMember ¶
func (c *Client) GroupAddMember(groupCn string, userName string) (*GroupRecord, error)
func (*Client) GroupDelete ¶
func (*Client) GroupRemoveMember ¶
func (*Client) HbacRuleAdd ¶ added in v1.0.5
создать ноове правило hbac
func (*Client) HbacRuleAddHost ¶ added in v1.0.22
func (*Client) HbacRuleAddService ¶ added in v1.0.22
func (*Client) HbacRuleAddUser ¶ added in v1.0.5
добавить группы в правило hbac
func (*Client) HbacRuleDelete ¶ added in v1.0.5
func (*Client) HbacRuleRemoveUser ¶ added in v1.0.5
добавить пользователей в правило hbac
func (*Client) HostExists ¶ added in v1.0.7
todo тонкое место не совсем понятно как работает
func (*Client) HostGroupAdd ¶
func (c *Client) HostGroupAdd(cn string) (*GroupRecord, error)
func (*Client) HostGroupAddMember ¶
func (c *Client) HostGroupAddMember(groupCn string, host string) (*GroupRecord, error)
HostGroupAddMember добавляет сервер к группе узлов (под member тут имеется в виду сервер, пример :"ttt-ttt-tst08.tst.cloud.vimpelcom.ru")
func (*Client) HostGroupDelete ¶
func (*Client) HostGroupRemoveMember ¶
HostGroupRemoveMember удаляет сервер из группы узлов (под member тут имеется в виду сервер, пример :"ttt-ttt-tst08.tst.cloud.vimpelcom.ru")
func (*Client) LoginFromCCache ¶
Login to FreeIPA using credentials cache
func (*Client) LoginWithKeytab ¶
Login to FreeIPA using local kerberos login with keytab and username
func (*Client) RefreshSessionID ¶ added in v1.0.26
вызывается при ошибке rpc запроса, так как видимо sessionID имеет свойство "протухать"(сутки + видимо срок жизни), и от этого будут 401 ответы
func (*Client) RemoteLogin ¶
Login to FreeIPA using web API with uid/passwd and set the FreeIPA session id on the client for subsequent requests.
func (*Client) RemoveOTPToken ¶
Remove OTP token
func (*Client) ResetPassword ¶
Reset user password and return new random password
func (*Client) SetAuthTypes ¶
Update user authentication types.
func (*Client) SetPassword ¶
Set user password. In FreeIPA when a password is first set or when a password is later reset it is marked as immediately expired and requires the owner to perform a password change. See here https://www.freeipa.org/page/New_Passwords_Expired for more details. This function exists to circumvent the "new passwords expired" feature of FreeIPA and allow an administrator to set a new password for a user without it being expired. This is acheived, for example, by first calling ResetPassword() then immediately calling this function. *WARNING* See https://www.freeipa.org/page/Self-Service_Password_Reset for security issues and possible weaknesses of this approach.
func (*Client) SudoRuleAddUser ¶ added in v1.0.23
Добавить пользователей и группы, которых касается правило Sudo.
func (*Client) UserAdd ¶
Add new user. If random is true a random password will be created for the user. Note this requires "User Administrators" Privilege in FreeIPA.
func (*Client) UserAddWithPassword ¶
Add new user and set password. Note this requires "User Administrators" Privilege in FreeIPA.
func (*Client) UserDelete ¶
Delete user. If preserve is false the user will be permanetly deleted, if true the users is moved to the Delete container. If stopOnError is false the operation will be in continuous mode otherwise it will stop on errors
func (*Client) UserDisable ¶
Disable User Account
type GroupRecord ¶
type GroupRecord struct { Dn string `json:"dn"` Cn []string `json:"cn"` IpaUniqueId []string `json:"ipauniqueid"` GidNumber []string `json:"gidnumber"` ObjectClass []string `json:"objectclass"` Users []string `json:"member_user"` }
func (*GroupRecord) GetUsers ¶
func (g *GroupRecord) GetUsers() ([]string, error)
type OTPToken ¶
type OTPToken struct { DN string `json:"dn"` UUID string `json:"ipatokenuniqueid"` Algorithm string `json:"ipatokenotpalgorithm"` Digits int `json:"ipatokenotpdigits"` Owner string `json:"ipatokenowner"` TimeStep int `json:"ipatokentotptimestep"` ClockOffest int `json:"ipatokentotpclockoffset"` ManagedBy string `json:"managedby_user"` Enabled bool `json:"-"` Type string `json:"type"` URI string `json:"uri"` Description string `json:"description"` Vendor string `json:"ipatokenvendor"` Model string `json:"ipatokenmodel"` Serial string `json:"ipatokenserial"` NotBefore time.Time `json:"ipatokennotbefore"` NotAfter time.Time `json:"ipatokennotafter"` }
OTPToken encapsulates FreeIPA otptokens
var DefaultTOTPToken *OTPToken = &OTPToken{ Type: TokenTypeTOTP, Algorithm: AlgorithmSHA1, Digits: 6, TimeStep: 30, }
func (*OTPToken) DisplayName ¶
type Response ¶
type Response struct { Error *IpaError `json:"error"` ID int `json:"id"` Principal string `json:"principal"` Version string `json:"version"` Result *Result `json:"result"` }
Response returned from a FreeIPA JSON rpc call
type Result ¶
type Result struct { Summary string `json:"summary"` Value interface{} `json:"value"` Data json.RawMessage `json:"result"` }
Result returned from a FreeIPA JSON rpc call
type SSHAuthorizedKey ¶
type SSHAuthorizedKey struct { Comment string Options []string PublicKey ssh.PublicKey Fingerprint string }
SSH Public Key
func NewSSHAuthorizedKey ¶
func NewSSHAuthorizedKey(in string) (*SSHAuthorizedKey, error)
func (*SSHAuthorizedKey) MarshalJSON ¶
func (k *SSHAuthorizedKey) MarshalJSON() ([]byte, error)
func (*SSHAuthorizedKey) String ¶
func (k *SSHAuthorizedKey) String() string
type User ¶
type User struct { UUID string `json:"ipauniqueid"` EmployeeNumber string `json:"employeenumber"` CN string `json:"cn"` Gecos string `json:"gecos"` Title string `json:"title"` DepartmentNumber string `json:"departmentnumber"` L string `json:"l"` // town EmployeeID string `json:"employeeID"` PreferredLanguage string `json:"preferredlanguage"` OU string `json:"ou"` SetAttr string `json:"setattr"` DN string `json:"dn"` First string `json:"givenname"` Last string `json:"sn"` DisplayName string `json:"displayname"` Principal string `json:"krbprincipalname"` Username string `json:"uid"` Uid string `json:"uidnumber"` Gid string `json:"gidnumber"` Groups []string `json:"memberof_group"` SSHAuthKeys []*SSHAuthorizedKey `json:"ipasshpubkey"` AuthTypes []string `json:"ipauserauthtype"` HasKeytab bool `json:"has_keytab"` HasPassword bool `json:"has_password"` Locked bool `json:"nsaccountlock"` Preserved bool `json:"preserved"` HomeDir string `json:"homedirectory"` Email string `json:"mail"` TelephoneNumber string `json:"telephonenumber"` Mobile string `json:"mobile"` Shell string `json:"loginshell"` Category string `json:"userclass"` SudoRules []string `json:"memberofindirect_sudorule"` HbacRules []string `json:"memberofindirect_hbacrule"` LastPasswdChange *time.Time `json:"krblastpwdchange"` PasswdExpire *time.Time `json:"krbpasswordexpiration"` PrincipalExpire *time.Time `json:"krbprincipalexpiration"` LastLoginSuccess *time.Time `json:"krblastsuccessfulauth"` LastLoginFail *time.Time `json:"krblastfailedauth"` RandomPassword string `json:"randompassword"` Version string `json:"version"` }
User encapsulates user data returned from ipa user commands
func (*User) AddSSHAuthorizedKey ¶
func (u *User) AddSSHAuthorizedKey(key *SSHAuthorizedKey)
Add ssh authorized key
func (*User) FormatSSHAuthorizedKeys ¶
Format ssh authorized keys
func (*User) RemoveSSHAuthorizedKey ¶
Removes ssh authorized key