cmd/example-app: expose connector_id
As a piece of "living documentation" for #1481. Signed-off-by: Stephan Renatus <srenatus@chef.io>
This commit is contained in:
parent
20a858da3b
commit
c4e0587df1
2 changed files with 12 additions and 2 deletions
|
@ -237,6 +237,10 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) {
|
|||
for _, client := range clients {
|
||||
scopes = append(scopes, "audience:server:client_id:"+client)
|
||||
}
|
||||
connectorID := ""
|
||||
if id := r.FormValue("connector_id"); id != "" {
|
||||
connectorID = id
|
||||
}
|
||||
|
||||
authCodeURL := ""
|
||||
scopes = append(scopes, "openid", "profile", "email")
|
||||
|
@ -248,6 +252,9 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState, oauth2.AccessTypeOffline)
|
||||
}
|
||||
if connectorID != "" {
|
||||
authCodeURL = authCodeURL + "&connector_id=" + connectorID
|
||||
}
|
||||
|
||||
http.Redirect(w, r, authCodeURL, http.StatusSeeOther)
|
||||
}
|
||||
|
|
|
@ -15,8 +15,11 @@ var indexTmpl = template.Must(template.New("index.html").Parse(`<html>
|
|||
<p>
|
||||
Extra scopes:<input type="text" name="extra_scopes" placeholder="list of scopes">
|
||||
</p>
|
||||
<p>
|
||||
Request offline access:<input type="checkbox" name="offline_access" value="yes" checked>
|
||||
<p>
|
||||
Connector ID:<input type="text" name="connector_id" placeholder="connector id">
|
||||
</p>
|
||||
<p>
|
||||
Request offline access:<input type="checkbox" name="offline_access" value="yes" checked>
|
||||
</p>
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
|
|
Reference in a new issue