Documentation ¶
Overview ¶
Package ipa is a Go client library for FreeIPA
Package ipa is a Go client library for FreeIPA
Index ¶
- Constants
- Variables
- type Algorithm
- type Client
- func (c *Client) AddGroupToGroup(groupCn string, groupName string) (*GroupRecord, error)
- func (c *Client) AddTOTPToken(uid string, algo Algorithm, digits Digits, interval int) (*OTPToken, error)
- func (c *Client) AddUserToGroup(groupCn string, userUid string) (*GroupRecord, error)
- func (c *Client) ChangePassword(uid, old_passwd, new_passwd, otpcode string) error
- func (c *Client) CheckGroupExist(cn string) (bool, error)
- func (c *Client) CheckGroupMemberOfGroup(memberGroupName, groupName string) (bool, error)
- func (c *Client) CheckUserExist(uid string) (bool, error)
- func (c *Client) CheckUserMemberOfGroup(userName, groupName string) (bool, error)
- func (c *Client) ClearSession()
- func (c *Client) DisableOTPToken(tokenID string) error
- func (c *Client) EnableOTPToken(tokenID string) error
- func (c *Client) FetchOTPTokens(uid string) ([]*OTPToken, error)
- func (c *Client) GroupAdd(cn string) (*GroupRecord, error)
- func (c *Client) GroupDelete(cn string) error
- func (c *Client) GroupShow(cn string) (*GroupRecord, error)
- func (c *Client) Login(username, password string) error
- func (c *Client) LoginWithKeytab(ktab, username string) error
- func (c *Client) Ping() (*Response, error)
- func (c *Client) RemoteLogin(uid, passwd string) error
- func (c *Client) RemoveOTPToken(tokenID string) error
- func (c *Client) RemoveUserFromGroup(groupCn string, userUid string) error
- func (c *Client) ResetPassword(uid string) (string, error)
- func (c *Client) SessionID() string
- func (c *Client) SetAuthTypes(uid string, types []string) error
- func (c *Client) SetPassword(uid, old_passwd, new_passwd, otpcode string) error
- func (c *Client) StickySession(enable bool)
- func (c *Client) UpdateMobileNumber(uid string, number string) error
- func (c *Client) UpdateSSHPubKeys(uid string, keys []string) ([]string, error)
- func (c *Client) UserAdd(uid, gid, email, first, last, title, homedir, shell string, random bool) (*UserRecord, error)
- func (c *Client) UserDisable(uid string) error
- func (c *Client) UserEnable(uid string) error
- func (c *Client) UserShow(uid string) (*UserRecord, error)
- type Digits
- type ErrExpiredPassword
- type ErrInvalidPassword
- type ErrPasswordPolicy
- type GroupRecord
- type IpaDateTime
- type IpaError
- type IpaString
- type OTPToken
- type Response
- type Result
- type UserRecord
Constants ¶
const ( IpaClientVersion = "2.156" IpaDatetimeFormat = "20060102150405Z" )
const ( AlgorithmSHA1 Algorithm = "SHA1" AlgorithmSHA256 = "SHA256" AlgorithmSHA384 = "SHA384" AlgorithmSHA512 = "SHA512" )
Variables ¶
var ErrorGroupRecordNotInitialized = errors.New("group record is not initialized")
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm string
OTP Token hash Algorithms supported by FreeIPA
func (*Algorithm) UnmarshalJSON ¶
Unmarshal a FreeIPA string from an array of strings and convert to an Algorithm. Uses the first value in the array as the value of the string.
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 ¶
func NewDefaultClient() *Client
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) AddGroupToGroup ¶ added in v0.0.10
func (c *Client) AddGroupToGroup(groupCn string, groupName string) (*GroupRecord, error)
func (*Client) AddTOTPToken ¶
func (c *Client) AddTOTPToken(uid string, algo Algorithm, digits Digits, interval int) (*OTPToken, error)
Add TOTP token. Returns new OTPToken
func (*Client) AddUserToGroup ¶
func (c *Client) AddUserToGroup(groupCn string, userUid string) (*GroupRecord, error)
func (*Client) ChangePassword ¶
Change user password. This will run the passwd ipa command. Optionally provide an OTP if required
func (*Client) CheckGroupMemberOfGroup ¶ added in v0.0.10
func (*Client) CheckUserMemberOfGroup ¶
func (*Client) DisableOTPToken ¶
Disable OTP token.
func (*Client) EnableOTPToken ¶
Enable OTP token.
func (*Client) FetchOTPTokens ¶
Fetch all OTP tokens.
func (*Client) GroupDelete ¶
func (*Client) LoginWithKeytab ¶
Login to FreeIPA using local kerberos login with keytab and username
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) RemoveUserFromGroup ¶
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) UpdateMobileNumber ¶
Update mobile number. Currently will store only a single number. Any existing numbers will be overwritten.
func (*Client) UpdateSSHPubKeys ¶
Update ssh public keys for user uid. Returns the fingerprints on success.
type Digits ¶
type Digits int
Number of digits each OTP token code will have
func (*Digits) UnmarshalJSON ¶
Unmarshal a FreeIPA string from an array of strings and convert to Digits. Uses the first value in the array as the value of the string.
type ErrExpiredPassword ¶
type ErrExpiredPassword struct { }
FreeIPA Expired Password Error
func (*ErrExpiredPassword) Error ¶
func (e *ErrExpiredPassword) Error() string
type ErrInvalidPassword ¶
type ErrInvalidPassword struct { }
FreeIPA Invalid Password Error
func (*ErrInvalidPassword) Error ¶
func (e *ErrInvalidPassword) Error() string
type ErrPasswordPolicy ¶
type ErrPasswordPolicy struct { }
FreeIPA Password Policy Error
func (*ErrPasswordPolicy) Error ¶
func (e *ErrPasswordPolicy) Error() string
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"` Groups []string `json:"member_group"` }
func (*GroupRecord) GetUsers ¶
func (g *GroupRecord) GetUsers() ([]string, error)
type IpaDateTime ¶
Custom FreeIPA datetime type
func (*IpaDateTime) Format ¶
func (dt *IpaDateTime) Format(layout string) string
func (*IpaDateTime) MarshalBinary ¶
func (dt *IpaDateTime) MarshalBinary() (data []byte, err error)
func (*IpaDateTime) String ¶
func (dt *IpaDateTime) String() string
func (*IpaDateTime) UnmarshalBinary ¶
func (dt *IpaDateTime) UnmarshalBinary(data []byte) error
func (*IpaDateTime) UnmarshalJSON ¶
func (dt *IpaDateTime) UnmarshalJSON(b []byte) error
Unmarshal 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"]}'
type IpaString ¶
type IpaString string
Custom FreeIPA string type
func (*IpaString) UnmarshalJSON ¶
Unmarshal a FreeIPA string from an array of strings. Uses the first value in the array as the value of the string.
type OTPToken ¶
type OTPToken struct { DN string `json:"dn"` Algorithm Algorithm `json:"ipatokenotpalgorithm"` Digits Digits `json:"ipatokenotpdigits"` Owner IpaString `json:"ipatokenowner"` TimeStep IpaString `json:"ipatokentotptimestep"` UUID IpaString `json:"ipatokenuniqueid"` ManagedBy IpaString `json:"managedby_user"` Disabled IpaString `json:"ipatokendisabled"` Type string `json:"type"` URI string `json:"uri"` }
OTPToken encapsulates FreeIPA otptokens
type Response ¶
type Response struct { Error *IpaError `json:"error"` Id string `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 UserRecord ¶
type UserRecord struct { Dn string `json:"dn"` First IpaString `json:"givenname"` Last IpaString `json:"sn"` DisplayName IpaString `json:"displayname"` Title IpaString `json:"title"` Principal IpaString `json:"krbprincipalname"` Uid IpaString `json:"uid"` UidNumber IpaString `json:"uidnumber"` GidNumber IpaString `json:"gidnumber"` Groups []string `json:"memberof_group"` SSHPubKeys []string `json:"ipasshpubkey"` SSHPubKeyFps []string `json:"sshpubkeyfp"` AuthTypes []string `json:"ipauserauthtype"` HasKeytab bool `json:"has_keytab"` HasPassword bool `json:"has_password"` NSAccountLock bool `json:"nsaccountlock"` HomeDir IpaString `json:"homedirectory"` Email IpaString `json:"mail"` Mobile IpaString `json:"mobile"` Shell IpaString `json:"loginshell"` SudoRules IpaString `json:"memberofindirect_sudorule"` HbacRules IpaString `json:"memberofindirect_hbacrule"` LastPasswdChange IpaDateTime `json:"krblastpwdchange"` PasswdExpire IpaDateTime `json:"krbpasswordexpiration"` PrincipalExpire IpaDateTime `json:"krbprincipalexpiration"` LastLoginSuccess IpaDateTime `json:"krblastsuccessfulauth"` LastLoginFail IpaDateTime `json:"krblastfailedauth"` Randompassword string `json:"randompassword"` }
UserRecord encapsulates user data returned from ipa user commands
func (*UserRecord) HasGroup ¶
func (u *UserRecord) HasGroup(group string) bool
Returns true if the User is in group
func (*UserRecord) OTPOnly ¶
func (u *UserRecord) OTPOnly() bool
Returns true if OTP is the only authentication type enabled