Version: v0.0.0-...-a11ed81 Latest Latest

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

Go to latest
Published: May 16, 2022 License: AGPL-3.0 Imports: 28 Imported by: 0



Package web provides types and functionality for the REST API and web app static files



View Source
const JSONHeader = "application/json; charset=UTF-8"

JSONHeader is the content-type header for JSON responses


View Source
var VerifyTokenAndUser = func(authorizationToken string, wb Service) (datastore.User, error) {
	return datastore.User{}, errors.New("service account authorization not configured")

VerifyTokenAndUser is a variable function to verify the token and extract the user based on the current provider


This section is empty.


type Account

type Account struct {
	Email       string
	Username    string
	DisplayName string `json:"displayname"`

Account is the account structure for a USSO user based on the token

type OrganizationResponse

type OrganizationResponse struct {
	Organization domain.Organization `json:"organization"`

OrganizationResponse defines the response to list users

type OrganizationsResponse

type OrganizationsResponse struct {
	Organizations []domain.Organization `json:"organizations"`

OrganizationsResponse defines the response to list users

type Page

type Page struct {
	Title string

Page is the page details for the web application

type Service

type Service struct {
	Manage manage.Manage

Service is the implementation of the web API

func NewService

func NewService(srv manage.Manage) *Service

NewService returns a new web controller

func (Service) ActionListHandler

func (wb Service) ActionListHandler(c *gin.Context)

ActionListHandler is the API method to get actions for a device

func (Service) DeviceDeleteHandler

func (wb Service) DeviceDeleteHandler(c *gin.Context)

DeviceDeleteHandler is the API method to delete a registered device

func (Service) DeviceGetHandler

func (wb Service) DeviceGetHandler(c *gin.Context)

DeviceGetHandler is the API method to get a registered device

func (Service) DeviceLogsHandler

func (wb Service) DeviceLogsHandler(c *gin.Context)

nolint DeviceLogsHandler is the API method to get logs for a device

func (Service) DeviceUsersActionHandler

func (wb Service) DeviceUsersActionHandler(c *gin.Context)

nolint DeviceUsersActionHandler is the API method to create a user for a device

func (Service) DevicesListHandler

func (wb Service) DevicesListHandler(c *gin.Context)

DevicesListHandler is the API method to list the registered devices

func (Service) GroupCreateHandler

func (wb Service) GroupCreateHandler(c *gin.Context)

GroupCreateHandler is the API method to create a group

func (Service) GroupDeviceLinkHandler

func (wb Service) GroupDeviceLinkHandler(c *gin.Context)

GroupDeviceLinkHandler is the API method to link a device to a group

func (Service) GroupDeviceUnlinkHandler

func (wb Service) GroupDeviceUnlinkHandler(c *gin.Context)

nolint GroupDeviceUnlinkHandler is the API method to unlink a device from a group

func (Service) GroupDevicesHandler

func (wb Service) GroupDevicesHandler(c *gin.Context)

GroupDevicesHandler is the API method to list the devices for a group

func (Service) GroupExcludedDevicesHandler

func (wb Service) GroupExcludedDevicesHandler(c *gin.Context)

GroupExcludedDevicesHandler is the API method to list the devices not in a group

func (Service) GroupListHandler

func (wb Service) GroupListHandler(c *gin.Context)

GroupListHandler is the API method to list the groups

func (Service) IndexHandler

func (wb Service) IndexHandler(c *gin.Context)

IndexHandler is the front page of the web application

func (Service) JWTCheck

func (wb Service) JWTCheck(c *gin.Context) (*jwt.Token, error)

JWTCheck extracts the JWT from the request, validates it and returns the token

func (Service) LoginHandler

func (wb Service) LoginHandler(c *gin.Context)

LoginHandler processes the login for Ubuntu SSO

func (Service) LoginHandlerAPIClient

func (wb Service) LoginHandlerAPIClient(c *gin.Context)

LoginHandlerAPIClient processes the login for API client

func (Service) LogoutHandler

func (wb Service) LogoutHandler(c *gin.Context)

LogoutHandler logs the user out by removing the cookie and the JWT authorization header

func (Service) OrganizationCreateHandler

func (wb Service) OrganizationCreateHandler(c *gin.Context)

OrganizationCreateHandler creates a new organization

func (Service) OrganizationGetHandler

func (wb Service) OrganizationGetHandler(c *gin.Context)

OrganizationGetHandler fetches an organization

func (Service) OrganizationListHandler

func (wb Service) OrganizationListHandler(c *gin.Context)

OrganizationListHandler returns the list of accounts

func (Service) OrganizationUpdateForUserHandler

func (wb Service) OrganizationUpdateForUserHandler(c *gin.Context)

OrganizationUpdateForUserHandler fetches the organizations for a user

func (Service) OrganizationUpdateHandler

func (wb Service) OrganizationUpdateHandler(c *gin.Context)

OrganizationUpdateHandler updates an organization

func (Service) OrganizationsForUserHandler

func (wb Service) OrganizationsForUserHandler(c *gin.Context)

OrganizationsForUserHandler fetches the organizations for a user

func (Service) RegDeviceGet

func (wb Service) RegDeviceGet(c *gin.Context)

RegDeviceGet is the API method to get a registered device

func (Service) RegDeviceGetDownload

func (wb Service) RegDeviceGetDownload(c *gin.Context)

RegDeviceGetDownload provides the download of the device data

func (Service) RegDeviceList

func (wb Service) RegDeviceList(c *gin.Context)

RegDeviceList is the API method to list the registered devices

func (Service) RegDeviceUpdate

func (wb Service) RegDeviceUpdate(c *gin.Context)

RegDeviceUpdate is the API method to update a registered device status

func (Service) RegisterDevice

func (wb Service) RegisterDevice(c *gin.Context)

RegisterDevice registers a new device with the Identity service

func (Service) Run

func (wb Service) Run()

Run starts the web service

func (Service) SnapConfigUpdateHandler

func (wb Service) SnapConfigUpdateHandler(c *gin.Context)

SnapConfigUpdateHandler gets the config for a snap on a device

func (Service) SnapDeleteHandler

func (wb Service) SnapDeleteHandler(c *gin.Context)

nolint SnapDeleteHandler uninstalls a snap from the device

func (Service) SnapInstallHandler

func (wb Service) SnapInstallHandler(c *gin.Context)

SnapInstallHandler installs a snap on the device

func (Service) SnapListHandler

func (wb Service) SnapListHandler(c *gin.Context)

SnapListHandler fetches the list of installed snaps from the device

func (Service) SnapListOnDevice

func (wb Service) SnapListOnDevice(c *gin.Context)

SnapListOnDevice lists snaps on the device

func (Service) SnapServiceAction

func (wb Service) SnapServiceAction(c *gin.Context)

SnapServiceAction start/stop/restart a snap on device

func (Service) SnapUpdateHandler

func (wb Service) SnapUpdateHandler(c *gin.Context)

SnapUpdateHandler updates a snap on the device Permitted actions are: enable, disable, refresh, or switch

func (Service) StoreSearchHandler

func (wb Service) StoreSearchHandler(c *gin.Context)

StoreSearchHandler fetches the available snaps from the store

func (Service) TokenHandler

func (wb Service) TokenHandler(c *gin.Context)

TokenHandler returns CSRF protection new token in a X-CSRF-Token response header This method is also used by the /authtoken endpoint to return the JWT. The method indicates to the UI whether OpenID user auth is enabled

func (Service) UserCreateHandler

func (wb Service) UserCreateHandler(c *gin.Context)

nolint UserCreateHandler handles user creation

func (Service) UserDeleteHandler

func (wb Service) UserDeleteHandler(c *gin.Context)

UserDeleteHandler handles user deletion

func (Service) UserGetHandler

func (wb Service) UserGetHandler(c *gin.Context)

UserGetHandler is the API method to fetch a user

func (Service) UserListHandler

func (wb Service) UserListHandler(c *gin.Context)

UserListHandler is the API method to list the users

func (Service) UserUpdateHandler

func (wb Service) UserUpdateHandler(c *gin.Context)

nolint UserUpdateHandler handles user update

func (Service) VersionHandler

func (wb Service) VersionHandler(c *gin.Context)

VersionHandler is the API method to return the version of the web

type UbuntuSingleSignOnServer

type UbuntuSingleSignOnServer interface {
	IsTokenValid(ssodata *usso.SSOData) (bool, error)
	GetAccounts(ssodata *usso.SSOData) (string, error)

UbuntuSingleSignOnServer is the interface for minimal USSO functionality

type UserOrganization

type UserOrganization struct {
	Selected bool `json:"selected"`

UserOrganization defines an organization and whether it is selected for a user

type UserOrganizationsResponse

type UserOrganizationsResponse struct {
	Organizations []UserOrganization `json:"organizations"`

UserOrganizationsResponse defines the response to list users

type UserResponse

type UserResponse struct {
	User domain.User `json:"user"`

UserResponse defines the response to get a user

type UsersResponse

type UsersResponse struct {
	Users []domain.User `json:"users"`

UsersResponse defines the response to list users

type VersionResponse

type VersionResponse struct {
	Versions map[string]string `json:"versions"`

VersionResponse is the JSON response from the API Version method


Path Synopsis
Package usso provides types and functionality for the Ubuntu Single Sign-on Server
Package usso provides types and functionality for the Ubuntu Single Sign-on Server

Jump to

Keyboard shortcuts

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