Documentation
¶
Index ¶
- Constants
- type IdProvHttpServer
- type IdProvService
- type ManageIdProvService
- func (svc *ManageIdProvService) ApproveRequest(ctx hubclient.ServiceContext, args *idprovapi.ApproveRequestArgs) error
- func (svc *ManageIdProvService) GetRequests(ctx hubclient.ServiceContext, args *idprovapi.GetRequestsArgs) (*idprovapi.GetRequestsResp, error)
- func (svc *ManageIdProvService) PreApproveClients(ctx hubclient.ServiceContext, args *idprovapi.PreApproveClientsArgs) error
- func (svc *ManageIdProvService) RejectRequest(ctx hubclient.ServiceContext, args *idprovapi.RejectRequestArgs) error
- func (svc *ManageIdProvService) Stop()
- func (svc *ManageIdProvService) SubmitRequest(ctx hubclient.ServiceContext, args *idprovapi.ProvisionRequestArgs) (resp *idprovapi.ProvisionRequestResp, err error)
Constants ¶
const ApprovedSecret = "approved"
const DefaultIoTCertValidityDays = 14
const DefaultRetrySec = 12 * 3600
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IdProvHttpServer ¶
type IdProvHttpServer struct {
// contains filtered or unexported fields
}
IdProvHttpServer serves the provisioning requests
func StartIdProvHttpServer ¶
func StartIdProvHttpServer( port uint, serverCert *tls.Certificate, caCert *x509.Certificate, mng *ManageIdProvService) (*IdProvHttpServer, error)
StartIdProvHttpServer starts the http server to handle provisioning requests
type IdProvService ¶
type IdProvService struct {
// contains filtered or unexported fields
}
IdProvService handles provisioning requests from devices and services. This starts listening on the provisioning port using a server certificate signed by the Hub CA. If enabled, publish the DNS-SD discovery record with the server address and port.
Connecting clients can request an auth token, providing their ID and public key. The server responds with a token or wait-for-approval. In case of wait for approval the client must repeat the request, in 1 minute intervals until approval is received or rejected.
The server connects to the Hub to obtain auth tokens from the auth service. Tokens issued will be very short lived and require the device to refresh with the auth service directly, after connecting to the hub.
The provisioning server can be started and stopped on the fly so it only runs when needed.
func NewIdProvService ¶
func NewIdProvService(hc *hubclient.HubClient, port uint, serverCert *tls.Certificate, caCert *x509.Certificate) *IdProvService
NewIdProvService creates a new provisioning service instance
func (*IdProvService) Start ¶
func (svc *IdProvService) Start() (err error)
Start the provisioning service 1. start the management service 2. set allowed roles for RPC calls to this service 3. Start the http request server 4. start the security check for rogue DNS-SD records 5. start DNS-SD discovery server
type ManageIdProvService ¶
type ManageIdProvService struct {
// contains filtered or unexported fields
}
func StartManageIdProvService ¶
func StartManageIdProvService(hc *hubclient.HubClient) (*ManageIdProvService, error)
func (*ManageIdProvService) ApproveRequest ¶
func (svc *ManageIdProvService) ApproveRequest(ctx hubclient.ServiceContext, args *idprovapi.ApproveRequestArgs) error
ApproveRequest approves an existing provisioning request. The client will be added on the next request. The next repeat request will return a short-lived token.
func (*ManageIdProvService) GetRequests ¶
func (svc *ManageIdProvService) GetRequests(ctx hubclient.ServiceContext, args *idprovapi.GetRequestsArgs) (*idprovapi.GetRequestsResp, error)
GetRequests returns list of requests since last start If args.OnlyPending is set then only return pending requests Note that rejected requests are never returned
func (*ManageIdProvService) PreApproveClients ¶
func (svc *ManageIdProvService) PreApproveClients(ctx hubclient.ServiceContext, args *idprovapi.PreApproveClientsArgs) error
PreApproveClients uploads list of pre-approved devices and services
func (*ManageIdProvService) RejectRequest ¶
func (svc *ManageIdProvService) RejectRequest(ctx hubclient.ServiceContext, args *idprovapi.RejectRequestArgs) error
RejectRequest rejects a provisioning request
func (*ManageIdProvService) Stop ¶
func (svc *ManageIdProvService) Stop()
func (*ManageIdProvService) SubmitRequest ¶
func (svc *ManageIdProvService) SubmitRequest(ctx hubclient.ServiceContext, args *idprovapi.ProvisionRequestArgs) (resp *idprovapi.ProvisionRequestResp, err error)
SubmitRequest creates a provisioning request for a device
If the request is pre-approved a token will be returned if the pubKey and/or MAC matches. If the pre-approval does not include a public key then only match required is the MAC.