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
@ -237,6 +237,10 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) {
|
|||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
scopes = append(scopes, "audience:server:client_id:"+client)
|
scopes = append(scopes, "audience:server:client_id:"+client)
|
||||||
}
|
}
|
||||||
|
connectorID := ""
|
||||||
|
if id := r.FormValue("connector_id"); id != "" {
|
||||||
|
connectorID = id
|
||||||
|
}
|
||||||
|
|
||||||
authCodeURL := ""
|
authCodeURL := ""
|
||||||
scopes = append(scopes, "openid", "profile", "email")
|
scopes = append(scopes, "openid", "profile", "email")
|
||||||
@ -248,6 +252,9 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState, oauth2.AccessTypeOffline)
|
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState, oauth2.AccessTypeOffline)
|
||||||
}
|
}
|
||||||
|
if connectorID != "" {
|
||||||
|
authCodeURL = authCodeURL + "&connector_id=" + connectorID
|
||||||
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, authCodeURL, http.StatusSeeOther)
|
http.Redirect(w, r, authCodeURL, http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,11 @@ var indexTmpl = template.Must(template.New("index.html").Parse(`<html>
|
|||||||
<p>
|
<p>
|
||||||
Extra scopes:<input type="text" name="extra_scopes" placeholder="list of scopes">
|
Extra scopes:<input type="text" name="extra_scopes" placeholder="list of scopes">
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Request offline access:<input type="checkbox" name="offline_access" value="yes" checked>
|
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>
|
</p>
|
||||||
<input type="submit" value="Login">
|
<input type="submit" value="Login">
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user