config

package
v0.0.0-...-4892902 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ApiVersionKey = "apiVersion"
View Source
const AuthdConfigKind = "AuthdConfig"
View Source
const AuthdSocketConfigKind = "AuthdSocketConfig"
View Source
const KindKey = "kind"

Variables

View Source
var Schemas = map[string]string{
	"AuthdConfig/v1": `
type: object
additionalProperties: false
minProperties: 4
properties:
  apiVersion:
    title: apiVersion
    description: |
      API domain and version
    type: string
  kind:
    title: kind
    description: |
      Config kind
    type: string
  jwtPath:
    type: string
  defaultSocketDirectory:
    description: |
      A path where all server sockets are created.
    type: string
  servers:
    type: array
    additionalItems: false
    minItems: 1
    items:
      type: object
      additionalProperties: false
      required:
      - domain
      - type
      properties:
        type:
          description: |
            Vault server type
          type: string
          enum:
          - Auth
          - RootSource
          - Test
        domain:
          description: |
            Vault server address
          type: string
        allowRedirects:
          description: |
            Vault server address
          type: array
          items:
            type: string
`,
	"AuthdSocketConfig/v1": `
type: object
additionalProperties: false
minProperties: 4
properties:
  apiVersion:
    title: apiVersion
    description: |
      API domain and version
    type: string
  kind:
    title: kind
    description: |
      Config kind
    type: string
  path:
    type: string
  user:
    type: string
  group:
    type: string
  mode:
    type: number
  allowedRoles:
    type: array
    additionalItems: false
    minItems: 1
    items:
      type: object
      additionalProperties: false
      required:
      - role
      properties:
        role:
          type: string
`,
}
View Source
var SchemasCache = map[string]*spec.Schema{}

Functions

func DetectServerAddr

func DetectServerAddr(servers []Server, serverType, serverAddr string) (string, error)

serverAddr может быть пустым, тогда надо найти дефолтный сервер по serverType если не пустой, то надо проверить его по всем серверам типа serverType проверка по нужна по domain и по списку allowedRedirects

func GetDefaultServerAddr

func GetDefaultServerAddr(servers []Server, serverType string) (string, error)

func GetSchema

func GetSchema(name string) *spec.Schema

GetSchema returns loaded schema.

func IsDomainAllowed

func IsDomainAllowed(server Server, serverAddr string) bool

matchDomainPattern matches srv against a pattern.

1. pattern == srv 2. if pattern starts with *., subdomain.srv is allowed

func LoadConfigFiles

func LoadConfigFiles(paths []string) (*AuthdConfig, []*AuthdSocketConfig, error)

func LoadSchema

func LoadSchema(name string) (*spec.Schema, error)

LoadSchema returns spec.Schema object loaded from yaml in Schemas map.

func RecursiveFindConfFiles

func RecursiveFindConfFiles(dir string) ([]string, error)

RecursiveFindConfFiles finds all yaml files in dir.

Types

type AllowedRole

type AllowedRole struct {
	Role string `json:"role"`
}

type AuthdConfig

type AuthdConfig struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

apiVersion: authd.example.com/v1alpha1 kind: AuthdConfig jwtPath: /var/lib/authd.jwt servers:

  • type: RootSource domain: root-source.auth.example.com
  • type: Auth domain: auth.example.com allowRedirects:
  • *.auth.example.com
  • type: Auth domain: auth2.example.com allowRedirects:
  • *.auth2.example.com

func (*AuthdConfig) GetDefaultSocketDirectory

func (a *AuthdConfig) GetDefaultSocketDirectory() string

func (*AuthdConfig) GetJWTPath

func (a *AuthdConfig) GetJWTPath() string

func (*AuthdConfig) GetServers

func (a *AuthdConfig) GetServers() []Server

func (*AuthdConfig) Load

func (c *AuthdConfig) Load(metadata Metadata, data []byte) error

func (*AuthdConfig) LoadV1

func (c *AuthdConfig) LoadV1(data []byte) (*AuthdConfigV1, error)

type AuthdConfigV1

type AuthdConfigV1 struct {
	JwtPath                string   `json:"jwtPath"`
	DefaultSocketDirectory string   `json:"defaultSocketDirectory"`
	Servers                []Server `json:"servers"`
}

type AuthdSocketConfig

type AuthdSocketConfig struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

apiVersion: authd.negentropy.flant.com/v1alpha1 kind: AuthdSocketConfig path: /var/run/my.sock user: root group: root mode: 0600 allowedServerTypes: [RootSource, Auth] allowedRoles: - role: iam.view - role: iam.edit - role: server.ssh.*

func (*AuthdSocketConfig) GetAllowedRoles

func (a *AuthdSocketConfig) GetAllowedRoles() []AllowedRole

func (*AuthdSocketConfig) GetAllowedServerTypes

func (a *AuthdSocketConfig) GetAllowedServerTypes() []string

func (*AuthdSocketConfig) GetGroup

func (a *AuthdSocketConfig) GetGroup() string

func (*AuthdSocketConfig) GetMode

func (a *AuthdSocketConfig) GetMode() int

func (*AuthdSocketConfig) GetPath

func (a *AuthdSocketConfig) GetPath() string

func (*AuthdSocketConfig) GetUser

func (a *AuthdSocketConfig) GetUser() string

func (*AuthdSocketConfig) Load

func (c *AuthdSocketConfig) Load(metadata Metadata, data []byte) error

func (*AuthdSocketConfig) LoadV1

func (c *AuthdSocketConfig) LoadV1(data []byte) (*AuthdSocketConfigV1, error)

type AuthdSocketConfigV1

type AuthdSocketConfigV1 struct {
	Path               string        `json:"path"`
	User               string        `json:"user"`
	Group              string        `json:"group"`
	Mode               int           `json:"mode"`
	AllowedServerTypes []string      `json:"allowedServerTypes"`
	AllowedRoles       []AllowedRole `json:"allowedRole"`
}

type Metadata

type Metadata struct {
	Api     string
	Version string
	Kind    string
}

func (Metadata) ApiVersion

func (m Metadata) ApiVersion() string

func (Metadata) String

func (m Metadata) String() string

type Server

type Server struct {
	Type           string   `json:"type"`
	Domain         string   `json:"domain"`
	AllowRedirects []string `json:"allowedRedirects,omitempty"`
}

type VersionedUntyped

type VersionedUntyped struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

func (*VersionedUntyped) Data

func (u *VersionedUntyped) Data() []byte

func (*VersionedUntyped) DetectMetadata

func (u *VersionedUntyped) DetectMetadata(data []byte) error

func (*VersionedUntyped) Object

func (u *VersionedUntyped) Object() map[string]interface{}

Jump to

Keyboard shortcuts

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