mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-16 00:06:31 +02:00
Prototype device authorization flow (core)
This commit is contained in:
parent
4eda7479ce
commit
6d947ebd26
13 changed files with 331 additions and 24 deletions
|
@ -39,6 +39,10 @@ func (p *Proxy) registerDashboardHandlers(r *mux.Router) *mux.Router {
|
|||
Queries(urlutil.QueryRedirectURI, "").
|
||||
Methods(http.MethodGet)
|
||||
|
||||
a.Path("/v1/device_auth").Handler(httputil.HandlerFunc(p.DeviceAuthLogin)).
|
||||
Queries(urlutil.QueryDeviceAuthRouteURI, "").
|
||||
Methods(http.MethodGet, http.MethodPost)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -136,6 +140,30 @@ func (p *Proxy) ProgrammaticLogin(w http.ResponseWriter, r *http.Request) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *Proxy) DeviceAuthLogin(w http.ResponseWriter, r *http.Request) error {
|
||||
state := p.state.Load()
|
||||
options := p.currentOptions.Load()
|
||||
|
||||
params := url.Values{}
|
||||
routeUri, err := urlutil.ParseAndValidateURL(r.FormValue(urlutil.QueryDeviceAuthRouteURI))
|
||||
if err != nil {
|
||||
return httputil.NewError(http.StatusBadRequest, err)
|
||||
}
|
||||
params.Set(urlutil.QueryDeviceAuthRouteURI, routeUri.String())
|
||||
|
||||
idp, err := options.GetIdentityProviderForRequestURL(routeUri.String())
|
||||
if err != nil {
|
||||
return httputil.NewError(http.StatusInternalServerError, err)
|
||||
}
|
||||
params.Set(urlutil.QueryIdentityProviderID, idp.Id)
|
||||
|
||||
if retryToken := r.FormValue(urlutil.QueryDeviceAuthRetryToken); retryToken != "" {
|
||||
params.Set(urlutil.QueryDeviceAuthRetryToken, retryToken)
|
||||
}
|
||||
|
||||
return state.authenticateFlow.AuthenticateDeviceCode(w, r, params)
|
||||
}
|
||||
|
||||
// jwtAssertion returns the current request's JWT assertion (rfc7519#section-10.3.1).
|
||||
func (p *Proxy) jwtAssertion(w http.ResponseWriter, r *http.Request) error {
|
||||
rawAssertionJWT := r.Header.Get(httputil.HeaderPomeriumJWTAssertion)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue