auth

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: MIT Imports: 15 Imported by: 631

Documentation

Index

Constants

View Source
const (
	AvatarLocal  string = "local"
	AvatarByMail string = "bymail"
)

Avatar types

Variables

This section is empty.

Functions

func AssignForm

func AssignForm(form interface{}, data map[string]interface{})

AssignForm assign form values back to the template data.

func GetInclude

func GetInclude(field reflect.StructField) string

GetInclude get include in form tag

func GetMaxSize

func GetMaxSize(field reflect.StructField) string

GetMaxSize get max size in form tag

func GetMinSize

func GetMinSize(field reflect.StructField) string

GetMinSize get minimal size in form tag

func GetSize

func GetSize(field reflect.StructField) string

GetSize get size int form tag

func IsAPIPath

func IsAPIPath(url string) bool

IsAPIPath if URL is an api path

func SignedInID

func SignedInID(ctx *macaron.Context, sess session.Store) int64

SignedInID returns the id of signed in user.

func SignedInUser

func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool)

SignedInUser returns the user object of signed user. It returns a bool value to indicate whether user uses basic auth or not.

Types

type AddEmailForm

type AddEmailForm struct {
	Email string `binding:"Required;Email;MaxSize(254)"`
}

AddEmailForm form for adding new email

func (*AddEmailForm) Validate

func (f *AddEmailForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type AddKeyForm added in v1.2.0

type AddKeyForm struct {
	Type    string `binding:"OmitEmpty"`
	Title   string `binding:"Required;MaxSize(50)"`
	Content string `binding:"Required"`
}

AddKeyForm form for adding SSH/GPG key

func (*AddKeyForm) Validate added in v1.2.0

func (f *AddKeyForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type AddOpenIDForm added in v1.2.0

type AddOpenIDForm struct {
	Openid string `binding:"Required;MaxSize(256)"`
}

AddOpenIDForm is for changing openid uri

func (*AddOpenIDForm) Validate added in v1.2.0

func (f *AddOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type AdminCreateUserForm added in v1.0.0

type AdminCreateUserForm struct {
	LoginType  string `binding:"Required"`
	LoginName  string
	UserName   string `binding:"Required;AlphaDashDot;MaxSize(35)"`
	Email      string `binding:"Required;Email;MaxSize(254)"`
	Password   string `binding:"MaxSize(255)"`
	SendNotify bool
}

AdminCreateUserForm form for admin to create user

func (*AdminCreateUserForm) Validate added in v1.0.0

func (f *AdminCreateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates form fields

type AdminEditUserForm

type AdminEditUserForm struct {
	LoginType               string `binding:"Required"`
	LoginName               string
	FullName                string `binding:"MaxSize(100)"`
	Email                   string `binding:"Required;Email;MaxSize(254)"`
	Password                string `binding:"MaxSize(255)"`
	Website                 string `binding:"ValidUrl;MaxSize(255)"`
	Location                string `binding:"MaxSize(50)"`
	MaxRepoCreation         int
	Active                  bool
	Admin                   bool
	AllowGitHook            bool
	AllowImportLocal        bool
	AllowCreateOrganization bool
	ProhibitLogin           bool
}

AdminEditUserForm form for admin to create user

func (*AdminEditUserForm) Validate

func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates form fields

type AuthenticationForm

type AuthenticationForm struct {
	ID                            int64
	Type                          int    `binding:"Range(2,6)"`
	Name                          string `binding:"Required;MaxSize(30)"`
	Host                          string
	Port                          int
	BindDN                        string
	BindPassword                  string
	UserBase                      string
	UserDN                        string
	AttributeUsername             string
	AttributeName                 string
	AttributeSurname              string
	AttributeMail                 string
	AttributesInBind              bool
	Filter                        string
	AdminFilter                   string
	IsActive                      bool
	IsSyncEnabled                 bool
	SMTPAuth                      string
	SMTPHost                      string
	SMTPPort                      int
	AllowedDomains                string
	SecurityProtocol              int `binding:"Range(0,2)"`
	TLS                           bool
	SkipVerify                    bool
	PAMServiceName                string
	Oauth2Provider                string
	Oauth2Key                     string
	Oauth2Secret                  string
	OpenIDConnectAutoDiscoveryURL string
	Oauth2UseCustomURL            bool
	Oauth2TokenURL                string
	Oauth2AuthURL                 string
	Oauth2ProfileURL              string
	Oauth2EmailURL                string
}

AuthenticationForm form for authentication

func (*AuthenticationForm) Validate

func (f *AuthenticationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates fields

type AvatarForm

type AvatarForm struct {
	Source      string
	Avatar      *multipart.FileHeader
	Gravatar    string `binding:"OmitEmpty;Email;MaxSize(254)"`
	Federavatar bool
}

AvatarForm form for changing avatar

func (*AvatarForm) Validate

func (f *AvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type ChangePasswordForm

type ChangePasswordForm struct {
	OldPassword string `form:"old_password" binding:"MaxSize(255)"`
	Password    string `form:"password" binding:"Required;MaxSize(255)"`
	Retype      string `form:"retype"`
}

ChangePasswordForm form for changing password

func (*ChangePasswordForm) Validate

func (f *ChangePasswordForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type ConnectOpenIDForm added in v1.2.0

type ConnectOpenIDForm struct {
	UserName string `binding:"Required;MaxSize(254)"`
	Password string `binding:"Required;MaxSize(255)"`
}

ConnectOpenIDForm form for connecting an existing account to an OpenID URI

func (*ConnectOpenIDForm) Validate added in v1.2.0

func (f *ConnectOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type CreateCommentForm

type CreateCommentForm struct {
	Content string
	Status  string `binding:"OmitEmpty;In(reopen,close)"`
	Files   []string
}

CreateCommentForm form for creating comment

func (*CreateCommentForm) Validate

func (f *CreateCommentForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type CreateIssueForm

type CreateIssueForm struct {
	Title       string `binding:"Required;MaxSize(255)"`
	LabelIDs    string `form:"label_ids"`
	MilestoneID int64
	AssigneeID  int64
	Content     string
	Files       []string
}

CreateIssueForm form for creating issue

func (*CreateIssueForm) Validate

func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type CreateLabelForm

type CreateLabelForm struct {
	ID    int64
	Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_name"`
	Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
}

CreateLabelForm form for creating label

func (*CreateLabelForm) Validate

func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type CreateMilestoneForm

type CreateMilestoneForm struct {
	Title    string `binding:"Required;MaxSize(50)"`
	Content  string
	Deadline string
}

CreateMilestoneForm form for creating milestone

func (*CreateMilestoneForm) Validate

Validate validates the fields

type CreateOrgForm

type CreateOrgForm struct {
	OrgName string `binding:"Required;AlphaDashDot;MaxSize(35)" locale:"org.org_name_holder"`
}

CreateOrgForm form for creating organization

func (*CreateOrgForm) Validate

func (f *CreateOrgForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type CreateRepoForm

type CreateRepoForm struct {
	UID         int64  `binding:"Required"`
	RepoName    string `binding:"Required;AlphaDashDot;MaxSize(100)"`
	Private     bool
	Description string `binding:"MaxSize(255)"`
	AutoInit    bool
	Gitignores  string
	License     string
	Readme      string
}

CreateRepoForm form for creating repository

func (*CreateRepoForm) Validate

func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type CreateTeamForm

type CreateTeamForm struct {
	TeamName    string `binding:"Required;AlphaDashDot;MaxSize(30)"`
	Description string `binding:"MaxSize(255)"`
	Permission  string
	Units       []models.UnitType
}

CreateTeamForm form for creating team

func (*CreateTeamForm) Validate

func (f *CreateTeamForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type DeleteRepoFileForm

type DeleteRepoFileForm struct {
	CommitSummary string `binding:"MaxSize(100)"`
	CommitMessage string
	CommitChoice  string `binding:"Required;MaxSize(50)"`
	NewBranchName string `binding:"GitRefName;MaxSize(100)"`
}

DeleteRepoFileForm form for deleting repository file

func (*DeleteRepoFileForm) Validate

func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type EditPreviewDiffForm

type EditPreviewDiffForm struct {
	Content string
}

EditPreviewDiffForm form for changing preview diff

func (*EditPreviewDiffForm) Validate

Validate validates the fields

type EditReleaseForm

type EditReleaseForm struct {
	Title      string `form:"title" binding:"Required"`
	Content    string `form:"content"`
	Draft      string `form:"draft"`
	Prerelease bool   `form:"prerelease"`
	Files      []string
}

EditReleaseForm form for changing release

func (*EditReleaseForm) Validate

func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type EditRepoFileForm

type EditRepoFileForm struct {
	TreePath      string `binding:"Required;MaxSize(500)"`
	Content       string `binding:"Required"`
	CommitSummary string `binding:"MaxSize(100)"`
	CommitMessage string
	CommitChoice  string `binding:"Required;MaxSize(50)"`
	NewBranchName string `binding:"GitRefName;MaxSize(100)"`
	LastCommit    string
}

EditRepoFileForm form for changing repository file

func (*EditRepoFileForm) Validate

func (f *EditRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type Form

type Form interface {
	binding.Validator
}

Form form binding interface

type InitializeLabelsForm

type InitializeLabelsForm struct {
	TemplateName string `binding:"Required"`
}

InitializeLabelsForm form for initializing labels

func (*InitializeLabelsForm) Validate

Validate validates the fields

type InstallForm

type InstallForm struct {
	DbType   string `binding:"Required"`
	DbHost   string
	DbUser   string
	DbPasswd string
	DbName   string
	SSLMode  string
	DbPath   string

	AppName      string `binding:"Required" locale:"install.app_name"`
	RepoRootPath string `binding:"Required"`
	LFSRootPath  string
	RunUser      string `binding:"Required"`
	Domain       string `binding:"Required"`
	SSHPort      int
	HTTPPort     string `binding:"Required"`
	AppURL       string `binding:"Required"`
	LogRootPath  string `binding:"Required"`

	SMTPHost        string
	SMTPFrom        string
	SMTPUser        string `binding:"OmitEmpty;MaxSize(254)" locale:"install.mailer_user"`
	SMTPPasswd      string
	RegisterConfirm bool
	MailNotify      bool

	OfflineMode                    bool
	DisableGravatar                bool
	EnableFederatedAvatar          bool
	EnableOpenIDSignIn             bool
	EnableOpenIDSignUp             bool
	DisableRegistration            bool
	EnableCaptcha                  bool
	RequireSignInView              bool
	DefaultKeepEmailPrivate        bool
	DefaultAllowCreateOrganization bool
	NoReplyAddress                 string

	AdminName          string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`
	AdminPasswd        string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"`
	AdminConfirmPasswd string
	AdminEmail         string `binding:"OmitEmpty;MinSize(3);MaxSize(254);Include(@)" locale:"install.admin_email"`
}

InstallForm form for installation page

func (*InstallForm) Validate

func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type MigrateRepoForm

type MigrateRepoForm struct {
	CloneAddr    string `json:"clone_addr" binding:"Required"`
	AuthUsername string `json:"auth_username"`
	AuthPassword string `json:"auth_password"`
	UID          int64  `json:"uid" binding:"Required"`
	RepoName     string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
	Mirror       bool   `json:"mirror"`
	Private      bool   `json:"private"`
	Description  string `json:"description" binding:"MaxSize(255)"`
}

MigrateRepoForm form for migrating repository

func (MigrateRepoForm) ParseRemoteAddr

func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error)

ParseRemoteAddr checks if given remote address is valid, and returns composed URL with needed username and password. It also checks if given user has permission when remote address is actually a local path.

func (*MigrateRepoForm) Validate

func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type NewAccessTokenForm

type NewAccessTokenForm struct {
	Name string `binding:"Required"`
}

NewAccessTokenForm form for creating access token

func (*NewAccessTokenForm) Validate

func (f *NewAccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type NewGogshookForm added in v1.2.0

type NewGogshookForm struct {
	PayloadURL  string `binding:"Required;ValidUrl"`
	ContentType int    `binding:"Required"`
	Secret      string
	WebhookForm
}

NewGogshookForm form for creating gogs hook

func (*NewGogshookForm) Validate added in v1.2.0

func (f *NewGogshookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type NewReleaseForm

type NewReleaseForm struct {
	TagName    string `binding:"Required"`
	Target     string `form:"tag_target" binding:"Required"`
	Title      string `binding:"Required"`
	Content    string
	Draft      string
	Prerelease bool
	Files      []string
}

NewReleaseForm form for creating release

func (*NewReleaseForm) Validate

func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type NewSlackHookForm

type NewSlackHookForm struct {
	PayloadURL string `binding:"Required;ValidUrl"`
	Channel    string `binding:"Required"`
	Username   string
	IconURL    string
	Color      string
	WebhookForm
}

NewSlackHookForm form for creating slack hook

func (*NewSlackHookForm) Validate

func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type NewWebhookForm

type NewWebhookForm struct {
	PayloadURL  string `binding:"Required;ValidUrl"`
	ContentType int    `binding:"Required"`
	Secret      string
	WebhookForm
}

NewWebhookForm form for creating web hook

func (*NewWebhookForm) Validate

func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type NewWikiForm

type NewWikiForm struct {
	OldTitle string
	Title    string `binding:"Required"`
	Content  string `binding:"Required"`
	Message  string
}

NewWikiForm form for creating wiki

func (*NewWikiForm) Validate

func (f *NewWikiForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields FIXME: use code generation to generate this method.

type RegisterForm

type RegisterForm struct {
	UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
	Email    string `binding:"Required;Email;MaxSize(254)"`
	Password string `binding:"Required;MaxSize(255)"`
	Retype   string
}

RegisterForm form for registering

func (*RegisterForm) Validate

func (f *RegisterForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type RemoveUploadFileForm

type RemoveUploadFileForm struct {
	File string `binding:"Required;MaxSize(50)"`
}

RemoveUploadFileForm form for removing uploaded file

func (*RemoveUploadFileForm) Validate

Validate validates the fields

type RepoSettingForm

type RepoSettingForm struct {
	RepoName      string `binding:"Required;AlphaDashDot;MaxSize(100)"`
	Description   string `binding:"MaxSize(255)"`
	Website       string `binding:"ValidUrl;MaxSize(255)"`
	Interval      string
	MirrorAddress string
	Private       bool
	EnablePrune   bool

	// Advanced settings
	EnableWiki            bool
	EnableExternalWiki    bool
	ExternalWikiURL       string
	EnableIssues          bool
	EnableExternalTracker bool
	ExternalTrackerURL    string
	TrackerURLFormat      string
	TrackerIssueStyle     string
	EnablePulls           bool
}

RepoSettingForm form for changing repository settings

func (*RepoSettingForm) Validate

func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type SignInForm

type SignInForm struct {
	UserName string `binding:"Required;MaxSize(254)"`
	Password string `binding:"Required;MaxSize(255)"`
	Remember bool
}

SignInForm form for signing in with user/password

func (*SignInForm) Validate

func (f *SignInForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type SignInOpenIDForm added in v1.2.0

type SignInOpenIDForm struct {
	Openid   string `binding:"Required;MaxSize(256)"`
	Remember bool
}

SignInOpenIDForm form for signing in with OpenID

func (*SignInOpenIDForm) Validate added in v1.2.0

func (f *SignInOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type SignUpOpenIDForm added in v1.2.0

type SignUpOpenIDForm struct {
	UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
	Email    string `binding:"Required;Email;MaxSize(254)"`
}

SignUpOpenIDForm form for signin up with OpenID

func (*SignUpOpenIDForm) Validate added in v1.2.0

func (f *SignUpOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type TwoFactorAuthForm added in v1.1.0

type TwoFactorAuthForm struct {
	Passcode string `binding:"Required"`
}

TwoFactorAuthForm for logging in with 2FA token.

func (*TwoFactorAuthForm) Validate added in v1.1.0

func (f *TwoFactorAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type TwoFactorScratchAuthForm added in v1.1.0

type TwoFactorScratchAuthForm struct {
	Token string `binding:"Required"`
}

TwoFactorScratchAuthForm for logging in with 2FA scratch token.

func (*TwoFactorScratchAuthForm) Validate added in v1.1.0

func (f *TwoFactorScratchAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate valideates the fields

type UpdateOrgSettingForm

type UpdateOrgSettingForm struct {
	Name            string `binding:"Required;AlphaDashDot;MaxSize(35)" locale:"org.org_name_holder"`
	FullName        string `binding:"MaxSize(100)"`
	Description     string `binding:"MaxSize(255)"`
	Website         string `binding:"ValidUrl;MaxSize(255)"`
	Location        string `binding:"MaxSize(50)"`
	MaxRepoCreation int
}

UpdateOrgSettingForm form for updating organization settings

func (*UpdateOrgSettingForm) Validate

func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type UpdateProfileForm

type UpdateProfileForm struct {
	Name             string `binding:"AlphaDashDot;MaxSize(35)"`
	FullName         string `binding:"MaxSize(100)"`
	Email            string `binding:"Required;Email;MaxSize(254)"`
	KeepEmailPrivate bool
	Website          string `binding:"ValidUrl;MaxSize(255)"`
	Location         string `binding:"MaxSize(50)"`
}

UpdateProfileForm form for updating profile

func (*UpdateProfileForm) Validate

func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type UploadRepoFileForm

type UploadRepoFileForm struct {
	TreePath      string `binding:"MaxSize(500)"`
	CommitSummary string `binding:"MaxSize(100)"`
	CommitMessage string
	CommitChoice  string `binding:"Required;MaxSize(50)"`
	NewBranchName string `binding:"GitRefName;MaxSize(100)"`
	Files         []string
}

UploadRepoFileForm form for uploading repository file

func (*UploadRepoFileForm) Validate

func (f *UploadRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate validates the fields

type WebhookForm

type WebhookForm struct {
	Events      string
	Create      bool
	Push        bool
	PullRequest bool
	Active      bool
}

WebhookForm form for changing web hook

func (WebhookForm) ChooseEvents

func (f WebhookForm) ChooseEvents() bool

ChooseEvents if the hook will be triggered choose events

func (WebhookForm) PushOnly

func (f WebhookForm) PushOnly() bool

PushOnly if the hook will be triggered when push

func (WebhookForm) SendEverything

func (f WebhookForm) SendEverything() bool

SendEverything if the hook will be triggered any event

Directories

Path Synopsis
Package ldap provide functions & structure to query a LDAP ldap directory For now, it's mainly tested again an MS Active Directory service, see README.md for more information
Package ldap provide functions & structure to query a LDAP ldap directory For now, it's mainly tested again an MS Active Directory service, see README.md for more information

Jump to

Keyboard shortcuts

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