types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlackAuthorizeURL = "https://slack.com/oauth/v2/authorize"
	SlackTokenURL     = "https://slack.com/api/oauth.v2.access"

	NotionAuthorizeURL = "https://api.notion.com/v1/oauth/authorize"
	NotionTokenURL     = "https://api.notion.com/v1/oauth/token"

	HubSpotAuthorizeURL = "https://app.hubspot.com/oauth/authorize"
	HubSpotTokenURL     = "https://api.hubapi.com/oauth/v1/token"

	GoogleAuthorizeURL = "https://accounts.google.com/o/oauth2/v2/auth"
	GoogleTokenURL     = "https://oauth2.googleapis.com/token"

	GitHubAuthorizeUrl = "https://github.com/login/oauth/authorize"
)
View Source
const (
	GitHubOAuthURL = "https://github.com/login/oauth/authorize"
	GitHubTokenURL = "https://github.com/login/oauth/access_token"

	GoogleOAuthURL = "https://accounts.google.com/o/oauth2/auth"
	GoogleJWKSURL  = "https://www.googleapis.com/oauth2/v3/certs"

	AzureOauthURL = "https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/authorize"
	AzureJWKSURL  = "https://login.microsoftonline.com/{tenantID}/discovery/v2.0/keys"

	AuthTypeGitHub      = "github"
	AuthTypeAzureAD     = "azuread"
	AuthTypeGoogle      = "google"
	AuthTypeGenericOIDC = "genericOIDC"
)

Variables

This section is empty.

Functions

func ConvertUser

func ConvertUser(u *User) *types2.User

func EmailClaimByType

func EmailClaimByType(t string) string

func JWKSURLByType

func JWKSURLByType(t string) string

func MergeOAuthAppManifests

func MergeOAuthAppManifests(r, other types.OAuthAppManifest) types.OAuthAppManifest

func OAuthURLByType

func OAuthURLByType(t string) string

func ScopesByType

func ScopesByType(t string) string

func TokenURLByType

func TokenURLByType(t string) string

func UsernameClaimByType

func UsernameClaimByType(t string) string

func ValidateAndSetDefaultsOAuthAppManifest

func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bool) error

Types

type AuthProvider

type AuthProvider struct {
	// These fields are set for every auth provider
	gorm.Model    `json:",inline"`
	Type          string        `json:"type"`
	ServiceName   string        `json:"serviceName"`
	Slug          string        `json:"slug" gorm:"unique"`
	ClientID      string        `json:"clientID"`
	ClientSecret  string        `json:"clientSecret"`
	OAuthURL      string        `json:"oauthURL"`
	Scopes        string        `json:"scopes,omitempty"`
	Expiration    string        `json:"expiration,omitempty"`
	ExpirationDur time.Duration `json:"-"`
	Disabled      bool          `json:"disabled"`
	// Not needed for OIDC type flows
	TokenURL string `json:"tokenURL"`
	// These fields are only set for AzureAD
	TenantID string `json:"tenantID,omitempty"`
	// These fields are only set for OIDC providers, including AzureAD
	JWKSURL       string `json:"jwksURL,omitempty"`
	UsernameClaim string `json:"usernameClaim,omitempty"`
	EmailClaim    string `json:"emailClaim,omitempty"`
}

func (*AuthProvider) AuthURL

func (ap *AuthProvider) AuthURL(baseURL string, state, nonce string) string

func (*AuthProvider) RedirectURL

func (ap *AuthProvider) RedirectURL(baseURL string) string

func (*AuthProvider) ValidateAndSetDefaults

func (ap *AuthProvider) ValidateAndSetDefaults() error

type AuthToken

type AuthToken struct {
	ID             string    `json:"id" gorm:"index:idx_id_hashed_token"`
	UserID         uint      `json:"-" gorm:"index"`
	AuthProviderID uint      `json:"-" gorm:"index"`
	HashedToken    string    `json:"-" gorm:"index:idx_id_hashed_token"`
	CreatedAt      time.Time `json:"createdAt"`
	ExpiresAt      time.Time `json:"expiresAt"`
}

type AuthTypeConfig

type AuthTypeConfig struct {
	DisplayName string            `json:"displayName"`
	Required    map[string]string `json:"required"`
	Advanced    map[string]string `json:"advanced"`
}

type GoogleOAuthTokenResponse

type GoogleOAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

type Identity

type Identity struct {
	AuthProviderID   uint      `json:"authProviderID" gorm:"primaryKey;index:idx_user_auth_id"`
	ProviderUsername string    `json:"providerUsername" gorm:"primaryKey"`
	Email            string    `json:"email"`
	UserID           uint      `json:"userID" gorm:"index:idx_user_auth_id"`
	IconURL          string    `json:"iconURL"`
	IconLastChecked  time.Time `json:"iconLastChecked"`
}

type LLMProvider

type LLMProvider struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Name      string    `json:"name"`
	Slug      string    `json:"slug" gorm:"unique;index"`
	BaseURL   string    `json:"baseURL"`
	Token     string    `json:"token"`
	Disabled  bool      `json:"disabled"`
}

func (*LLMProvider) RequestBaseURL

func (lp *LLMProvider) RequestBaseURL(serverBase string) string

func (*LLMProvider) URL

func (lp *LLMProvider) URL() string

func (*LLMProvider) Validate

func (lp *LLMProvider) Validate() error

type LLMProxyActivity

type LLMProxyActivity struct {
	ID             uint
	CreatedAt      time.Time
	WorkflowID     string
	WorkflowStepID string
	AgentID        string
	ThreadID       string
	RunID          string
	Username       string
	Path           string
}

type Model

type Model struct {
	ID                string    `json:"id" gorm:"unique"`
	CreatedAt         time.Time `json:"createdAt"`
	UpdatedAt         time.Time `json:"updatedAt"`
	LLMProviderID     uint      `json:"llmProviderID" gorm:"foreignKey:id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	ProviderModelName string    `json:"providerModelName"`
	Disabled          bool      `json:"disabled"`
}

func (*Model) Validate

func (m *Model) Validate() error

type OAuthAppTypeConfig

type OAuthAppTypeConfig struct {
	DisplayName string            `json:"displayName"`
	Parameters  map[string]string `json:"parameters"`
}

type OAuthTokenRequestChallenge

type OAuthTokenRequestChallenge struct {
	State     string    `json:"state" gorm:"primaryKey"`
	Challenge string    `json:"challenge"`
	CreatedAt time.Time `json:"createdAt"`
}

type OAuthTokenResponse

type OAuthTokenResponse struct {
	State        string `json:"state"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	ExtExpiresIn int    `json:"ext_expires_in"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	Ok           bool   `json:"ok"`
	Error        string `json:"error"`
	CreatedAt    time.Time
}

OAuthTokenResponse represents a response from the /token endpoint on an OAuth server. These do not get stored in the database.

type SlackOAuthTokenResponse

type SlackOAuthTokenResponse struct {
	Ok         bool   `json:"ok"`
	Error      string `json:"error"`
	AuthedUser struct {
		ID          string `json:"id"`
		Scope       string `json:"scope"`
		AccessToken string `json:"access_token"`
	} `json:"authed_user"`
}

type TokenRequest

type TokenRequest struct {
	ID                    string `gorm:"primaryKey"`
	CreatedAt             time.Time
	UpdatedAt             time.Time
	State                 string `gorm:"index"`
	Nonce                 string
	Token                 string
	ExpiresAt             time.Time
	CompletionRedirectURL string
	Error                 string
	TokenRetrieved        bool
}

type User

type User struct {
	ID        uint        `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time   `json:"createdAt"`
	Username  string      `json:"username" gorm:"unique"`
	Email     string      `json:"email"`
	Role      types2.Role `json:"role"`
	IconURL   string      `json:"iconURL"`
}

type UserQuery

type UserQuery struct {
	Username string
	Email    string
	Role     types2.Role
}

func NewUserQuery

func NewUserQuery(u url.Values) UserQuery

func (UserQuery) Scope

func (q UserQuery) Scope(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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