securepassctl

package module
v0.0.0-...-0346970 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2017 License: MIT Imports: 8 Imported by: 0

README

GoDoc Travis-CI Status Coverage

securepassctl

Go (golang) port of the SecurePass tool

Usage

$ spctl -h
Usage: spctl [global options] command [command options] [arguments...]
Manage distributed identities.
  
  --debug, -D	enable debug output
  --help, -h	show help
  --version, -v	print the version
  
Commands:
    ping		ping a SecurePass's remote endpoint
    app			manage applications
    config		configure SecurePass
    group-member	test group membership
    logs		display SecurePass logs
    radius		manage RADIUS information
    realm		manage realm settings
    user		manage users
    help, h		Shows a list of commands or help for one command
    

spctl home page: <https://github.com/garlsecurity/securepassctl>
SecurePass online help: <http://www.secure-pass.net/integration-guides-examples/>
Report bugs to <https://github.com/garlsecurity/securepassctl/issues>

Documentation

Index

Examples

Constants

View Source
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

View Source
var DebugLogger = log.New(ioutil.Discard, "", log.LstdFlags)

DebugLogger collects all debug messages

Functions

func NewClient

func NewClient(tr *http.Transport) *http.Client

NewClient initialize http.Client with a certain http.Transport

Types

type APIResponse

type APIResponse interface {
	ErrorCode() int
	ErrorMessage() string
}

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

type AppListResponse struct {
	AppID []string `json:"APP_ID"`
	Response
}

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

type GroupAddResponse struct {
	Group string
	Response
}

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

type GroupListResponse struct {
	Group []string
	Response
}

GroupListResponse encapsulates the list of groups

type GroupMemberListResponse

type GroupMemberListResponse struct {
	Members []string
	Response
}

GroupMemberListResponse encapsulates the list of users in a group

type GroupMemberResponse

type GroupMemberResponse struct {
	Member bool
	Response
}

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

type LogsResponse struct {
	Logs map[string]LogEntry
	Response
}

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

type PingResponse struct {
	IP        string
	IPVersion int `json:"ip_version"`
	Response
}

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

type RadiusListResponse struct {
	IPAddrs []string `json:"radius"`
	Response
}

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) ErrorCode

func (r *Response) ErrorCode() int

ErrorCode returns the API call's numeric return code

func (*Response) ErrorMessage

func (r *Response) ErrorMessage() string

ErrorMessage returns the API call's text message

type SSHConfig

type SSHConfig struct {
	Root        string `ini:"root"`
	StripDomain string `ini:"strip_windows_domain"`
}

SSHConfig encapsulates the SecurePass's config section '[ssh]'

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

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

func (s *SecurePass) NewRequest(method, path string, data *url.Values) (*http.Request, error)

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

type UserAddResponse struct {
	Username string
	Response
}

UserAddResponse encapsulates the /api/v1/users/add HTTP response

type UserAuthResponse

type UserAuthResponse struct {
	Authenticated bool
	Response
}

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

type UserListResponse struct {
	Username []string
	Response
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL