model

package
v0.0.0-...-252f4b7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 7

Documentation

Overview

Copyright 2023 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 2023 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 2023 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 2023 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 2023 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 2023 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 2023 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 2023 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 2023 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"
	DevStatusNoAuth   = "noauth"

	DevKeyId           = "_id"
	DevKeyIdData       = "id_data"
	DevKeyIdDataSha256 = "id_data_sha256"
	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 crypto.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:"-" bson:"id_data,omitempty"`
	IdDataStruct map[string]interface{} `json:"identity_data" bson:"id_data_struct,omitempty"`
	IdDataSha256 []byte                 `json:"-" 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"`
	TenantID     string                 `json:"-" bson:"tenant_id"`
}

type AuthSetUpdate

type AuthSetUpdate struct {
	Id           string                 `bson:"id,omitempty"`
	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"`
	IdData          string                 `json:"-" bson:"id_data,omitempty"`
	IdDataStruct    map[string]interface{} `json:"identity_data" bson:"id_data_struct,omitempty"`
	IdDataSha256    []byte                 `json:"-" bson:"id_data_sha256,omitempty"`
	Status          string                 `json:"status" 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:"-"`
	CheckInTime     *time.Time             `json:"check_in_time,omitempty" bson:"check_in_time,omitempty"` // nolint:lll
	//ApiLimits override tenant-wide quota/burst config
	ApiLimits ratelimits.ApiLimits `json:"-" bson:"api_limits"`

	//object revision which we use when synchronizing status with inventory service
	Revision uint   `json:"-" bson:"revision"`
	TenantID string `json:"-" bson:"tenant_id"`
}

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 DeviceAttribute

type DeviceAttribute struct {
	Name        string      `json:"name" bson:",omitempty"`
	Description *string     `json:"description,omitempty" bson:",omitempty"`
	Value       interface{} `json:"value" bson:",omitempty"`
	Scope       string      `json:"scope" bson:",omitempty"`
}

type DeviceAuthAttributes

type DeviceAuthAttributes map[string]string

type DeviceFilter

type DeviceFilter struct {
	Status []string `json:"status,omitempty"`
	IDs    []string `json:"id,omitempty"`
}

func (*DeviceFilter) ParseForm

func (fltr *DeviceFilter) ParseForm(form url.Values) error

func (*DeviceFilter) UnmarshalJSON

func (fltr *DeviceFilter) UnmarshalJSON(b []byte) error

func (DeviceFilter) Validate

func (fltr DeviceFilter) Validate() error

type DeviceInventoryUpdate

type DeviceInventoryUpdate struct {
	Id       string `json:"id"`
	Revision uint   `json:"revision"`
}

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"`
	CheckInTime     *time.Time             `json:"-" bson:"check_in_time,omitempty"`
}

type Limit

type Limit struct {
	Id       string `json:"-" bson:"_id,omitempty"`
	Name     string `bson:"name"`
	Value    uint64 `json:"value" bson:"value"`
	TenantID string `json:"-" bson:"tenant_id"`
}

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 {
	Force     bool   `json:"force" bson:"force"`
	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"`
}

Jump to

Keyboard shortcuts

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