devauth

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: 24 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.

Index

Constants

View Source
const (
	MsgErrDevAuthUnauthorized = "dev auth: unauthorized"
	MsgErrDevAuthBadRequest   = "dev auth: bad request"
)

Variables

View Source
var (
	ErrDevAuthUnauthorized   = errors.New(MsgErrDevAuthUnauthorized)
	ErrDevIdAuthIdMismatch   = errors.New("dev auth: dev ID and auth ID mismatch")
	ErrMaxDeviceCountReached = errors.New("maximum number of accepted devices reached")
	ErrDeviceExists          = errors.New("device already exists")
	ErrDeviceNotFound        = errors.New("device not found")
	ErrDevAuthBadRequest     = errors.New(MsgErrDevAuthBadRequest)
)

Functions

func IsErrDevAuthBadRequest

func IsErrDevAuthBadRequest(e error) bool

func IsErrDevAuthUnauthorized

func IsErrDevAuthUnauthorized(e error) bool

func MakeErrDevAuthBadRequest

func MakeErrDevAuthBadRequest(e error) error

func MakeErrDevAuthUnauthorized

func MakeErrDevAuthUnauthorized(e error) error

Types

type ApiClientGetter

type ApiClientGetter func() apiclient.HttpRunner

helper for obtaining API clients

type App

type App interface {
	SubmitAuthRequest(ctx context.Context, r *model.AuthReq) (string, error)

	GetDevices(ctx context.Context, skip, limit uint, filter store.DeviceFilter) ([]model.Device, error)
	GetDevice(ctx context.Context, dev_id string) (*model.Device, error)
	DecommissionDevice(ctx context.Context, dev_id string) error
	DeleteAuthSet(ctx context.Context, dev_id string, auth_id string) error
	AcceptDeviceAuth(ctx context.Context, dev_id string, auth_id string) error
	RejectDeviceAuth(ctx context.Context, dev_id string, auth_id string) error
	ResetDeviceAuth(ctx context.Context, dev_id string, auth_id string) error
	PreauthorizeDevice(ctx context.Context, req *model.PreAuthReq) error
	GetDeviceToken(ctx context.Context, dev_id string) (*model.Token, error)

	RevokeToken(ctx context.Context, token_id string) error
	VerifyToken(ctx context.Context, token string) error
	DeleteTokens(ctx context.Context, tenant_id, device_id string) error

	SetTenantLimit(ctx context.Context, tenant_id string, limit model.Limit) error

	GetLimit(ctx context.Context, name string) (*model.Limit, error)
	GetTenantLimit(ctx context.Context, name, tenant_id string) (*model.Limit, error)

	GetDevCountByStatus(ctx context.Context, status string) (int, error)

	ProvisionTenant(ctx context.Context, tenant_id string) error

	GetTenantDeviceStatus(ctx context.Context, tenantId, deviceId string) (*model.Status, error)
}

this device auth service interface

type Config

type Config struct {
	// token issuer
	Issuer string
	// token expiration time
	ExpirationTime int64
	// max devices limit default
	MaxDevicesLimitDefault uint64
}

type DevAuth

type DevAuth struct {
	// contains filtered or unexported fields
}

func NewDevAuth

func NewDevAuth(d store.DataStore, co orchestrator.ClientRunner,
	jwt jwt.Handler, config Config) *DevAuth

func (*DevAuth) AcceptDeviceAuth

func (d *DevAuth) AcceptDeviceAuth(ctx context.Context, device_id string, auth_id string) error

func (*DevAuth) DecommissionDevice

func (d *DevAuth) DecommissionDevice(ctx context.Context, devId string) error

DecommissionDevice deletes device and all its tokens

func (*DevAuth) DeleteAuthSet

func (d *DevAuth) DeleteAuthSet(ctx context.Context, devId string, authId string) error

Deletes device authentication set, and optionally the device.

func (*DevAuth) DeleteTokens

func (d *DevAuth) DeleteTokens(ctx context.Context, tenant_id, device_id string) error

func (*DevAuth) GetDevCountByStatus

func (d *DevAuth) GetDevCountByStatus(ctx context.Context, status string) (int, error)

func (*DevAuth) GetDevice

func (d *DevAuth) GetDevice(ctx context.Context, devId string) (*model.Device, error)

func (*DevAuth) GetDeviceToken

func (*DevAuth) GetDeviceToken(ctx context.Context, dev_id string) (*model.Token, error)

func (*DevAuth) GetDevices

func (d *DevAuth) GetDevices(ctx context.Context, skip, limit uint, filter store.DeviceFilter) ([]model.Device, error)

func (*DevAuth) GetLimit

func (d *DevAuth) GetLimit(ctx context.Context, name string) (*model.Limit, error)

func (*DevAuth) GetTenantDeviceStatus

func (d *DevAuth) GetTenantDeviceStatus(ctx context.Context, tenantId, deviceId string) (*model.Status, error)

func (*DevAuth) GetTenantLimit

func (d *DevAuth) GetTenantLimit(ctx context.Context, name, tenant_id string) (*model.Limit, error)

func (*DevAuth) PreauthorizeDevice

func (d *DevAuth) PreauthorizeDevice(ctx context.Context, req *model.PreAuthReq) error

func (*DevAuth) ProvisionTenant

func (d *DevAuth) ProvisionTenant(ctx context.Context, tenant_id string) error

func (*DevAuth) RejectDeviceAuth

func (d *DevAuth) RejectDeviceAuth(ctx context.Context, device_id string, auth_id string) error

func (*DevAuth) ResetDeviceAuth

func (d *DevAuth) ResetDeviceAuth(ctx context.Context, device_id string, auth_id string) error

func (*DevAuth) RevokeToken

func (d *DevAuth) RevokeToken(ctx context.Context, token_id string) error

func (*DevAuth) SetTenantLimit

func (d *DevAuth) SetTenantLimit(ctx context.Context, tenant_id string, limit model.Limit) error

func (*DevAuth) SubmitAuthRequest

func (d *DevAuth) SubmitAuthRequest(ctx context.Context, r *model.AuthReq) (string, error)

func (*DevAuth) VerifyToken

func (d *DevAuth) VerifyToken(ctx context.Context, raw string) error

func (*DevAuth) WithTenantVerification

func (d *DevAuth) WithTenantVerification(c tenant.ClientRunner) *DevAuth

WithTenantVerification will force verification of tenant token with tenant administrator when processing device authentication requests. Returns an updated devauth.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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