api

package
v0.0.0-...-9fcbe96 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelloWorld

func HelloWorld(rw http.ResponseWriter, req *http.Request)

HelloWorld emits a hello world

func ShowUI

func ShowUI(rw http.ResponseWriter, req *http.Request)

ShowUI redirects to the /ui/ url path

Types

type AuthResponse

type AuthResponse struct {
	Authorized bool `json:"authorized"`
}

AuthResponse is a response structure returned after validating a request

type ErrorResponse

type ErrorResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

ErrorResponse represents an API response

type NewUserRequest

type NewUserRequest struct {
	Password string    `json:"password"`
	User     data.User `json:"user"`
}

NewUserRequest is a request to create a new user. This is really the only type of requests

that requires a specific request type -- because a new user request includes a password

type OAuthRequest

type OAuthRequest struct {
	GrantType    string `json:"grant_type"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	Scope        string `json:"scope"`
	UserName     string `json:"username"`
	Password     string `json:"password"`
	CSRFToken    string `json:"state"`
	RedirectURI  string `json:"redirect_uri"`
	ResponseType string `json:"response_type"`
	Code         string `json:"code"`
}

OAuthRequest is an OAuth2 based request. For more information on the various grant types that can use this request object: https://alexbilbie.com/guide-to-oauth-2-grants/

type OAuthResponse

type OAuthResponse struct {
	TokenType    string `json:"token_type"`
	ExpiresIn    string `json:"expires_in"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

OAuthResponse is an OAuth2 based response

type OverviewResponse

type OverviewResponse struct {
	SystemOverview  data.SystemOverview `json:"overview"`
	Uptime          string              `json:"uptime"`
	UserName        string              `json:"user_name"`
	UserDescription string              `json:"user_description"`
}

OverviewResponse represents a response to the GetOverview call

type SearchRequest

type SearchRequest struct {
	SearchExpression string `json:"expression"`
}

SearchRequest represents a request to search for information

type Service

type Service struct {
	DB        *data.Manager
	StartTime time.Time
}

Service encapsulates API service operations

func (Service) AddActionsToResource

func (service Service) AddActionsToResource(rw http.ResponseWriter, req *http.Request)

AddActionsToResource adds action(s) to a resource. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddGroup

func (service Service) AddGroup(rw http.ResponseWriter, req *http.Request)

AddGroup adds a group. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddPolicy

func (service Service) AddPolicy(rw http.ResponseWriter, req *http.Request)

AddPolicy adds a policy. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddResource

func (service Service) AddResource(rw http.ResponseWriter, req *http.Request)

AddResource adds a resource. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddRole

func (service Service) AddRole(rw http.ResponseWriter, req *http.Request)

AddRole adds a role. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddUser

func (service Service) AddUser(rw http.ResponseWriter, req *http.Request)

AddUser adds a user. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AddUsersToGroup

func (service Service) AddUsersToGroup(rw http.ResponseWriter, req *http.Request)

AddUsersToGroup adds user(s) to a group. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AttachPoliciesToRole

func (service Service) AttachPoliciesToRole(rw http.ResponseWriter, req *http.Request)

AttachPoliciesToRole attaches policy(s) to a role. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AttachPolicyToGroups

func (service Service) AttachPolicyToGroups(rw http.ResponseWriter, req *http.Request)

AttachPolicyToGroups attaches group(s) to a policy. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AttachPolicyToUsers

func (service Service) AttachPolicyToUsers(rw http.ResponseWriter, req *http.Request)

AttachPolicyToUsers attaches user(s) to a policy. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AttachRoleToGroups

func (service Service) AttachRoleToGroups(rw http.ResponseWriter, req *http.Request)

AttachRoleToGroups attaches group(s) to a role. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) AttachRoleToUsers

func (service Service) AttachRoleToUsers(rw http.ResponseWriter, req *http.Request)

AttachRoleToUsers attaches user(s) to a role. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) BeginTOTPEnrollment

func (service Service) BeginTOTPEnrollment(rw http.ResponseWriter, req *http.Request)

BeginTOTPEnrollment begins TOTP (two factor auth) enrollment. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) FinishTOTPEnrollment

func (service Service) FinishTOTPEnrollment(rw http.ResponseWriter, req *http.Request)

FinishTOTPEnrollment finishes TOTP (two factor auth) enrollment by verifying the first code. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetAllGroups

func (service Service) GetAllGroups(rw http.ResponseWriter, req *http.Request)

GetAllGroups gets all group information. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetAllPolicies

func (service Service) GetAllPolicies(rw http.ResponseWriter, req *http.Request)

GetAllPolicies gets all policies in the system. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetAllResources

func (service Service) GetAllResources(rw http.ResponseWriter, req *http.Request)

GetAllResources gets all resources in the system. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetAllRoles

func (service Service) GetAllRoles(rw http.ResponseWriter, req *http.Request)

GetAllRoles gets all role information. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetAllUsers

func (service Service) GetAllUsers(rw http.ResponseWriter, req *http.Request)

GetAllUsers gets all users in the system. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetGroup

func (service Service) GetGroup(rw http.ResponseWriter, req *http.Request)

GetGroup gets group information. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetOverview

func (service Service) GetOverview(rw http.ResponseWriter, req *http.Request)

GetOverview gets the system overview information. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetPoliciesForUser

func (service Service) GetPoliciesForUser(rw http.ResponseWriter, req *http.Request)

GetPoliciesForUser gets all policies for a given user. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetPolicy

func (service Service) GetPolicy(rw http.ResponseWriter, req *http.Request)

GetPolicy gets a policy. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetResource

func (service Service) GetResource(rw http.ResponseWriter, req *http.Request)

GetResource gets a resource. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetRole

func (service Service) GetRole(rw http.ResponseWriter, req *http.Request)

GetRole gets role information. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetTOTPEnrollmentImage

func (service Service) GetTOTPEnrollmentImage(rw http.ResponseWriter, req *http.Request)

GetTOTPEnrollmentImage gets the TOTP (two factor auth) enrollment image. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) GetTokenForCredentials

func (service Service) GetTokenForCredentials(rw http.ResponseWriter, req *http.Request)

GetTokenForCredentials gets a bearer token for a given set of credentials

func (Service) GetUser

func (service Service) GetUser(rw http.ResponseWriter, req *http.Request)

GetUser gets a user. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

func (Service) IsRequestAuthorized

func (service Service) IsRequestAuthorized(rw http.ResponseWriter, req *http.Request)

IsRequestAuthorized returns whether a request is authorized for a given bearer token and request object

func (Service) Search

func (service Service) Search(rw http.ResponseWriter, req *http.Request)

Search searches the system for a given user/group/role/policy/resource name using the supplied regex expression. If the bearer token is not authorized for the operation, StatusUnauthorized is returned

type SystemResponse

type SystemResponse struct {
	Status  int         `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

SystemResponse is a response for a system request

type TokenResponse

type TokenResponse struct {
	TokenType   string `json:"token_type"`
	ExpiresIn   string `json:"expires_in"`
	AccessToken string `json:"access_token"`
}

TokenResponse is a response for a bearer token

type TotpEnrollmentFinishRequest

type TotpEnrollmentFinishRequest struct {
	PassCode string `json:"passcode"`
}

TotpEnrollmentFinishRequest represents a request to complete the TOTP enrollment request. A passcode (from the OTP device / authenticator app) is required to validate and complete the process

Jump to

Keyboard shortcuts

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