sso

package
v0.0.0-...-2f92620 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnAuthorized = errors.New("Not Authorized")
	ErrUserNotFound = errors.New("User Not Found")
)
View Source
var ConfMap = map[string]string{

	"sso_ssl_cert_path": "sso_ssl_cert_path",
	"sso_ssl_key_path":  "sso_ssl_key_path",

	"sso_private_key_path": "sso_private_key_path",

	"sso_weblog_dir": "sso_weblog_dir",

	"sso_user_roles": "sso_user_roles",

	"sso_cookie_name":       "sso_cookie_name",
	"sso_cookie_domain":     "sso_cookie_domain",
	"sso_cookie_validhours": "sso_cookie_validhours",

	"sso_ldap_host":       "sso_ldap_host",
	"sso_ldap_port":       "sso_ldap_port",
	"sso_ldap_ssl":        "sso_ldap_ssl",
	"sso_ldap_basedn":     "sso_ldap_basedn",
	"sso_ldap_binddn":     "sso_ldap_binddn",
	"sso_ldap_bindpasswd": "sso_ldap_bindpasswd",
}

All environment variables config goes here for better tracking.

Functions

This section is empty.

Types

type BaseConfig

type BaseConfig struct {
	SSLCertPath    string
	SSLKeyPath     string
	PrivateKeyPath string
	WeblogDir      string
	UserRoles      bool
}

func SetupBaseConfig

func SetupBaseConfig() (*BaseConfig, error)

SetupBaseConfig function setups some generic configs

type CookieConfig

type CookieConfig struct {
	Name       string
	Domain     string
	ValidHours int64
}

func SetupCookieConfig

func SetupCookieConfig() (*CookieConfig, error)

SetupCookieConfig sets up cookie config.

type SSOer

type SSOer interface {
	// Auth takes user,password strings as arguments and returns the user, user roles (e.g ldap groups)
	// (string slice) if the call succeds. Auth should return the ErrUnAuthorized or ErrUserNotFound error if
	// auth fails or if the user is not found respectively.
	Auth(string, string) (*string, *[]string, error)
	// CTValidHours returns the cookie/jwt token validity in hours.
	CTValidHours() int64
	CookieName() string
	CookieDomain() string
	// BuildJWTToken takes the user and the user roles info which is then signed by the private
	// key of the login server. The expiry of the token is set per the third argument.
	BuildJWTToken(string, []string, time.Time) (string, error)
	// BuildCookie takes the jwt token and returns a cookie and sets the expiration time of the same to that of
	// the second arg.
	BuildCookie(string, time.Time) http.Cookie
	// Logout sets the expiration time of the cookie in the past rendering it unusable.
	Logout(time.Time) http.Cookie
}

SSOImplementer is what it needs to be implemented for sso functionality.

Jump to

Keyboard shortcuts

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