Prototype device authorization flow (core)

This commit is contained in:
Joe Kralicky 2024-05-16 16:47:02 -04:00
parent 4eda7479ce
commit 6d947ebd26
No known key found for this signature in database
GPG key ID: 75C4875F34A9FB79
13 changed files with 331 additions and 24 deletions

View file

@ -339,6 +339,17 @@ func (s *Stateful) AuthenticateSignInURL(
return redirectTo, nil
}
func (s *Stateful) AuthenticateDeviceCode(w http.ResponseWriter, r *http.Request, params url.Values) error {
deviceAuthURL := s.authenticateURL.ResolveReference(&url.URL{
Path: "/.pomerium/device_auth",
RawQuery: params.Encode(),
})
signedURL := urlutil.NewSignedURL(s.sharedKey, deviceAuthURL)
httputil.Redirect(w, r, signedURL.String(), http.StatusFound)
return nil
}
// GetIdentityProviderIDForURLValues returns the identity provider ID
// associated with the given URL values.
func (s *Stateful) GetIdentityProviderIDForURLValues(vs url.Values) string {

View file

@ -365,6 +365,17 @@ func (s *Stateless) AuthenticateSignInURL(
)
}
func (s *Stateless) AuthenticateDeviceCode(w http.ResponseWriter, r *http.Request, params url.Values) error {
signinURL := s.authenticateURL.ResolveReference(&url.URL{
Path: "/.pomerium/device_auth",
RawQuery: params.Encode(),
})
signedURL := urlutil.NewSignedURL(s.sharedKey, signinURL)
httputil.Redirect(w, r, signedURL.String(), http.StatusFound)
return nil
}
// Callback handles a redirect to a route domain once signed in.
func (s *Stateless) Callback(w http.ResponseWriter, r *http.Request) error {
if err := r.ParseForm(); err != nil {