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.
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
- Variables
- type DataStoreMongo
- func (db *DataStoreMongo) AddAuthSet(ctx context.Context, set model.AuthSet) error
- func (db *DataStoreMongo) AddDevice(ctx context.Context, d model.Device) error
- func (db *DataStoreMongo) AddToken(ctx context.Context, t *jwt.Token) error
- func (db *DataStoreMongo) DeleteAuthSetForDevice(ctx context.Context, devId string, authId string) error
- func (db *DataStoreMongo) DeleteAuthSetsForDevice(ctx context.Context, devid string) error
- func (db *DataStoreMongo) DeleteBrokenAuthSets(tenantId string) error
- func (db *DataStoreMongo) DeleteDevice(ctx context.Context, id string) error
- func (db *DataStoreMongo) DeleteDevicesBeingDecommissioned(tenantId string) error
- func (db *DataStoreMongo) DeleteLimit(ctx context.Context, lim string) error
- func (db *DataStoreMongo) DeleteToken(ctx context.Context, jti oid.ObjectID) error
- func (db *DataStoreMongo) DeleteTokenByDevId(ctx context.Context, devID oid.ObjectID) error
- func (db *DataStoreMongo) DeleteTokens(ctx context.Context) error
- func (db *DataStoreMongo) ForEachTenant(ctx context.Context, mapFunc store.MapFunc) error
- func (db *DataStoreMongo) GetAuthSetById(ctx context.Context, auth_id string) (*model.AuthSet, error)
- func (db *DataStoreMongo) GetAuthSetByIdDataHashKey(ctx context.Context, idDataHash []byte, key string) (*model.AuthSet, error)
- func (db *DataStoreMongo) GetAuthSetByIdDataHashKeyByStatus(ctx context.Context, idDataHash []byte, key string, status string) (*model.AuthSet, error)
- func (db *DataStoreMongo) GetAuthSetsForDevice(ctx context.Context, devid string) ([]model.AuthSet, error)
- func (db *DataStoreMongo) GetBrokenAuthSets(tenantId string) ([]string, error)
- func (db *DataStoreMongo) GetDevCountByStatus(ctx context.Context, status string) (int, error)
- func (db *DataStoreMongo) GetDeviceById(ctx context.Context, id string) (*model.Device, error)
- func (db *DataStoreMongo) GetDeviceByIdentityDataHash(ctx context.Context, idataHash []byte) (*model.Device, error)
- func (db *DataStoreMongo) GetDeviceStatus(ctx context.Context, devId string) (string, error)
- func (db *DataStoreMongo) GetDevices(ctx context.Context, skip, limit uint, filter model.DeviceFilter) ([]model.Device, error)
- func (db *DataStoreMongo) GetDevicesBeingDecommissioned(tenantId string) ([]model.Device, error)
- func (db *DataStoreMongo) GetLimit(ctx context.Context, name string) (*model.Limit, error)
- func (db *DataStoreMongo) GetToken(ctx context.Context, jti oid.ObjectID) (*jwt.Token, error)
- func (db *DataStoreMongo) ListTenantsIds(ctx context.Context) ([]string, error)
- func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
- func (db *DataStoreMongo) MigrateTenant(ctx context.Context, database, version string) error
- func (db *DataStoreMongo) Ping(ctx context.Context) error
- func (db *DataStoreMongo) PutLimit(ctx context.Context, lim model.Limit) error
- func (db *DataStoreMongo) RejectAuthSetsForDevice(ctx context.Context, deviceID string) error
- func (db *DataStoreMongo) StoreMigrationVersion(ctx context.Context, version *migrate.Version) error
- func (db *DataStoreMongo) UpdateAuthSet(ctx context.Context, filter interface{}, mod model.AuthSetUpdate) error
- func (db *DataStoreMongo) UpdateAuthSetById(ctx context.Context, id string, mod model.AuthSetUpdate) error
- func (db *DataStoreMongo) UpdateDevice(ctx context.Context, deviceID string, updev model.DeviceUpdate) error
- func (db *DataStoreMongo) UpsertAuthSetStatus(ctx context.Context, authSet *model.AuthSet) error
- func (db *DataStoreMongo) WithAutomigrate() store.DataStore
- func (db *DataStoreMongo) WithMultitenant() *DataStoreMongo
- type DataStoreMongoConfig
- type DeviceFilter
Constants ¶
const ( DbVersion = "2.0.0" DbName = "deviceauth" DbDevicesColl = "devices" DbAuthSetColl = "auth_sets" DbTokensColl = "tokens" DbLimitsColl = "limits" DbKeyDeviceRevision = "revision" )
Variables ¶
var DbAuthSetsCollectionIndices = []mongo.IndexModel{ { Keys: bson.D{ {Key: mstore.FieldTenantID, Value: 1}, {Key: dbFieldIDDataSha, Value: 1}, {Key: dbFieldPubKey, Value: 1}, }, Options: mopts.Index(). SetName(strings.Join([]string{ mstore.FieldTenantID, dbFieldIDDataSha, dbFieldPubKey, }, "_")). SetUnique(true), }, { Keys: bson.D{ {Key: mstore.FieldTenantID, Value: 1}, {Key: dbFieldDeviceID, Value: 1}, }, Options: mopts.Index(). SetName(strings.Join([]string{ mstore.FieldTenantID, dbFieldDeviceID, }, "_")), }, }
var DbDevicesCollectionIndices = []mongo.IndexModel{ { Keys: bson.D{ {Key: mstore.FieldTenantID, Value: 1}, {Key: dbFieldIDDataSha, Value: 1}, }, Options: mopts.Index(). SetName(strings.Join([]string{ mstore.FieldTenantID, dbFieldIDDataSha, }, "_")). SetUnique(true). SetBackground(false), }, { Keys: bson.D{ {Key: mstore.FieldTenantID, Value: 1}, {Key: dbFieldStatus, Value: 1}, {Key: dbFieldID, Value: 1}, }, Options: mopts.Index(). SetName(strings.Join([]string{ mstore.FieldTenantID, dbFieldStatus, dbFieldID, }, "_")). SetBackground(false), }, }
var DbLimitsCollectionIndices = []mongo.IndexModel{ { Keys: bson.D{ {Key: mstore.FieldTenantID, Value: 1}, {Key: dbFieldName, Value: 1}, }, Options: mopts.Index(). SetName(strings.Join([]string{ mstore.FieldTenantID, dbFieldName, }, "_", ), ). SetUnique(true), }, }
var DbTokensCollectionIndices = []mongo.IndexModel{ { Keys: bson.D{ {Key: dbFieldTenantClaim, Value: 1}, {Key: dbFieldSubject, Value: 1}, }, Options: mopts.Index(). SetName( strings.Join( []string{ strings.ReplaceAll(dbFieldTenantClaim, ".", "_"), dbFieldSubject, }, "_", ), ), }, { Keys: bson.D{ {Key: dbFieldExpTime, Value: 1}, }, Options: mopts.Index(). SetName( strings.Join( []string{ strings.ReplaceAll(dbFieldExpTime, ".", "_"), }, "_", ), ). SetExpireAfterSeconds(0), }, }
Functions ¶
This section is empty.
Types ¶
type DataStoreMongo ¶
type DataStoreMongo struct {
// contains filtered or unexported fields
}
func NewDataStoreMongo ¶
func NewDataStoreMongo(config DataStoreMongoConfig) (*DataStoreMongo, error)
func NewDataStoreMongoWithClient ¶
func NewDataStoreMongoWithClient(client *mongo.Client) *DataStoreMongo
func (*DataStoreMongo) AddAuthSet ¶
func (*DataStoreMongo) DeleteAuthSetForDevice ¶
func (*DataStoreMongo) DeleteAuthSetsForDevice ¶
func (db *DataStoreMongo) DeleteAuthSetsForDevice(ctx context.Context, devid string) error
func (*DataStoreMongo) DeleteBrokenAuthSets ¶
func (db *DataStoreMongo) DeleteBrokenAuthSets(tenantId string) error
Deletes auth sets owned by devices that are in decommissioning state and auth sets not owned by any device.
func (*DataStoreMongo) DeleteDevice ¶
func (db *DataStoreMongo) DeleteDevice(ctx context.Context, id string) error
func (*DataStoreMongo) DeleteDevicesBeingDecommissioned ¶
func (db *DataStoreMongo) DeleteDevicesBeingDecommissioned(tenantId string) error
Deletes devices with decommissioning flag set
func (*DataStoreMongo) DeleteLimit ¶
func (db *DataStoreMongo) DeleteLimit(ctx context.Context, lim string) error
func (*DataStoreMongo) DeleteToken ¶
func (*DataStoreMongo) DeleteTokenByDevId ¶
func (*DataStoreMongo) DeleteTokens ¶
func (db *DataStoreMongo) DeleteTokens(ctx context.Context) error
func (*DataStoreMongo) ForEachTenant ¶
func (*DataStoreMongo) GetAuthSetById ¶
func (*DataStoreMongo) GetAuthSetByIdDataHashKey ¶
func (*DataStoreMongo) GetAuthSetByIdDataHashKeyByStatus ¶
func (*DataStoreMongo) GetAuthSetsForDevice ¶
func (*DataStoreMongo) GetBrokenAuthSets ¶
func (db *DataStoreMongo) GetBrokenAuthSets(tenantId string) ([]string, error)
Retrieves Ids of the auth sets owned by devices that are in decommissioning state or not owned by any device.
func (*DataStoreMongo) GetDevCountByStatus ¶
func (*DataStoreMongo) GetDeviceById ¶
func (*DataStoreMongo) GetDeviceByIdentityDataHash ¶
func (*DataStoreMongo) GetDeviceStatus ¶
func (*DataStoreMongo) GetDevices ¶
func (db *DataStoreMongo) GetDevices( ctx context.Context, skip, limit uint, filter model.DeviceFilter, ) ([]model.Device, error)
func (*DataStoreMongo) GetDevicesBeingDecommissioned ¶
func (db *DataStoreMongo) GetDevicesBeingDecommissioned(tenantId string) ([]model.Device, error)
Retrieves devices with decommissioning flag set
func (*DataStoreMongo) ListTenantsIds ¶
func (db *DataStoreMongo) ListTenantsIds( ctx context.Context, ) ([]string, error)
func (*DataStoreMongo) Migrate ¶
func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
func (*DataStoreMongo) MigrateTenant ¶
func (db *DataStoreMongo) MigrateTenant(ctx context.Context, database, version string) error
func (*DataStoreMongo) RejectAuthSetsForDevice ¶
func (db *DataStoreMongo) RejectAuthSetsForDevice( ctx context.Context, deviceID string, ) error
func (*DataStoreMongo) StoreMigrationVersion ¶
func (*DataStoreMongo) UpdateAuthSet ¶
func (db *DataStoreMongo) UpdateAuthSet( ctx context.Context, filter interface{}, mod model.AuthSetUpdate, ) error
func (*DataStoreMongo) UpdateAuthSetById ¶
func (db *DataStoreMongo) UpdateAuthSetById( ctx context.Context, id string, mod model.AuthSetUpdate, ) error
func (*DataStoreMongo) UpdateDevice ¶
func (db *DataStoreMongo) UpdateDevice(ctx context.Context, deviceID string, updev model.DeviceUpdate) error
func (*DataStoreMongo) UpsertAuthSetStatus ¶
UpsertAuthSetStatus inserts a new auth set and if it exists, ensures the AuthSet.Status matches the one in authSet.
func (*DataStoreMongo) WithAutomigrate ¶
func (db *DataStoreMongo) WithAutomigrate() store.DataStore
func (*DataStoreMongo) WithMultitenant ¶
func (db *DataStoreMongo) WithMultitenant() *DataStoreMongo
type DataStoreMongoConfig ¶
type DeviceFilter ¶
type DeviceFilter model.DeviceFilter
func (DeviceFilter) MarshalBSON ¶
func (fltr DeviceFilter) MarshalBSON() (b []byte, err error)