idp

package
v0.0.0-...-976a764 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginReadTx

func BeginReadTx(driver neo4j.Driver, configurers ...func(*neo4j.TransactionConfig)) (neo4j.Session, neo4j.Transaction, error)

func BeginWriteTx

func BeginWriteTx(driver neo4j.Driver, configurers ...func(*neo4j.TransactionConfig)) (neo4j.Session, neo4j.Transaction, error)

func CreateChallengeUsingOtp

func CreateChallengeUsingOtp(tx neo4j.Transaction, challengeType ChallengeType, newChallenge Challenge) (challenge Challenge, otpCode ChallengeCode, err error)

func CreatePassword

func CreatePassword(password string) (string, error)

func Decrypt

func Decrypt(str string, key string) (string, error)

Enforce AES-256 by using 32 byte string as key param

func EmitEventClientCreated

func EmitEventClientCreated(natsConnection *nats.Conn, client Client)

func EmitEventHumanCreated

func EmitEventHumanCreated(natsConnection *nats.Conn, human Human)

func EmitEventHumanEmailChanged

func EmitEventHumanEmailChanged(natsConnection *nats.Conn, human Human)

func EmitEventHumanPasswordChanged

func EmitEventHumanPasswordChanged(natsConnection *nats.Conn, human Human)

func EmitEventIdentityAuthenticated

func EmitEventIdentityAuthenticated(natsConnection *nats.Conn, i Identity, acr string)

func EmitEventInviteCreated

func EmitEventInviteCreated(natsConnection *nats.Conn, invite Invite)

func EmitEventInviteSent

func EmitEventInviteSent(natsConnection *nats.Conn, invite Invite)

func EmitEventResourceServerCreated

func EmitEventResourceServerCreated(natsConnection *nats.Conn, resourceServer ResourceServer)

func Encrypt

func Encrypt(str string, key string) (string, error)

Enforce AES-256 by using 32 byte string as key param

func GenerateRandomDigits

func GenerateRandomDigits(max int) (string, error)

func SendEmail

func SendEmail(smtpConfig SMTPConfig, name string, email string, subject string, body string) (bool, error)

func SendEmailUsingTemplate

func SendEmailUsingTemplate(smtpConfig SMTPConfig, name string, email string, subject string, templateFile string, data interface{}) (bool, error)

func ValidateOtp

func ValidateOtp(otp string, secret string) (bool, error)

func ValidatePassword

func ValidatePassword(storedPassword string, password string) (bool, error)

Types

type Challenge

type Challenge struct {
	Id            string
	ChallengeType ChallengeType

	JwtRegisteredClaims

	RedirectTo string
	CodeType   int64

	Code string

	VerifiedAt int64

	Data string
}

func CreateChallengeUsingTotp

func CreateChallengeUsingTotp(tx neo4j.Transaction, challengeType ChallengeType, newChallenge Challenge) (challenge Challenge, err error)

func FetchChallenges

func FetchChallenges(tx neo4j.Transaction, iChallenges []Challenge) (challenges []Challenge, err error)

func VerifyChallenge

func VerifyChallenge(tx neo4j.Transaction, challengeToUpdate Challenge) (updatedChallenge Challenge, err error)

type ChallengeCode

type ChallengeCode struct {
	Code string
}

func CreateChallengeCode

func CreateChallengeCode() (ChallengeCode, error)

type ChallengeType

type ChallengeType int
const (
	ChallengeNotSupported ChallengeType = iota + 0 // Start a 0
	ChallengeAuthenticate
	ChallengeRecover
	ChallengeDelete
	ChallengeEmailConfirm
	ChallengeEmailChange
)

func (ChallengeType) String

func (d ChallengeType) String() string

type Client

type Client struct {
	Identity
	Secret                  string
	Name                    string
	Description             string
	GrantTypes              []string
	Audiences               []string
	ResponseTypes           []string
	RedirectUris            []string
	PostLogoutRedirectUris  []string
	TokenEndpointAuthMethod string
}

func CreateClient

func CreateClient(tx neo4j.Transaction, managedBy *Identity, newClient Client) (client Client, err error)

func DeleteClient

func DeleteClient(tx neo4j.Transaction, managedBy *Identity, clientToDelete Client) (client Client, err error)

func FetchClients

func FetchClients(tx neo4j.Transaction, managedBy *Identity, iClients []Client) (clients []Client, err error)

type DeleteChallenge

type DeleteChallenge struct {
	Id         string
	Code       string
	Expire     int64
	RedirectTo string
}

func CreateDeleteChallenge

func CreateDeleteChallenge(url string, identity Human, challengeTimeoutInSeconds int64) (DeleteChallenge, error)

type Human

type Human struct {
	Identity

	// Identity.Id aliasses
	Email            string
	EmailConfirmedAt int64
	Username         string

	Name string

	AllowLogin bool

	Password string

	TotpRequired bool
	TotpSecret   string
}

func ConfirmEmail

func ConfirmEmail(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func CreateHuman

func CreateHuman(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func CreateHumanFromInvite

func CreateHumanFromInvite(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func DeleteHuman

func DeleteHuman(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func FetchHumans

func FetchHumans(tx neo4j.Transaction, iHumans []Human) (humans []Human, err error)

func FetchHumansByEmail

func FetchHumansByEmail(tx neo4j.Transaction, iHumans []Human) (humans []Human, err error)

func FetchHumansByUsername

func FetchHumansByUsername(tx neo4j.Transaction, iHumans []Human) (humans []Human, err error)

func UpdateAllowLogin

func UpdateAllowLogin(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func UpdateEmail

func UpdateEmail(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func UpdateHuman

func UpdateHuman(tx neo4j.Transaction, newHuman Human) (human Human, err error)

NOTE: This can update everything that is _NOT_ sensitive to the authentication process like Identity.Password

To change the password see recover for that or iff identified UpdatePassword

func UpdatePassword

func UpdatePassword(tx neo4j.Transaction, newHuman Human) (human Human, err error)

func UpdateTotp

func UpdateTotp(tx neo4j.Transaction, newHuman Human) (human Human, err error)

type Identity

type Identity struct {
	Id     string
	Labels string

	// JWT
	// Subject string // Renamed it to Identity.Id
	Issuer    string
	ExpiresAt int64
	IssuedAt  int64

	OtpDeleteCode       string
	OtpDeleteCodeExpire int64

	CreatedBy *Identity
}

func FetchIdentities

func FetchIdentities(tx neo4j.Transaction, iIdentities []Identity) (identities []Identity, err error)

func SearchIdentities

func SearchIdentities(tx neo4j.Transaction, iSearch string) (identities []Identity, err error)

type Invite

type Invite struct {
	Identity

	Email    string
	Username string

	SentAt int64
}

func CreateInvite

func CreateInvite(tx neo4j.Transaction, invitedBy *Identity, newInvite Invite) (invite Invite, err error)

func FetchInvites

func FetchInvites(tx neo4j.Transaction, invitedBy *Identity, iInvites []Invite) (invites []Invite, err error)

func FetchInvitesByEmail

func FetchInvitesByEmail(tx neo4j.Transaction, invitedBy *Identity, iInvites []Invite) (invites []Invite, err error)

func FetchInvitesByUsername

func FetchInvitesByUsername(tx neo4j.Transaction, invitedBy *Identity, iInvites []Invite) (invites []Invite, err error)

func UpdateInviteSentAt

func UpdateInviteSentAt(tx neo4j.Transaction, updatedBy *Identity, inviteToUpdate Invite) (invite Invite, err error)

type JwtRegisteredClaims

type JwtRegisteredClaims struct {
	Issuer    string
	Subject   string
	Audience  string
	ExpiresAt int64
	NotBefore int64
	IssuedAt  int64
	JwtId     string
}

type RecoverChallenge

type RecoverChallenge struct {
	Id         string
	Code       string
	Expire     int64
	RedirectTo string
}

func CreateRecoverChallenge

func CreateRecoverChallenge(url string, identity Human, challengeTimeoutInSeconds int64) (RecoverChallenge, error)

type ResourceServer

type ResourceServer struct {
	Identity
	Name        string
	Description string
	Audience    string
}

func CreateResourceServer

func CreateResourceServer(tx neo4j.Transaction, managedBy *Identity, newResourceServer ResourceServer) (resourceServer ResourceServer, err error)

func DeleteResourceServer

func DeleteResourceServer(tx neo4j.Transaction, managedBy *Identity, resourceServerToDelete ResourceServer) (resourceServer ResourceServer, err error)

func FetchResourceServers

func FetchResourceServers(tx neo4j.Transaction, managedBy *Identity, iResourceServers []ResourceServer) (resourceServers []ResourceServer, err error)

type Role

type Role struct {
	Identity
	Name        string
	Description string
}

func CreateRole

func CreateRole(tx neo4j.Transaction, iRole Role, requestor Identity) (rRole Role, err error)

func DeleteRole

func DeleteRole(tx neo4j.Transaction, iRole Role, requestor Identity) (rRole Role, err error)

func FetchRoles

func FetchRoles(tx neo4j.Transaction, iFilterRoles []Role, iRequest Identity) (rRoles []Role, err error)

type SMTPConfig

type SMTPConfig struct {
	Host          string
	Username      string
	Password      string
	Sender        SMTPSender
	SkipTlsVerify int
}

type SMTPSender

type SMTPSender struct {
	Name       string
	Email      string
	ReturnPath string
}

Jump to

Keyboard shortcuts

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