auth

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

*

  • Copyright 2025 Comcast Cable Communications Management, LLC *
  • 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. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2023 Comcast Cable Communications Management, LLC *
  • 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. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2025 Comcast Cable Communications Management, LLC *
  • 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. *
  • SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	COMMON_MODULE    string = "common"
	TOOL_MODULE      string = "tools"
	CHANGE_MODULE    string = "changes"
	DCM_MODULE       string = "dcm"
	FIRMWARE_MODULE  string = "firmware"
	RFC_MODULE       string = "rfc"
	TELEMETRY_MODULE string = "telemetry"

	READ_COMMON  string = "read-common"
	WRITE_COMMON string = "write-common"

	VIEW_TOOLS  string = "view-tools"
	WRITE_TOOLS string = "write-tools"

	READ_DCM     string = "read-dcm-"
	READ_DCM_ALL string = "read-dcm-*"

	WRITE_DCM     string = "write-dcm-"
	WRITE_DCM_ALL string = "write-dcm-*"

	READ_FIRMWARE     string = "read-firmware-"
	READ_FIRMWARE_ALL string = "read-firmware-*"

	WRITE_FIRMWARE     string = "write-firmware-"
	WRITE_FIRMWARE_ALL string = "write-firmware-*"

	READ_TELEMETRY     string = "read-telemetry-"
	READ_TELEMETRY_ALL string = "read-telemetry-*"

	WRITE_TELEMETRY     string = "write-telemetry-"
	WRITE_TELEMETRY_ALL string = "write-telemetry-*"

	READ_CHANGES     string = "read-changes-"
	READ_CHANGES_ALL string = "read-changes-*"

	WRITE_CHANGES     string = "write-changes-"
	WRITE_CHANGES_ALL string = "write-changes-*"

	XCONF_ALL           string = "x1:appds:xconf:*"
	XCONF_READ          string = "x1:coast:xconf:read"
	XCONF_READ_MACLIST  string = "x1:coast:xconf:read:maclist"
	XCONF_WRITE         string = "x1:coast:xconf:write"
	XCONF_WRITE_MACLIST string = "x1:coast:xconf:write:maclist"

	DEV_PROFILE string = "dev"

	COMMON_ENTITY    string = "CommonEntity"
	TOOL_ENTITY      string = "ToolEntity"
	CHANGE_ENTITY    string = "ChangeEntity"
	DCM_ENTITY       string = "DcmEntity"
	FIRMWARE_ENTITY  string = "FirmwareEntity"
	TELEMETRY_ENTITY string = "TelemetryEntity"
)

Variables

View Source
var ChangePermissions = EntityPermission{
	ReadAll:  READ_CHANGES_ALL,
	Read:     READ_CHANGES,
	WriteAll: WRITE_CHANGES_ALL,
	Write:    WRITE_CHANGES,
}
View Source
var CommonPermissions = EntityPermission{
	ReadAll:  READ_COMMON,
	WriteAll: WRITE_COMMON,
}
View Source
var DcmPermissions = EntityPermission{
	ReadAll:  READ_DCM_ALL,
	Read:     READ_DCM,
	WriteAll: WRITE_DCM_ALL,
	Write:    WRITE_DCM,
}
View Source
var FirmwarePermissions = EntityPermission{
	ReadAll:  READ_FIRMWARE_ALL,
	Read:     READ_FIRMWARE,
	WriteAll: WRITE_FIRMWARE_ALL,
	Write:    WRITE_FIRMWARE,
}
View Source
var GetPermissionsFunc = getPermissions
View Source
var TelemetryPermissions = EntityPermission{
	ReadAll:  READ_TELEMETRY_ALL,
	Read:     READ_TELEMETRY,
	WriteAll: WRITE_TELEMETRY_ALL,
	Write:    WRITE_TELEMETRY,
}
View Source
var ToolPermissions = EntityPermission{
	ReadAll:  VIEW_TOOLS,
	WriteAll: WRITE_TOOLS,
}

Ws - webserver object

Functions

func AuthInfoHandler

func AuthInfoHandler(w http.ResponseWriter, r *http.Request)

func AuthProvider

func AuthProvider(w http.ResponseWriter, r *http.Request)

func BasicAuthHandler

func BasicAuthHandler(w http.ResponseWriter, r *http.Request)

func CanRead

func CanRead(r *http.Request, entityType string, vargs ...string) (applicationType string, err error)

CanRead returns the applicationType the user has read permission for non-common entityType, otherwise returns error if applicationType is not specified in query parameter or cookie

func CanWrite

func CanWrite(r *http.Request, entityType string, vargs ...string) (applicationType string, err error)

CanWrite returns the applicationType the user has write permission for non-common entityType, otherwise returns error if applicationType is not specified in query parameter or cookie

func CodeHandler

func CodeHandler(w http.ResponseWriter, r *http.Request)

func ExtractBodyAndCheckPermissions

func ExtractBodyAndCheckPermissions(obj owcommon.ApplicationTypeAware, w http.ResponseWriter, r *http.Request, entityType string) (applicationType string, err error)

func GetAdminUIUrlFromCookies

func GetAdminUIUrlFromCookies(r *http.Request) string

func GetDistributedLockOwner added in v1.0.6

func GetDistributedLockOwner(r *http.Request) (owner string)

func GetUserNameOrUnknown

func GetUserNameOrUnknown(r *http.Request) string

func HasReadPermissionForTool

func HasReadPermissionForTool(r *http.Request) bool

func HasWritePermissionForTool

func HasWritePermissionForTool(r *http.Request) bool

func IsDevProfile

func IsDevProfile() bool

func LoginUrlHandler

func LoginUrlHandler(w http.ResponseWriter, r *http.Request)

func LogoutAfterHandler

func LogoutAfterHandler(w http.ResponseWriter, r *http.Request)

func LogoutHandler

func LogoutHandler(w http.ResponseWriter, r *http.Request)

func ValidateRead

func ValidateRead(r *http.Request, entityApplicationType string, entityType string) error

func ValidateWrite

func ValidateWrite(r *http.Request, entityApplicationType string, entityType string) error

func WebServerInjection

func WebServerInjection(ws *xhttp.WebconfigServer)

WebServerInjection - dependency injection

Types

type EntityPermission

type EntityPermission struct {
	ReadAll  string `json:"readAll,omitempty"`
	Read     string `json:"read,omitempty"`
	WriteAll string `json:"writeAll,omitempty"`
	Write    string `json:"write,omitempty"`
}

Jump to

Keyboard shortcuts

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