mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
browser policy store type & path in labels.
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
//go:embed policies.json
|
||||
var policiesJson string
|
||||
|
||||
func Generate(policies types.Policies) (string, error) {
|
||||
func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
policiesTmpl := map[string]interface{}{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Parse(policiesJson string) (*types.Policies, error) {
|
||||
policies := types.Policies{}
|
||||
func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
policies := types.BrowserPolicyContent{}
|
||||
|
||||
policiesTmpl := map[string]interface{}{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
@@ -21,12 +21,12 @@ func Parse(policiesJson string) (*types.Policies, error) {
|
||||
//
|
||||
|
||||
if extensions, ok := policiesTmpl["ExtensionInstallForcelist"]; ok {
|
||||
policies.Extensions = []types.Extension{}
|
||||
policies.Extensions = []types.BrowserPolicyExtension{}
|
||||
for _, val := range extensions.([]interface{}) {
|
||||
s := strings.Split(val.(string), ";")
|
||||
policies.Extensions = append(
|
||||
policies.Extensions,
|
||||
types.Extension{
|
||||
types.BrowserPolicyExtension{
|
||||
ID: s[0],
|
||||
URL: s[1],
|
||||
},
|
||||
|
||||
@@ -7,80 +7,24 @@ import (
|
||||
"m1k1o/neko_rooms/internal/types"
|
||||
)
|
||||
|
||||
type PolicyType string
|
||||
|
||||
const (
|
||||
Chromium PolicyType = "chromium"
|
||||
Firefox PolicyType = "friefox"
|
||||
)
|
||||
|
||||
type PoliciesConfig struct {
|
||||
Type PolicyType
|
||||
Path string
|
||||
Profile string
|
||||
}
|
||||
|
||||
func GetConfig(image string) *PoliciesConfig {
|
||||
switch image {
|
||||
case "m1k1o/neko:latest":
|
||||
fallthrough
|
||||
case "m1k1o/neko:firefox":
|
||||
return &PoliciesConfig{
|
||||
Type: Firefox,
|
||||
Path: "/usr/lib/firefox/distribution/policies.json",
|
||||
Profile: "/home/neko/.mozilla/firefox/profile.default",
|
||||
}
|
||||
case "m1k1o/neko:arm-firefox":
|
||||
return &PoliciesConfig{
|
||||
Type: Firefox,
|
||||
Path: "/usr/lib/firefox-esr/distribution/policies.json",
|
||||
Profile: "/home/neko/.mozilla/firefox/profile.default",
|
||||
}
|
||||
case "m1k1o/neko:chromium":
|
||||
fallthrough
|
||||
case "m1k1o/neko:arm-chromium":
|
||||
fallthrough
|
||||
case "m1k1o/neko:ungoogled-chromium":
|
||||
return &PoliciesConfig{
|
||||
Type: Chromium,
|
||||
Path: "/etc/chromium/policies/managed/policies.json",
|
||||
Profile: "/home/neko/.config/chromium",
|
||||
}
|
||||
case "m1k1o/neko:google-chrome":
|
||||
return &PoliciesConfig{
|
||||
Type: Chromium,
|
||||
Path: "/etc/opt/chrome/policies/managed/policies.json",
|
||||
Profile: "/home/neko/.config/google-chrome",
|
||||
}
|
||||
case "m1k1o/neko:brave":
|
||||
return &PoliciesConfig{
|
||||
Type: Chromium,
|
||||
Path: "/etc/brave/policies/managed/policies.json",
|
||||
Profile: "/home/neko/.config/brave",
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Generate(policies types.Policies, policyType PolicyType) (string, error) {
|
||||
if policyType == Chromium {
|
||||
func Generate(policies types.BrowserPolicyContent, policyType types.BrowserPolicyType) (string, error) {
|
||||
if policyType == types.ChromiumBrowserPolicy {
|
||||
return chromium.Generate(policies)
|
||||
}
|
||||
|
||||
if policyType == Firefox {
|
||||
if policyType == types.FirefoxBrowserPolicy {
|
||||
return firefox.Generate(policies)
|
||||
}
|
||||
|
||||
return "", errors.New("unknown policy type")
|
||||
}
|
||||
|
||||
func Parse(policiesJson string, policyType PolicyType) (*types.Policies, error) {
|
||||
if policyType == Chromium {
|
||||
func Parse(policiesJson string, policyType types.BrowserPolicyType) (*types.BrowserPolicyContent, error) {
|
||||
if policyType == types.ChromiumBrowserPolicy {
|
||||
return chromium.Parse(policiesJson)
|
||||
}
|
||||
|
||||
if policyType == Firefox {
|
||||
if policyType == types.FirefoxBrowserPolicy {
|
||||
return firefox.Parse(policiesJson)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
//go:embed policies.json
|
||||
var policiesJson string
|
||||
|
||||
func Generate(policies types.Policies) (string, error) {
|
||||
func Generate(policies types.BrowserPolicyContent) (string, error) {
|
||||
policiesTmpl := struct {
|
||||
Policies map[string]interface{} `json:"policies"`
|
||||
}{}
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"m1k1o/neko_rooms/internal/types"
|
||||
)
|
||||
|
||||
func Parse(policiesJson string) (*types.Policies, error) {
|
||||
policies := types.Policies{}
|
||||
func Parse(policiesJson string) (*types.BrowserPolicyContent, error) {
|
||||
policies := types.BrowserPolicyContent{}
|
||||
|
||||
policiesTmpl := struct {
|
||||
Policies map[string]interface{} `json:"policies"`
|
||||
@@ -28,7 +28,7 @@ func Parse(policiesJson string) (*types.Policies, error) {
|
||||
//
|
||||
|
||||
if extensions, ok := policiesTmpl.Policies["ExtensionSettings"]; ok {
|
||||
policies.Extensions = []types.Extension{}
|
||||
policies.Extensions = []types.BrowserPolicyExtension{}
|
||||
for id, val := range extensions.(map[string]interface{}) {
|
||||
if id == "*" {
|
||||
continue
|
||||
@@ -39,7 +39,7 @@ func Parse(policiesJson string) (*types.Policies, error) {
|
||||
|
||||
policies.Extensions = append(
|
||||
policies.Extensions,
|
||||
types.Extension{
|
||||
types.BrowserPolicyExtension{
|
||||
ID: id,
|
||||
URL: url,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user