Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(tr *http.Transport) *http.Client
- type APIResponse
- type AppAddResponse
- type AppInfoResponse
- type AppListResponse
- type ApplicationDescriptor
- type GlobalConfig
- type GroupAddResponse
- type GroupDescriptor
- type GroupInfoResponse
- type GroupListResponse
- type GroupMemberListResponse
- type GroupMemberResponse
- type LogEntriesByTimestamp
- type LogEntry
- type LogsResponse
- type NSSConfig
- type PingResponse
- type RadiusDescriptor
- type RadiusInfoResponse
- type RadiusListResponse
- type Response
- type SSHConfig
- type SecurePass
- func (s *SecurePass) AppAdd(app *ApplicationDescriptor) (*AppAddResponse, error)
- func (s *SecurePass) AppDel(app string) (*Response, error)
- func (s *SecurePass) AppInfo(app string) (*AppInfoResponse, error)
- func (s *SecurePass) AppList(realm string) (*AppListResponse, error)
- func (s *SecurePass) AppMod(appID string, app *ApplicationDescriptor) (*Response, error)
- func (s *SecurePass) DoRequest(req *http.Request, obj APIResponse, expstatus int) error
- func (s *SecurePass) GroupAdd(group *GroupDescriptor) (*GroupAddResponse, error)
- func (s *SecurePass) GroupDel(group string) (*Response, error)
- func (s *SecurePass) GroupInfo(group string) (*GroupInfoResponse, error)
- func (s *SecurePass) GroupList(realm string) (*GroupListResponse, error)
- func (s *SecurePass) GroupMember(user, group string) (*GroupMemberResponse, error)
- func (s *SecurePass) GroupMemberAdd(username string, group string) (*Response, error)
- func (s *SecurePass) GroupMemberDel(username string, group string) (*Response, error)
- func (s *SecurePass) GroupMemberList(group string) (*GroupMemberListResponse, error)
- func (s *SecurePass) GroupXattrsDelete(group, attribute string) (*Response, error)
- func (s *SecurePass) GroupXattrsList(group string) (*XattrsListResponse, error)
- func (s *SecurePass) GroupXattrsSet(group, attribute, value string) (*Response, error)
- func (s *SecurePass) Logs(realm, start, end string) (*LogsResponse, error)
- func (s *SecurePass) NewRequest(method, path string, data *url.Values) (*http.Request, error)
- func (s *SecurePass) Ping() (*PingResponse, error)
- func (s *SecurePass) RadiusAdd(radius *RadiusDescriptor) (*Response, error)
- func (s *SecurePass) RadiusDel(ipaddr string) (*Response, error)
- func (s *SecurePass) RadiusInfo(ipaddr string) (*RadiusInfoResponse, error)
- func (s *SecurePass) RadiusList(realm string) (*RadiusListResponse, error)
- func (s *SecurePass) RadiusMod(radiusID string, radius *RadiusDescriptor) (*Response, error)
- func (s *SecurePass) RealmXattrsDelete(realm, attribute string) (*Response, error)
- func (s *SecurePass) RealmXattrsList(realm string) (*XattrsListResponse, error)
- func (s *SecurePass) RealmXattrsSet(realm, attribute, value string) (*Response, error)
- func (s *SecurePass) UserAdd(user *UserDescriptor) (*UserAddResponse, error)
- func (s *SecurePass) UserAuth(username, secret string) (*UserAuthResponse, error)
- func (s *SecurePass) UserDel(username string) (*Response, error)
- func (s *SecurePass) UserDisable(username string) (*Response, error)
- func (s *SecurePass) UserEnable(username string) (*Response, error)
- func (s *SecurePass) UserInfo(username string) (*UserInfoResponse, error)
- func (s *SecurePass) UserList(realm string) (*UserListResponse, error)
- func (s *SecurePass) UserMod(username string, user *UserDescriptor) (*Response, error)
- func (s *SecurePass) UserPasswordChange(username, password string) (*Response, error)
- func (s *SecurePass) UserPasswordDisable(username string) (*Response, error)
- func (s *SecurePass) UserProvision(username, token string) (*Response, error)
- func (s *SecurePass) UserXattrsDelete(username, attribute string) (*Response, error)
- func (s *SecurePass) UserXattrsList(username string) (*XattrsListResponse, error)
- func (s *SecurePass) UserXattrsSet(username, attribute, value string) (*Response, error)
- type UserAddResponse
- type UserAuthResponse
- type UserDescriptor
- type UserInfoResponse
- type UserListResponse
- type XattrsDescriptor
- type XattrsListResponse
Examples ¶
Constants ¶
const ( // DefaultRemote is the default Content-Type header used in HTTP requests DefaultRemote = "https://beta.secure-pass.net" // ContentType is the default Content-Type header used in HTTP requests ContentType = "application/json" // UserAgent contains the default User-Agent value used in HTTP requests UserAgent = "SecurePass CLI" )
Variables ¶
DebugLogger collects all debug messages
Functions ¶
Types ¶
type APIResponse ¶
APIResponse gives access to the response details
type AppAddResponse ¶
type AppAddResponse struct {
AppID string `json:"APP_ID"`
AppSecret string `json:"APP_SECRET"`
Response
}
AppAddResponse describes the expected response from the /api/v1/apps/add
type AppInfoResponse ¶
type AppInfoResponse struct {
ApplicationDescriptor
Response
}
AppInfoResponse encapsulates the /api/v1/apps/info call's HTTP response
type AppListResponse ¶
AppListResponse encapsulates the /api/v1/apps HTTP response
type ApplicationDescriptor ¶
type ApplicationDescriptor struct {
Label string `json:"label"`
Realm string `json:"realm"`
Group string `json:"group"`
Write bool `json:"write"`
AllowNetworkIPv4 string `json:"allow_network_ipv4"`
AllowNetworkIPv6 string `json:"allow_network_ipv6"`
Privacy bool `json:"privacy"`
}
ApplicationDescriptor describes the basic attributes of a Securepass application
type GlobalConfig ¶
type GlobalConfig struct {
SecurePass `ini:"default"`
NSSConfig `ini:"nss"`
SSHConfig `ini:"ssh"`
}
GlobalConfig encapsulates the SecurePass's whole configuration
type GroupAddResponse ¶
GroupAddResponse encapsulates the /api/v1/users/add HTTP response
type GroupDescriptor ¶
type GroupDescriptor struct {
Group string `json:"GROUP"`
Description string `json:"DESCRIPTION"`
Realm string `json:"REALM"`
}
GroupDescriptor defines attributes of Group
type GroupInfoResponse ¶
type GroupInfoResponse struct {
GroupDescriptor
Response
}
GroupInfoResponse encapsulates the information of a group
type GroupListResponse ¶
GroupListResponse encapsulates the list of groups
type GroupMemberListResponse ¶
GroupMemberListResponse encapsulates the list of users in a group
type GroupMemberResponse ¶
GroupMemberResponse encapsulates whether a group belogs to a member
type LogEntriesByTimestamp ¶
type LogEntriesByTimestamp []LogEntry
LogEntriesByTimestamp sorts log entries by timestamp
func (LogEntriesByTimestamp) Len ¶
func (l LogEntriesByTimestamp) Len() int
func (LogEntriesByTimestamp) Less ¶
func (l LogEntriesByTimestamp) Less(i, j int) bool
func (LogEntriesByTimestamp) Swap ¶
func (l LogEntriesByTimestamp) Swap(i, j int)
type LogEntry ¶
type LogEntry struct {
// SecurePass response is currently broken, this
// should be a time.Time object.
Timestamp string
UUID string
Message string
Level int
App string
Realm string
}
LogEntry is a SecurePass application's log entry
type LogsResponse ¶
LogsResponse encapsulates SecurePass application's logs
type NSSConfig ¶
type NSSConfig struct {
Realm string `ini:"realm"`
DefaultGid int `ini:"default_gid"`
DefaultHome string `ini:"default_home"`
DefaultShell string `ini:"default_shell"`
}
NSSConfig encapsulates the SecurePass's config section '[nss]'
type PingResponse ¶
PingResponse represents the /api/v1/ping call's HTTP response
type RadiusDescriptor ¶
type RadiusDescriptor struct {
Radius string
Name string
Secret string
Group string
Realm string
Rfid bool
}
RadiusDescriptor defines the attributes of SecurePass RADIUS devices
type RadiusInfoResponse ¶
type RadiusInfoResponse struct {
RadiusDescriptor
Response
}
RadiusInfoResponse encapsulates the /api/v1/radius/info call's HTTP response
type RadiusListResponse ¶
RadiusListResponse encapsulates the /api/v1/radius HTTP response
type Response ¶
type Response struct {
APIResponse
ErrorMsg string
RC int
}
Response is the base type for API calls responses
func (*Response) ErrorMessage ¶
ErrorMessage returns the API call's text message
type SecurePass ¶
type SecurePass struct {
AppID string `ini:"app_id"`
AppSecret string `ini:"app_secret"`
Endpoint string `ini:"endpoint"`
}
SecurePass main object type
Example ¶
fmt.Println(testInstance.AppID) fmt.Println(testInstance.AppSecret) fmt.Println(testInstance.Endpoint)
Output: ce64dc90d88b11e5b001de2f4665c1f2@ci.secure-pass.net E2m6HawI743as61Kv0OhyPb6wAewXnwVkLLcF82rKOWe1SJ0Wd https://beta.secure-pass.net
func (*SecurePass) AppAdd ¶
func (s *SecurePass) AppAdd(app *ApplicationDescriptor) (*AppAddResponse, error)
AppAdd represents /api/v1/apps/add
Example ¶
var (
resp APIResponse
addResponse *AppAddResponse
infoResponse *AppInfoResponse
fixtureAppID string
)
// Create a new app
addResponse, _ = testInstance.AppAdd(&ApplicationDescriptor{
Label: appLabel,
})
fixtureAppID = addResponse.AppID
fmt.Println(addResponse.ErrorCode())
fmt.Println(addResponse.ErrorMessage() == "")
// Check for its existence
resp, _ = testInstance.AppInfo(fixtureAppID)
fmt.Println(resp.ErrorCode())
// Modify it
resp, _ = testInstance.AppMod(fixtureAppID, &ApplicationDescriptor{
Write: false,
Label: appLabel + "newLabel",
Privacy: true,
})
fmt.Println(resp.ErrorCode())
// Check whether the modifcations have been applied
infoResponse, _ = testInstance.AppInfo(fixtureAppID)
fmt.Println(infoResponse.Label == appLabel+"newLabel")
// Remove it
resp, _ = testInstance.AppDel(fixtureAppID)
fmt.Println(resp.ErrorCode())
// Check whether it does not longer exist
resp, _ = testInstance.AppInfo(fixtureAppID)
fmt.Println(resp.ErrorCode())
Output: 0 true 0 0 true 0 10
func (*SecurePass) AppDel ¶
func (s *SecurePass) AppDel(app string) (*Response, error)
AppDel deletes an application from SecurePass
func (*SecurePass) AppInfo ¶
func (s *SecurePass) AppInfo(app string) (*AppInfoResponse, error)
AppInfo retrieves information on a SecurePass application
func (*SecurePass) AppList ¶
func (s *SecurePass) AppList(realm string) (*AppListResponse, error)
AppList retrieves the list of applications available in SecurePass
Example ¶
var resp APIResponse
resp, err := testInstance.AppList("")
fmt.Println(resp.ErrorCode())
fmt.Println(err)
Output: 0 <nil>
func (*SecurePass) AppMod ¶
func (s *SecurePass) AppMod(appID string, app *ApplicationDescriptor) (*Response, error)
AppMod represents /api/v1/apps/modify
func (*SecurePass) DoRequest ¶
func (s *SecurePass) DoRequest(req *http.Request, obj APIResponse, expstatus int) error
DoRequest issues an HTTP request
func (*SecurePass) GroupAdd ¶
func (s *SecurePass) GroupAdd(group *GroupDescriptor) (*GroupAddResponse, error)
GroupAdd issues requests to /api/v1/groups/add
func (*SecurePass) GroupDel ¶
func (s *SecurePass) GroupDel(group string) (*Response, error)
GroupDel deletes a user from SecurePass
func (*SecurePass) GroupInfo ¶
func (s *SecurePass) GroupInfo(group string) (*GroupInfoResponse, error)
GroupList issues requests to /api/v1/groups/info
func (*SecurePass) GroupList ¶
func (s *SecurePass) GroupList(realm string) (*GroupListResponse, error)
GroupList issues requests to /api/v1/groups/list
func (*SecurePass) GroupMember ¶
func (s *SecurePass) GroupMember(user, group string) (*GroupMemberResponse, error)
GroupMember issues requests to /api/v1/groups/member
func (*SecurePass) GroupMemberAdd ¶
func (s *SecurePass) GroupMemberAdd(username string, group string) (*Response, error)
GroupMemberAdd issues requests to /api/v1/groups/members/add
func (*SecurePass) GroupMemberDel ¶
func (s *SecurePass) GroupMemberDel(username string, group string) (*Response, error)
GroupMemberDel issues requests to /api/v1/groups/members/delete
func (*SecurePass) GroupMemberList ¶
func (s *SecurePass) GroupMemberList(group string) (*GroupMemberListResponse, error)
GroupMemberList issues requests to /api/v1/groups/member/list
func (*SecurePass) GroupXattrsDelete ¶
func (s *SecurePass) GroupXattrsDelete(group, attribute string) (*Response, error)
GroupXattrsDelete deletes an attribute from group's extended attributes
func (*SecurePass) GroupXattrsList ¶
func (s *SecurePass) GroupXattrsList(group string) (*XattrsListResponse, error)
GroupXattrsList lists group's extended attributes
func (*SecurePass) GroupXattrsSet ¶
func (s *SecurePass) GroupXattrsSet(group, attribute, value string) (*Response, error)
RealmXattrsSet set realm's extended attributes
func (*SecurePass) Logs ¶
func (s *SecurePass) Logs(realm, start, end string) (*LogsResponse, error)
Logs retrieves application logs
func (*SecurePass) NewRequest ¶
NewRequest initializes and issues an HTTP request to the SecurePass endpoint
func (*SecurePass) Ping ¶
func (s *SecurePass) Ping() (*PingResponse, error)
Ping issues requests to the /api/v1/ping API endpoint
Example ¶
resp, err := testInstance.Ping() fmt.Println(err) fmt.Println(resp.IPVersion) fmt.Println(resp.ErrorCode()) fmt.Println(resp.ErrorMessage())
Output: <nil> 4 0
func (*SecurePass) RadiusAdd ¶
func (s *SecurePass) RadiusAdd(radius *RadiusDescriptor) (*Response, error)
RadiusAdd adds a RADIUS to SecurePass RADIUS
func (*SecurePass) RadiusDel ¶
func (s *SecurePass) RadiusDel(ipaddr string) (*Response, error)
RadiusDel deletes a RADIUS device from SecurePass
func (*SecurePass) RadiusInfo ¶
func (s *SecurePass) RadiusInfo(ipaddr string) (*RadiusInfoResponse, error)
RadiusInfo retrieves information on a SecurePass RADIUS device
func (*SecurePass) RadiusList ¶
func (s *SecurePass) RadiusList(realm string) (*RadiusListResponse, error)
RadiusList retrieves the list of RADIUS devices available in SecurePass
func (*SecurePass) RadiusMod ¶
func (s *SecurePass) RadiusMod(radiusID string, radius *RadiusDescriptor) (*Response, error)
RadiusMod modify a RADIUS device available in SecurePass
func (*SecurePass) RealmXattrsDelete ¶
func (s *SecurePass) RealmXattrsDelete(realm, attribute string) (*Response, error)
RealmXattrsDelete deletes an attribute from realm's extended attributes
func (*SecurePass) RealmXattrsList ¶
func (s *SecurePass) RealmXattrsList(realm string) (*XattrsListResponse, error)
RealmXattrsList lists realm's extended attributes
func (*SecurePass) RealmXattrsSet ¶
func (s *SecurePass) RealmXattrsSet(realm, attribute, value string) (*Response, error)
RealmXattrsSet set realm's extended attributes
func (*SecurePass) UserAdd ¶
func (s *SecurePass) UserAdd(user *UserDescriptor) (*UserAddResponse, error)
UserAdd issues requests to /api/v1/users/add
func (*SecurePass) UserAuth ¶
func (s *SecurePass) UserAuth(username, secret string) (*UserAuthResponse, error)
UserAuth issues requests to /api/v1/users/auth
func (*SecurePass) UserDel ¶
func (s *SecurePass) UserDel(username string) (*Response, error)
UserDel deletes a user from SecurePass
func (*SecurePass) UserDisable ¶
func (s *SecurePass) UserDisable(username string) (*Response, error)
UserDisable disables a user
func (*SecurePass) UserEnable ¶
func (s *SecurePass) UserEnable(username string) (*Response, error)
UserEnable enables a user
func (*SecurePass) UserInfo ¶
func (s *SecurePass) UserInfo(username string) (*UserInfoResponse, error)
UserInfo issues requests to /api/v1/users/info
func (*SecurePass) UserList ¶
func (s *SecurePass) UserList(realm string) (*UserListResponse, error)
UserList issues requests to /api/v1/users/list
func (*SecurePass) UserMod ¶
func (s *SecurePass) UserMod(username string, user *UserDescriptor) (*Response, error)
Modify a user in SecurePass
func (*SecurePass) UserPasswordChange ¶
func (s *SecurePass) UserPasswordChange(username, password string) (*Response, error)
UserPasswordChange change user password
func (*SecurePass) UserPasswordDisable ¶
func (s *SecurePass) UserPasswordDisable(username string) (*Response, error)
UserPasswordDisable disable a user's password
func (*SecurePass) UserProvision ¶
func (s *SecurePass) UserProvision(username, token string) (*Response, error)
UserProvision provisions a user with a token
func (*SecurePass) UserXattrsDelete ¶
func (s *SecurePass) UserXattrsDelete(username, attribute string) (*Response, error)
UserXattrsDelete deletes an attribute from user's extended attributes
func (*SecurePass) UserXattrsList ¶
func (s *SecurePass) UserXattrsList(username string) (*XattrsListResponse, error)
UserXattrsList lists user's extended attributes
func (*SecurePass) UserXattrsSet ¶
func (s *SecurePass) UserXattrsSet(username, attribute, value string) (*Response, error)
UserXattrsSet set user's extended attributes
type UserAddResponse ¶
UserAddResponse encapsulates the /api/v1/users/add HTTP response
type UserAuthResponse ¶
UserAuthResponse encapsulates the /api/v1/users/auth HTTP response
type UserDescriptor ¶
type UserDescriptor struct {
Username string `json:"USERNAME"`
Name string `json:"NAME"`
Surname string `json:"SURNAME"`
Email string `json:"EMAIL"`
Mobile string `json:"MOBILE"`
Nin string `json:"NIN"`
Rfid string `json:"RFID"`
Manager string `json:"MANAGER"`
Seclevel string `json:"SECLEVEL"`
Type string
Password bool
Enabled bool
Token string
}
UserDescriptor defines the attributes of SecurePass users
type UserInfoResponse ¶
type UserInfoResponse struct {
UserDescriptor
Response
}
UserInfoResponse encapsulates the /api/v1/users/info HTTP response
type UserListResponse ¶
UserListResponse encapsulates the /api/v1/users HTTP response
type XattrsDescriptor ¶
type XattrsDescriptor map[string]interface{}
XattrsDescriptor defines a set of extended attributes
type XattrsListResponse ¶
type XattrsListResponse XattrsDescriptor
XattrsListResponse encapsulates a xattrs HTTP response
func (*XattrsListResponse) ErrorCode ¶
func (r *XattrsListResponse) ErrorCode() int
ErrorCode returns the API call's numeric return code
func (*XattrsListResponse) ErrorMessage ¶
func (r *XattrsListResponse) ErrorMessage() string
ErrorMessage returns the API call's text message
