Documentation
¶
Index ¶
- func AddPrincipalKey(ctx context.Context, ownerID int64, content string, authSourceID int64) (*asymkey_model.PublicKey, error)
- func AllHeadCommitsVerified(ctx context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository) (bool, error)
- func DeleteDeployKey(ctx context.Context, repo *repo_model.Repository, id int64) error
- func DeletePublicKey(ctx context.Context, doer *user_model.User, id int64) (err error)
- func DeleteRepoDeployKeys(ctx context.Context, repoID int64) (int, error)
- func HashAndVerifyForKeyID(ctx context.Context, sig *packet.Signature, payload string, ...) *asymkey_model.CommitVerification
- func IsErrWontSign(err error) bool
- func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *asymkey_model.CommitVerification
- func ParseCommitWithSignatureCommitter(ctx context.Context, c *git.Commit, committer *user_model.User) *asymkey_model.CommitVerification
- func PublicSigningKey(ctx context.Context) (content, format string, err error)
- func RewriteAllPrincipalKeys(ctx context.Context) error
- func RewriteAllPublicKeys(ctx context.Context) error
- func SignCRUDAction(ctx context.Context, u *user_model.User, gitRepo *git.Repository, ...) (bool, *git.SigningKey, *git.Signature, error)
- func SignInitialCommit(ctx context.Context, u *user_model.User) (bool, *git.SigningKey, *git.Signature, error)
- func SignMerge(ctx context.Context, pr *issues_model.PullRequest, u *user_model.User, ...) (bool, *git.SigningKey, *git.Signature, error)
- func SignWikiCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, ...) (bool, *git.SigningKey, *git.Signature, error)
- type ErrWontSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPrincipalKey ¶
func AddPrincipalKey(ctx context.Context, ownerID int64, content string, authSourceID int64) (*asymkey_model.PublicKey, error)
AddPrincipalKey adds new principal to database and authorized_principals file.
func AllHeadCommitsVerified ¶
func AllHeadCommitsVerified(ctx context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository) (bool, error)
AllHeadCommitsVerified checks that every new commit in the PR head has a verified signature.
func DeleteDeployKey ¶
func DeleteDeployKey(ctx context.Context, repo *repo_model.Repository, id int64) error
DeleteDeployKey deletes deploy key from its repository authorized_keys file if needed. Permissions check should be done outside.
func DeletePublicKey ¶
DeletePublicKey deletes SSH key information both in database and authorized_keys file.
func DeleteRepoDeployKeys ¶
DeleteRepoDeployKeys deletes all deploy keys of a repository. permissions check should be done outside
func HashAndVerifyForKeyID ¶
func HashAndVerifyForKeyID(ctx context.Context, sig *packet.Signature, payload string, committer *user_model.User, keyID, name, email string) *asymkey_model.CommitVerification
func IsErrWontSign ¶
IsErrWontSign checks if an error is a ErrWontSign
func ParseCommitWithSignature ¶
func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *asymkey_model.CommitVerification
ParseCommitWithSignature check if signature is good against keystore.
func ParseCommitWithSignatureCommitter ¶
func ParseCommitWithSignatureCommitter(ctx context.Context, c *git.Commit, committer *user_model.User) *asymkey_model.CommitVerification
ParseCommitWithSignatureCommitter parses a commit's GPG or SSH signature. The caller guarantees that the committer user is related to the commit by checking its activated email addresses or no-reply address. If the commit is singed by an instance key, then committer can be nil. If the signature exists, even if committer is nil, the returned CommittingUser will be a non-nil fake user (e.g.: instance key)
func PublicSigningKey ¶
PublicSigningKey gets the public signing key of the entire instance
func RewriteAllPrincipalKeys ¶
RewriteAllPrincipalKeys removes any authorized principal and rewrite all keys from database again. Note: db.GetEngine(ctx).Iterate does not get latest data after insert/delete, so we have to call this function outside any session scope independently.
func RewriteAllPublicKeys ¶
RewriteAllPublicKeys removes any authorized key and rewrite all keys from database again. Note: db.GetEngine(ctx).Iterate does not get latest data after insert/delete, so we have to call this function outside any session scope independently.
func SignCRUDAction ¶
func SignCRUDAction(ctx context.Context, u *user_model.User, gitRepo *git.Repository, parentCommit string) (bool, *git.SigningKey, *git.Signature, error)
SignCRUDAction determines if we should sign a CRUD commit to this repository
func SignInitialCommit ¶
func SignInitialCommit(ctx context.Context, u *user_model.User) (bool, *git.SigningKey, *git.Signature, error)
SignInitialCommit determines if we should sign the initial commit to this repository
func SignMerge ¶
func SignMerge(ctx context.Context, pr *issues_model.PullRequest, u *user_model.User, gitRepo *git.Repository, baseRef, headRef string) (bool, *git.SigningKey, *git.Signature, error)
SignMerge determines if we should sign a PR merge commit to the base repository. baseRef and headRef must resolve in gitRepo. Callers pass the temporary merge repo's own refs for an update by merge, whose fake reverse PR has no head ref in the base repository.
func SignWikiCommit ¶
func SignWikiCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, u *user_model.User) (bool, *git.SigningKey, *git.Signature, error)
SignWikiCommit determines if we should sign the commits to this repository wiki
Types ¶
type ErrWontSign ¶
type ErrWontSign struct {
Reason signingMode
}
ErrWontSign explains the first reason why a commit would not be signed There may be other reasons - this is just the first reason found
func (*ErrWontSign) Error ¶
func (e *ErrWontSign) Error() string