model

package
v0.0.0-...-2e0ac8a Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	AuthSetKeyIdData       = "id_data"
	AuthSetKeyPubKey       = "pubkey"
	AuthSetKeyDeviceId     = "device_id"
	AuthSetKeyStatus       = "status"
	AuthSetKeyIdDataSha256 = "id_data_sha256"
)
View Source
const (
	DevStatusAccepted = "accepted"
	DevStatusRejected = "rejected"
	DevStatusPending  = "pending"
	DevStatusPreauth  = "preauthorized"

	DevKeyIdData = "id_data"
	DevKeyStatus = "status"
)
View Source
const (
	LimitMaxDeviceCount = "max_devices"
)

Variables

View Source
var (
	ValidLimits = []string{LimitMaxDeviceCount}
)

Functions

func IsValidLimit

func IsValidLimit(name string) bool

Types

type AuthReq

type AuthReq struct {
	IdData      string `json:"id_data" bson:"id_data"`
	TenantToken string `json:"tenant_token" bson:"tenant_token"`
	PubKey      string `json:"pubkey"`

	//helpers, not serialized
	PubKeyStruct *rsa.PublicKey `json:"-" bson:"-"`
}

note: fields with underscores need the 'bson' decorator otherwise the underscore will be removed upon write to mongo

func (*AuthReq) Validate

func (r *AuthReq) Validate() error

type AuthSet

type AuthSet struct {
	Id           string                 `json:"id" bson:"_id,omitempty"`
	IdData       string                 `json:"id_data" bson:"id_data,omitempty"`
	IdDataStruct map[string]interface{} `bson:"id_data_struct,omitempty"`
	IdDataSha256 []byte                 `bson:"id_data_sha256,omitempty"`
	PubKey       string                 `json:"pubkey" bson:"pubkey,omitempty"`
	DeviceId     string                 `json:"-" bson:"device_id,omitempty"`
	Timestamp    *time.Time             `json:"ts" bson:"ts,omitempty"`
	Status       string                 `json:"status" bson:"status,omitempty"`
}

type AuthSetUpdate

type AuthSetUpdate struct {
	IdData       string                 `bson:"id_data,omitempty"`
	IdDataStruct map[string]interface{} `bson:"id_data_struct,omitempty"`
	IdDataSha256 []byte                 `bson:"id_data_sha256,omitempty"`
	PubKey       string                 `bson:"pubkey,omitempty"`
	DeviceId     string                 `bson:"device_id,omitempty"`
	Timestamp    *time.Time             `bson:"ts,omitempty"`
	Status       string                 `bson:"status,omitempty"`
}

type Count

type Count struct {
	Count int `json:"count"`
}

type DevAdmAuthSet

type DevAdmAuthSet struct {
	Id             string                 `json:"id" bson:"_id,omitempty"`
	DeviceIdentity string                 `json:"device_identity" bson:"id_data"`
	Key            string                 `json:"key" bson:"pubkey"`
	DeviceId       string                 `json:"device_id" bson:"device_id,omitempty"`
	RequestTime    *time.Time             `json:"request_time" bson:"request_time"`
	Status         string                 `json:"status" bson:"status"`
	Attributes     map[string]interface{} `json:"attributes" bson:"attributes"`
}

func NewDevAdmAuthSet

func NewDevAdmAuthSet(a AuthSet) (*DevAdmAuthSet, error)

type DevAdmAuthSetReq

type DevAdmAuthSetReq struct {
	DeviceId string `json:"device_identity" valid:"required"`
	Key      string `json:"key" valid:"required"`
	//decoded, human-readable identity attribute set
	Attributes DeviceAuthAttributes `json:"-"`
}

func ParseDevAdmAuthSetReq

func ParseDevAdmAuthSetReq(source io.Reader) (*DevAdmAuthSetReq, error)

func (*DevAdmAuthSetReq) Validate

func (r *DevAdmAuthSetReq) Validate() error

type Device

type Device struct {
	Id              string                 `json:"id" bson:"_id,omitempty"`
	PubKey          string                 `json:"-" bson:",omitempty"`
	IdData          string                 `json:"id_data" bson:"id_data,omitempty"`
	IdDataStruct    map[string]interface{} `bson:"id_data_struct,omitempty"`
	IdDataSha256    []byte                 `bson:"id_data_sha256,omitempty"`
	Status          string                 `json:"-" bson:",omitempty"`
	Decommissioning bool                   `json:"decommissioning" bson:",omitempty"`
	CreatedTs       time.Time              `json:"created_ts" bson:"created_ts,omitempty"`
	UpdatedTs       time.Time              `json:"updated_ts" bson:"updated_ts,omitempty"`
	AuthSets        []AuthSet              `json:"auth_sets" bson:"-"`
}

note: fields with underscores need the 'bson' decorator otherwise the underscore will be removed upon write to mongo

func NewDevice

func NewDevice(id, id_data, pubkey string) *Device

type DeviceAuthAttributes

type DeviceAuthAttributes map[string]string

type DeviceUpdate

type DeviceUpdate struct {
	PubKey          string                 `json:"-" bson:",omitempty"`
	IdData          string                 `json:"id_data" bson:"id_data,omitempty"`
	IdDataStruct    map[string]interface{} `bson:"id_data_struct,omitempty"`
	IdDataSha256    []byte                 `bson:"id_data_sha256,omitempty"`
	Status          string                 `json:"-" bson:",omitempty"`
	Decommissioning *bool                  `json:"-" bson:",omitempty"`
	UpdatedTs       *time.Time             `json:"updated_ts" bson:"updated_ts,omitempty"`
}

type Limit

type Limit struct {
	Name  string `bson:"_id"`
	Value uint64 `bson:"value" json:"value"`
}

func (Limit) IsLess

func (l Limit) IsLess(what uint64) bool

type NewTenant

type NewTenant struct {
	TenantId string `json:"tenant_id"`
}

func ParseNewTenant

func ParseNewTenant(source io.Reader) (*NewTenant, error)

type PreAuthReq

type PreAuthReq struct {
	DeviceId  string `json:"device_id" valid:"required" bson:"device_id"`
	AuthSetId string `json:"auth_set_id" valid:"required" bson:"auth_set_id"`
	IdData    string `json:"id_data" valid:"required" bson:"id_data"`
	PubKey    string `json:"pubkey" valid:"required" bson:"pubkey"`
}

func ParsePreAuthReq

func ParsePreAuthReq(source io.Reader) (*PreAuthReq, error)

func (*PreAuthReq) Validate

func (r *PreAuthReq) Validate() error

type Status

type Status struct {
	Status string `json:"status"`
}

type Token

type Token struct {
	Id        string `json:"id" bson:"_id"`
	DevId     string `json:"dev_id" bson:"dev_id,omitempty"`
	AuthSetId string `json:"auth_id" bson:"auth_id,omitempty"`
	Token     string `json:"token" bson:"token,omitempty"`
}

func NewToken

func NewToken(id string, dev_id string, token string) *Token

func (*Token) WithAuthSet

func (t *Token) WithAuthSet(set *AuthSet) *Token

type TokenFilter

type TokenFilter struct {
	Id        string `json:"id" bson:"_id,omitempty"`
	DevId     string `json:"dev_id" bson:"dev_id,omitempty"`
	AuthSetId string `json:"auth_id" bson:"auth_id,omitempty"`
	Token     string `json:"token" bson:"token,omitempty"`
}

Jump to

Keyboard shortcuts

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