exampleop

package
v0.0.0-...-cc91d47 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCasAuthenticationSuccessToUser

func ConvertCasAuthenticationSuccessToUser(cas *CasAuthenticationSuccess) *storage.User

func ParseOptionsFromEnv

func ParseOptionsFromEnv(opts interface{}) error

getOptionsFromEnv retrieves options for a service from environment variables. The function returns an Options struct and an error if any required variables are missing.

func SetupServer

func SetupServer(opts Options, storage Storage) *mux.Router

SetupServer creates an OIDC server with Issuer=http://localhost:<port>

Use one of the pre-made clients in storage/clients.go or register a new one.

Types

type Cas

type Cas struct {
	// contains filtered or unexported fields
}

func NewCas

func NewCas(
	store authenticate,
	host string,
	prefixURL string,
	casAddress string,
	casLoginEndpoint string,
	casLogoutEndpoint string,
	casValidateEndpoint string,
	callbackURL func(context.Context, string) string,
	externalGroupsProvider *ExternalGroupsProvider,
) *Cas

type CasAuthenticationFailure

type CasAuthenticationFailure struct {
	Code    string `xml:"code,attr"`
	Message string `xml:",chardata"`
}

type CasAuthenticationSuccess

type CasAuthenticationSuccess struct {
	User                               string `xml:"user" json:"user"`
	SsoId                              string `xml:"attributes>ssoId" json:"ssoId"`
	LastName                           string `xml:"attributes>lastName" json:"lastName"`
	Country                            string `xml:"attributes>country" json:"country"`
	EmailConfirmed                     bool   `xml:"attributes>emailConfirmed" json:"emailConfirmed"`
	Contactid                          string `xml:"attributes>contactid" json:"contactid"`
	HasRememberMe                      bool   `xml:"attributes>hasRememberMe" json:"hasRememberMe"`
	Telephone                          string `xml:"attributes>telephone" json:"telephone"`
	Employee                           int    `xml:"attributes>employee" json:"employee"`
	PasswordCreationTime               int    `xml:"attributes>passwordCreationTime" json:"passwordCreationTime"`
	UserId                             string `xml:"attributes>userId" json:"userId"`
	LastAuthenticationFromRepositories string `xml:"attributes>lastAuthenticationFromRepositories" json:"lastAuthenticationFromRepositories"`
	FirstName                          string `xml:"attributes>firstName" json:"firstName"`
	UserUuid                           string `xml:"attributes>user_uuid" json:"user_uuid"`
	Company                            string `xml:"attributes>company" json:"company"`
	Email                              string `xml:"attributes>email" json:"email"`
	TwoFaActive                        bool   `xml:"attributes>twoFaActive" json:"twoFaActive"`
	Username                           string `xml:"attributes>username" json:"username"`
}

type CasServiceResponse

type CasServiceResponse struct {
	XMLName               xml.Name                  `xml:"http://www.yale.edu/tp/cas serviceResponse"`
	AuthenticationSuccess *CasAuthenticationSuccess `xml:"authenticationSuccess,omitempty"`
	AuthenticationFailure *CasAuthenticationFailure `xml:"authenticationFailure,omitempty"`
}

type ExternalGroupsProvider

type ExternalGroupsProvider struct {
	// contains filtered or unexported fields
}

func NewExternalGroupsProvider

func NewExternalGroupsProvider(url string, header string) *ExternalGroupsProvider

NewExternalGroupsProvider Constructor function for ExternalGroupsProvider

func (*ExternalGroupsProvider) GetGroups

func (egp *ExternalGroupsProvider) GetGroups(userID string) ([]string, error)

GetGroups function retrieves the groups associated with a given user ID from the external provider.

type Options

type Options struct {
	Host                   string `env:"HOST" default:"localhost"`
	Port                   string `env:"PORT" default:"9998"`
	PrefixURL              string `env:"PREFIX_URL" default:""`
	Issuer                 string `env:"ISSUER" default:"http://localhost:9998/"`
	CasAddress             string `env:"CAS_ADDRESS"`
	CasLoginEndpoint       string `env:"CAS_LOGIN_ENDPOINT" default:"/login"`
	CasLogoutEndpoint      string `env:"CAS_LOGOUT_ENDPOINT" default:"/logout"`
	CasValidateEndpoint    string `env:"CAS_VALIDATE_ENDPOINT" default:"/serviceValidate"`
	ClientID               string `env:"CLIENT_ID" default:"web"`
	ClientSecret           string `env:"CLIENT_SECRET"`
	ClientRedirectURIs     string `env:"CLIENT_REDIRECT_URIs" default:"http://localhost:9999/auth/callback"`
	OpenIDKeyPhrase        string `env:"OPENID_KEY_PHRASE"`
	SigningPrivateKey      string `env:"SIGNING_PRIVATE_KEY"`
	SigningPublicKey       string `env:"SIGNING_PUBLIC_KEY"`
	SigningKeyID           string `env:"SIGNING_KEY_ID" default:"682a39b4-cf9f-40de-9fdd-b5c78ff07fe4"`
	InjectedGroups         string `env:"INJECT_GROUPS" default:""`
	ExternalGroupsProvider string `env:"EXTERNAL_GROUPS_PROVIDER" default:""`
	EgpHeader              string `env:"EXTERNAL_GROUPS_PROVIDER_HEADER" default:"user-id"`
}

type Storage

type Storage interface {
	op.Storage
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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