Skip to content

Commit b1fb367

Browse files
karmirojer
authored andcommitted
[authn] Added the ability to display full docker login command (cesanta#221)
In order to make the `docker login` command more user-friendly, allow to set `registry_url` in the YAML configuration, and display it when the user has been succesfully authenticated. If the parameter is not set, display an example URL. (cherry picked from commit 3aeb847)
1 parent e10780b commit b1fb367

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

auth_server/authn/bindata.go

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auth_server/authn/data/github_auth_result.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
border-radius: 0.5em;
3333
text-shadow: 0px 1px 0px #fff;
3434
}
35+
.command span {
36+
user-select: none;
37+
-moz-user-select: none;
38+
-webkit-user-select: none;
39+
-ms-user-select: none;
40+
}
3541
</style>
3642
</head>
3743
<body>
@@ -40,6 +46,6 @@
4046
Use the following username and password to login into the registry:
4147
</p>
4248
<hr>
43-
<pre class="command">$ docker login -u {{.Username}} -p {{.Password}} YOUR_REGISTRY_FQDN</pre>
49+
<pre class="command"><span>$ </span>docker login -u {{.Username}} -p {{.Password}} {{if .RegistryUrl}}{{.RegistryUrl}}{{else}}docker.example.com{{end}}</pre>
4450
</body>
4551
</html>

auth_server/authn/github_auth.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type GitHubAuthConfig struct {
6464
RevalidateAfter time.Duration `yaml:"revalidate_after,omitempty"`
6565
GithubWebUri string `yaml:"github_web_uri,omitempty"`
6666
GithubApiUri string `yaml:"github_api_uri,omitempty"`
67+
RegistryUrl string `yaml:"registry_url,omitempty"`
6768
}
6869

6970
type GitHubGCSStoreConfig struct {
@@ -193,10 +194,11 @@ func (gha *GitHubAuth) doGitHubAuthPage(rw http.ResponseWriter, req *http.Reques
193194

194195
func (gha *GitHubAuth) doGitHubAuthResultPage(rw http.ResponseWriter, username string, password string) {
195196
if err := gha.tmplResult.Execute(rw, struct {
196-
Organization, Username, Password string
197+
Organization, Username, Password, RegistryUrl string
197198
}{Organization: gha.config.Organization,
198-
Username: username,
199-
Password: password}); err != nil {
199+
Username: username,
200+
Password: password,
201+
RegistryUrl: gha.config.RegistryUrl}); err != nil {
200202
http.Error(rw, fmt.Sprintf("Template error: %s", err), http.StatusInternalServerError)
201203
}
202204
}

examples/reference.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ github_auth:
117117
# The Github API URI in case you are using Github Enterprise.
118118
# Includes the protocol, without trailing slash. - defaults to: https://api.github.com
119119
github_api_uri: "https://github.acme.com/api/v3"
120+
# Set an URL to display in the `docker login` command when succesfully authenticated. Optional.
121+
registry_url: localhost:5000
120122

121123
# LDAP authentication.
122124
# Authentication is performed by first binding to the server, looking up the user entry

0 commit comments

Comments
 (0)