亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

ディレクトリ 検索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
テキスト

憑證 API 提供了一種從用戶那里收集用戶名和密碼憑證的抽象方式(即使更廣泛的世界中的憑證可以采用多種形式,本文檔中的“憑證”一詞總是指用戶名和密碼對(duì))。

本文檔描述了兩個(gè)接口:憑證子系統(tǒng)提供給 Git 其余部分的 C API ,以及 Git 用來(lái)與系統(tǒng)特定的“憑證助手”通信的協(xié)議。如果您正在編寫想要查看或提示輸入憑據(jù)的 Git 代碼,請(qǐng)參閱下面的 “C API” 部分。如果您想編寫自己的幫手,請(qǐng)參閱下面的“憑證助手”部分。

典型設(shè)置

+-----------------------+| Git code (C)          |--- to server requiring --->|                       |        authentication|.......................|| C credential API      |--- prompt ---> User+-----------------------+        ^      |        | pipe |        |      v+-----------------------+| Git credential helper |+-----------------------+

Git 代碼(通常是遠(yuǎn)程幫助程序)將調(diào)用 C API 來(lái)獲取憑證數(shù)據(jù),如登錄名/密碼對(duì)( credential_fill )。API 本身會(huì)調(diào)用一個(gè)遠(yuǎn)程助手(例如 “git credential-cache” 或 “git credential-store” ),它可以從商店中檢索憑證數(shù)據(jù)。如果憑證幫助程序找不到信息,C API 將提示用戶。然后,API 的調(diào)用者負(fù)責(zé)聯(lián)系服務(wù)器,并進(jìn)行實(shí)際的身份驗(yàn)證。

C api

憑證 C API 旨在由需要獲取或存儲(chǔ)憑證的 Git 代碼調(diào)用。它以代表單個(gè)憑證的對(duì)象為中心,并提供三種基本操作:填充(通過(guò)調(diào)用助手和/或提示用戶獲取憑證),批準(zhǔn)(將憑證標(biāo)記為已成功使用,以便將其存儲(chǔ)以供以后使用),并拒絕(將憑證標(biāo)記為不成功,以便可以從任何持久性存儲(chǔ)中將其刪除)。

Data Structures

struct credential

該結(jié)構(gòu)表示一個(gè)用戶名/密碼組合以及任何關(guān)聯(lián)的上下文。所有字符串字段應(yīng)該是堆分配的(如果它們不知道或不適用,則為 NULL )。各個(gè)上下文字段的含義與幫助程序協(xié)議中的對(duì)應(yīng)字段相同; 請(qǐng)參閱下面的部分,了解每個(gè)字段的說(shuō)明。

helpers結(jié)構(gòu)的成員是一個(gè)string_list助手。每個(gè)字符串都指定一個(gè)外部幫助程序,它將按順序運(yùn)行以獲取或存儲(chǔ)憑證。請(qǐng)參閱下面的憑證助手部分。在查詢幫助器之前,該列表由API函數(shù)根據(jù)相應(yīng)的配置變量填充,因此通常根本不需要調(diào)用者修改幫助器字段。

這個(gè)結(jié)構(gòu)應(yīng)該始終用CREDENTIAL_INITcredential_init來(lái)初始化。

功能

credential_init

初始化憑證結(jié)構(gòu),將所有字段設(shè)置為空。

credential_clear

釋放與憑證結(jié)構(gòu)關(guān)聯(lián)的任何資源,并將其返回到原始初始化狀態(tài)。

credential_fill

指示憑證子系統(tǒng)通過(guò)首先咨詢助手填充傳遞的憑證結(jié)構(gòu)的用戶名和密碼字段,然后詢問(wèn)用戶。此函數(shù)返回后,憑證的用戶名和密碼字段將保證為非 NULL。如果發(fā)生錯(cuò)誤,該函數(shù)將死()。

credential_reject

通知憑證子系統(tǒng)所提供的憑證已被拒絕。這將導(dǎo)致憑證子系統(tǒng)通知拒絕的任何助手(例如,允許他們清除存儲(chǔ)中的無(wú)效憑證)。它還將釋放()用戶名和密碼字段的憑證并將它們?cè)O(shè)置為 NULL(準(zhǔn)備另一次呼叫的憑證credential_fill)。來(lái)自助手的任何錯(cuò)誤都會(huì)被忽略。

credential_approve

通知憑證子系統(tǒng)所提供的憑證已成功用于身份驗(yàn)證。這將導(dǎo)致憑證子系統(tǒng)通知任何助手的批準(zhǔn),以便他們可以存儲(chǔ)結(jié)果再次使用。來(lái)自助手的任何錯(cuò)誤都會(huì)被忽略。

credential_from_url

將 URL 解析為已破解的憑證字段。

下面的示例顯示了憑證 API 的功能如何用于登錄到遠(yuǎn)程主機(jī)上虛構(gòu)的 “foo” 服務(wù):

int foo_login(struct foo_connection *f){
        int status;        /*
         * Create a credential with some context; we don't yet know the
         * username or password.
         */

        struct credential c = CREDENTIAL_INIT;
        c.protocol = xstrdup("foo");
        c.host = xstrdup(f->hostname);        /*
         * Fill in the username and password fields by contacting
         * helpers and/or asking the user. The function will die if it
         * fails.
         */        credential_fill(&c);        /*
         * Otherwise, we have a username and password. Try to use it.
         */
        status = send_foo_login(f, c.username, c.password);        switch (status) {        case FOO_OK:                /* It worked. Store the credential for later use. */                credential_accept(&c);                break;        case FOO_BAD_LOGIN:                /* Erase the credential from storage so we don't try it
                 * again. */                credential_reject(&c);                break;        default:                /*
                 * Some other error occurred. We don't know if the
                 * credential is good or bad, so report nothing to the
                 * credential subsystem.
                 */        }        /* Free any associated resources. */        credential_clear(&c);        return status;}

憑證助手

憑證助手是由 Git 執(zhí)行的程序,用于從長(zhǎng)期存儲(chǔ)中獲取或保存憑據(jù)(其中“長(zhǎng)期”比單個(gè) Git 流程更長(zhǎng);例如,憑證可以存儲(chǔ)在內(nèi)存中幾分鐘,或者無(wú)限期地在磁盤上)。

每個(gè)助手都由配置變量中的單個(gè)字符串credential.helper(以及其他字符串,請(qǐng)參閱 git-config [1] )指定。該字符串通過(guò) Git 轉(zhuǎn)換為使用這些規(guī)則執(zhí)行的命令:

1. 如果輔助字符串以“!”開頭,則它被認(rèn)為是一個(gè) shell 代碼片段,并且“!”之后的所有內(nèi)容都成為命令。

2. 否則,如果輔助字符串以絕對(duì)路徑開始,則逐字幫助字符串變成命令。

3. 否則,字符串“git credential-”被預(yù)先添加到助手字符串中,結(jié)果變成命令。

然后生成的命令會(huì)附加一個(gè)“操作”參數(shù)(詳情參見下文),結(jié)果由 shell 執(zhí)行。

以下是一些示例說(shuō)明:

# run "git credential-foo"foo

# same as above, but pass an argument to the helper
foo --bar=baz

# the arguments are parsed by the shell, so use shell
# quoting if necessary
foo --bar="whitespace arg"# you can also use an absolute path, which will not use the git wrapper/path/to/my/helper --with-arguments

# or you can specify your own shell snippet!f() { echo "password=`cat $HOME/.secret`"; }; f

一般來(lái)說(shuō),上面的規(guī)則(3)對(duì)用戶來(lái)說(shuō)是最簡(jiǎn)單的。憑證助手的作者應(yīng)該努力通過(guò)命名他們的程序 “git-credential- $ NAME” 來(lái)幫助他們的用戶,并且在安裝時(shí)將其放在 $ PATH 或 $ GIT_EXEC_PATH 中,這將允許用戶使用它和git config credential.helper $NAME。

當(dāng)執(zhí)行幫助程序時(shí),它的命令行中會(huì)附加一個(gè)“操作”參數(shù),該參數(shù)是以下之一:

get

返回匹配的憑證(如果存在)。

store

存儲(chǔ)憑證(如果適用于助手)。

erase

從助手的存儲(chǔ)中刪除匹配的憑據(jù)(如果有)。

憑證的詳細(xì)信息將在助手的 stdin 流中提供。確切的格式與git credential管道命令的輸入/輸出格式相同(INPUT/OUTPUT FORMAT有關(guān)詳細(xì)規(guī)范,請(qǐng)參閱 git-credential [1] 中的部分)。

對(duì)于get操作,幫助者應(yīng)該以相同的格式在 stdout 上產(chǎn)生一個(gè)屬性列表。輔助者可以自由地產(chǎn)生一個(gè)子集,或者如果它沒有任何用處可以提供的話,甚至根本沒有值。任何提供的屬性都會(huì)覆蓋 Git 已知的那些屬性。如果助手輸出quit值為true或?qū)傩?code>1,則不會(huì)再咨詢幫助者,也不會(huì)提示用戶(如果沒有提供憑證,則操作將失?。?。

對(duì)于 storeerase操作,幫助器的輸出將被忽略。如果它未能執(zhí)行請(qǐng)求的操作,它可能會(huì)向 stderr 投訴以通知用戶。如果它不支持請(qǐng)求的操作(例如只讀存儲(chǔ)),它應(yīng)該默默地忽略該請(qǐng)求。

如果助手收到任何其他操作,它應(yīng)該默默地忽略該請(qǐng)求。這為未來(lái)的操作留下了余地(較舊的幫助者將忽略新的請(qǐng)求)。

前の記事: 次の記事: