Documentation
¶
Index ¶
- Constants
- func IsActionAllowed(rights []*types.UserRights, controller string, action string, index string, ...) int
- type Profile
- type ProfileSearchResult
- type Role
- type RoleSearchResult
- type Security
- func (s *Security) CreateCredentials(strategy, id string, body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) CreateFirstAdmin(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) CreateOrReplaceProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
- func (s *Security) CreateOrReplaceRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
- func (s *Security) CreateProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
- func (s *Security) CreateRestrictedUser(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) CreateRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
- func (s *Security) CreateUser(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) DeleteCredentials(strategy, id string, options types.QueryOptions) error
- func (s *Security) DeleteProfile(id string, options types.QueryOptions) (string, error)
- func (s *Security) DeleteRole(id string, options types.QueryOptions) (string, error)
- func (s *Security) DeleteUser(id string, options types.QueryOptions) (string, error)
- func (s *Security) GetAllCredentialFields(options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetCredentialFields(strategy string, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetCredentials(strategy, id string, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetCredentialsByID(strategy, id string, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetProfile(id string, options types.QueryOptions) (*Profile, error)
- func (s *Security) GetProfileMapping(options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetProfileRights(id string, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetRole(id string, options types.QueryOptions) (*Role, error)
- func (s *Security) GetRoleMapping(options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetUser(id string, options types.QueryOptions) (*User, error)
- func (s *Security) GetUserMapping(options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) GetUserRights(id string, options types.QueryOptions) (json.RawMessage, error)
- func (s *Security) HasCredentials(strategy, id string, options types.QueryOptions) (bool, error)
- func (s *Security) MDeleteCredentials(ids []string, options types.QueryOptions) ([]string, error)
- func (s *Security) MDeleteRoles(ids []string, options types.QueryOptions) ([]string, error)
- func (s *Security) MDeleteUsers(ids []string, options types.QueryOptions) ([]string, error)
- func (s *Security) MGetProfiles(ids []string, options types.QueryOptions) ([]*Profile, error)
- func (s *Security) MGetRoles(ids []string, options types.QueryOptions) ([]*Role, error)
- func (s *Security) ReplaceUser(id string, content json.RawMessage, options types.QueryOptions) (*User, error)
- func (s *Security) SearchProfiles(body json.RawMessage, options types.QueryOptions) (*ProfileSearchResult, error)
- func (s *Security) SearchRoles(body json.RawMessage, options types.QueryOptions) (*RoleSearchResult, error)
- func (s *Security) SearchUsers(body json.RawMessage, options types.QueryOptions) (*UserSearchResult, error)
- func (s *Security) UpdateCredentials(strategy string, kuid string, body json.RawMessage, options types.QueryOptions) error
- func (s *Security) UpdateProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
- func (s *Security) UpdateProfileMapping(body json.RawMessage, options types.QueryOptions) error
- func (s *Security) UpdateRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
- func (s *Security) UpdateRoleMapping(body json.RawMessage, options types.QueryOptions) error
- func (s *Security) UpdateUser(id string, body json.RawMessage, options types.QueryOptions) (*User, error)
- func (s *Security) UpdateUserMapping(body json.RawMessage, options types.QueryOptions) error
- func (s *Security) ValidateCredentials(strategy string, kuid string, body json.RawMessage, options types.QueryOptions) (bool, error)
- type User
- type UserSearchResult
Examples ¶
Constants ¶
const ( ActionIsAllowed = iota ActionIsConditional ActionIsDenied )
Variables ¶
This section is empty.
Functions ¶
func IsActionAllowed ¶
func IsActionAllowed(rights []*types.UserRights, controller string, action string, index string, collection string) int
IsActionAllowed indicates whether an action is allowed, denied or conditional based on user rights provided as the first argument. An action is defined as a couple of action and controller (mandatory), plus an index and a collection(optional).
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/security" "github.com/kuzzleio/sdk-go/types" ) func main() { userRights := []*types.UserRights{ {Controller: "wow-controller", Action: "*", Index: "much-index", Collection: "very-collection", Value: "allowed"}, } res := security.IsActionAllowed(userRights, "wow-controller", "such-action", "much-index", "very-collection") fmt.Println(res) }
Types ¶
type Profile ¶
func (*Profile) ProfileToJson ¶
type ProfileSearchResult ¶
type ProfileSearchResult struct { Aggregations json.RawMessage `json:"aggregations"` Hits []*Profile Total int `json:"total"` Fetched int ScrollId string `json:"scrollId"` // contains filtered or unexported fields }
func (*ProfileSearchResult) Next ¶
func (psr *ProfileSearchResult) Next() (*ProfileSearchResult, error)
Next returns the next page of profiles
func (*ProfileSearchResult) Options ¶
func (sr *ProfileSearchResult) Options() types.QueryOptions
func (*ProfileSearchResult) Request ¶
func (sr *ProfileSearchResult) Request() *types.KuzzleRequest
func (*ProfileSearchResult) Response ¶
func (sr *ProfileSearchResult) Response() *types.KuzzleResponse
type Role ¶
type Role struct { Id string `json:"_id"` Controllers map[string]*types.Controller }
func (*Role) RoleToJson ¶
type RoleSearchResult ¶
type RoleSearchResult struct { Aggregations json.RawMessage `json:"aggregations"` Hits []*Role Total int `json:"total"` Fetched int ScrollId string `json:"scrollId"` // contains filtered or unexported fields }
func (*RoleSearchResult) Next ¶
func (rsr *RoleSearchResult) Next() (*RoleSearchResult, error)
Next returns the next page of roles
func (*RoleSearchResult) Options ¶
func (sr *RoleSearchResult) Options() types.QueryOptions
func (*RoleSearchResult) Request ¶
func (sr *RoleSearchResult) Request() *types.KuzzleRequest
func (*RoleSearchResult) Response ¶
func (sr *RoleSearchResult) Response() *types.KuzzleResponse
type Security ¶
func NewSecurity ¶
NewSecurity returns a new instance of Security
func (*Security) CreateCredentials ¶
func (s *Security) CreateCredentials(strategy, id string, body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
CreateCredentials create credentials of the specified strategy with given body infos.
func (*Security) CreateFirstAdmin ¶
func (s *Security) CreateFirstAdmin(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
CreateFirstAdmin create credentials of the specified strategy with given body infos.
func (*Security) CreateOrReplaceProfile ¶
func (s *Security) CreateOrReplaceProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
CreateOrReplaceProfile creates or replaces (if _id matches an existing one) a profile with a list of policies.
func (*Security) CreateOrReplaceRole ¶
func (s *Security) CreateOrReplaceRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
CreateOrReplaceRole creates or replaces (if _id matches an existing one) a Role with a list of policies.
func (*Security) CreateProfile ¶
func (s *Security) CreateProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
CreateProfile creates or replaces (if _id matches an existing one) a profile with a list of policies.
func (*Security) CreateRestrictedUser ¶
func (s *Security) CreateRestrictedUser(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
CreateRestrictedUser create credentials of the specified strategy with given body infos.
func (*Security) CreateRole ¶
func (s *Security) CreateRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
CreateRole creates or replaces (if _id matches an existing one) a Role with a list of policies.
func (*Security) CreateUser ¶
func (s *Security) CreateUser(body json.RawMessage, options types.QueryOptions) (json.RawMessage, error)
CreateUser creates or replaces (if _id matches an existing one) a User with a list of policies.
func (*Security) DeleteCredentials ¶
func (s *Security) DeleteCredentials(strategy, id string, options types.QueryOptions) error
DeleteCredentials delete credentials of the specified strategy with given body infos.
func (*Security) DeleteProfile ¶
DeleteProfile deletes (if _id matches an existing one) a Profile with a list of policies.
func (*Security) DeleteRole ¶
DeleteRole creates or replaces (if _id matches an existing one) a Profile with a list of policies.
func (*Security) DeleteUser ¶
DeleteUser deletes (if _id matches an existing one) a Profile with a list of policies.
func (*Security) GetAllCredentialFields ¶
func (s *Security) GetAllCredentialFields(options types.QueryOptions) (json.RawMessage, error)
GetAllCredentialFields gets an array of strategy's fieldnames for each strategies
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { c := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(c, nil) res, err := k.Security.GetAllCredentialFields(nil) if err != nil { fmt.Println(err.Error()) return } fmt.Println(res) }
func (*Security) GetCredentialFields ¶
func (s *Security) GetCredentialFields(strategy string, options types.QueryOptions) (json.RawMessage, error)
GetCredentialFields gets an array of strategy's fieldnames
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { c := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(c, nil) res, err := k.Security.GetCredentialFields("local", nil) if err != nil { fmt.Println(err.Error()) return } fmt.Println(res) }
func (*Security) GetCredentials ¶
func (s *Security) GetCredentials(strategy, id string, options types.QueryOptions) (json.RawMessage, error)
func (*Security) GetCredentialsByID ¶
func (s *Security) GetCredentialsByID(strategy, id string, options types.QueryOptions) (json.RawMessage, error)
GetCredentialsByID recover credentials from given strategy identified by given id
func (*Security) GetProfile ¶
GetProfile fetch profile matching with given id
func (*Security) GetProfileMapping ¶
func (s *Security) GetProfileMapping(options types.QueryOptions) (json.RawMessage, error)
GetProfileMapping gets an array of strategy's fieldnames for each strategies
func (*Security) GetProfileRights ¶
func (s *Security) GetProfileRights(id string, options types.QueryOptions) (json.RawMessage, error)
GetProfileRights gets rights for given profile id
func (*Security) GetRoleMapping ¶
func (s *Security) GetRoleMapping(options types.QueryOptions) (json.RawMessage, error)
GetRoleMapping gets mapping for Roles
func (*Security) GetUserMapping ¶
func (s *Security) GetUserMapping(options types.QueryOptions) (json.RawMessage, error)
GetUserMapping gets mapping for Users
func (*Security) GetUserRights ¶
func (s *Security) GetUserRights(id string, options types.QueryOptions) (json.RawMessage, error)
GetUserRights gets rights for given profile id
func (*Security) HasCredentials ¶
HasCredentials check the existence of the specified strategy credentials for the id
func (*Security) MDeleteCredentials ¶
MDeleteCredentials deletes all credentials matching with given ids
func (*Security) MDeleteRoles ¶
MDeleteRoles deletes all roles matching with given ids
func (*Security) MDeleteUsers ¶
MDeleteUsers deletes all users matching with given ids
func (*Security) MGetProfiles ¶
MGetProfiles deletes all roles matching with given ids
func (*Security) ReplaceUser ¶
func (s *Security) ReplaceUser(id string, content json.RawMessage, options types.QueryOptions) (*User, error)
ReplaceUser replaces the matching user with the given one
func (*Security) SearchProfiles ¶
func (s *Security) SearchProfiles(body json.RawMessage, options types.QueryOptions) (*ProfileSearchResult, error)
func (*Security) SearchRoles ¶
func (s *Security) SearchRoles(body json.RawMessage, options types.QueryOptions) (*RoleSearchResult, error)
SearchRoles returns the roles matching the given query
func (*Security) SearchUsers ¶
func (s *Security) SearchUsers(body json.RawMessage, options types.QueryOptions) (*UserSearchResult, error)
SearchUsers retrieves the users matching the given query
func (*Security) UpdateCredentials ¶
func (s *Security) UpdateCredentials(strategy string, kuid string, body json.RawMessage, options types.QueryOptions) error
UpdateCredentials updates credentials of the specified strategy for the given user.
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { c := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(c, nil) err := k.Security.UpdateCredentials("local", "someId", []byte(`{"body": "test"}`), nil) if err != nil { fmt.Println(err.Error()) return } }
func (*Security) UpdateProfile ¶
func (s *Security) UpdateProfile(id string, body json.RawMessage, options types.QueryOptions) (*Profile, error)
func (*Security) UpdateProfileMapping ¶
func (s *Security) UpdateProfileMapping(body json.RawMessage, options types.QueryOptions) error
func (*Security) UpdateRole ¶
func (s *Security) UpdateRole(id string, body json.RawMessage, options types.QueryOptions) (*Role, error)
func (*Security) UpdateRoleMapping ¶
func (s *Security) UpdateRoleMapping(body json.RawMessage, options types.QueryOptions) error
func (*Security) UpdateUser ¶
func (s *Security) UpdateUser(id string, body json.RawMessage, options types.QueryOptions) (*User, error)
func (*Security) UpdateUserMapping ¶
func (s *Security) UpdateUserMapping(body json.RawMessage, options types.QueryOptions) error
func (*Security) ValidateCredentials ¶
func (s *Security) ValidateCredentials(strategy string, kuid string, body json.RawMessage, options types.QueryOptions) (bool, error)
ValidateCredentials validates credentials of the specified strategy for the given user.
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { c := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(c, nil) res, err := k.Security.ValidateCredentials("local", "someId", []byte(`{"body": "test"}`), nil) if err != nil { fmt.Println(err.Error()) return } fmt.Println(res) }
type User ¶
type UserSearchResult ¶
type UserSearchResult struct { Aggregations json.RawMessage `json:"aggregations"` Hits []*User Total int `json:"total"` Fetched int ScrollId string `json:"scrollId"` // contains filtered or unexported fields }
func (*UserSearchResult) Next ¶
func (usr *UserSearchResult) Next() (*UserSearchResult, error)
Next returns the next page of roles
func (*UserSearchResult) Options ¶
func (sr *UserSearchResult) Options() types.QueryOptions
func (*UserSearchResult) Request ¶
func (sr *UserSearchResult) Request() *types.KuzzleRequest
func (*UserSearchResult) Response ¶
func (sr *UserSearchResult) Response() *types.KuzzleResponse
Source Files
¶
- createCredentials.go
- createFirstAdmin.go
- createOrReplaceProfile.go
- createOrReplaceRole.go
- createProfile.go
- createRestrictedUser.go
- createRole.go
- createUser.go
- deleteCredentials.go
- deleteProfile.go
- deleteRole.go
- deleteUser.go
- getAllCredentialFields.go
- getCredentialFields.go
- getCredentials.go
- getCredentialsById.go
- getProfile.go
- getProfileMapping.go
- getProfileRights.go
- getRole.go
- getRoleMapping.go
- getUser.go
- getUserMapping.go
- getUserRights.go
- hasCredentials.go
- is_action_allowed.go
- json_profile.go
- json_role.go
- json_user.go
- mDeleteCredentials.go
- mDeleteRoles.go
- mDeleteUsers.go
- mGetProfiles.go
- mGetRoles.go
- profile.go
- profileSearchResult.go
- replaceUser.go
- role.go
- roleSearchResult.go
- searchProfiles.go
- searchRoles.go
- searchUsers.go
- security.go
- updateCredentials.go
- updateProfile.go
- updateProfileMapping.go
- updateRole.go
- updateRoleMapping.go
- updateUser.go
- updateUserMapping.go
- user.go
- userSearchResult.go
- validateCredentials.go