Skip to content

Commit

Permalink
Merge pull request #28 from vivshankar/v0.44.x
Browse files Browse the repository at this point in the history
Sync commits to v0.46.x
  • Loading branch information
vivshankar authored Jul 9, 2024
2 parents c2138c6 + 74cec9f commit 55da756
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion handler/rfc8628/device_authorize_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package rfc8628

import (
"context"
"net/url"
"time"

"github.com/ory/fosite"
Expand Down Expand Up @@ -57,8 +58,16 @@ func (d *DeviceAuthorizeHandler) HandleDeviceAuthorizeEndpointRequest(ctx contex
resp.SetDeviceCode(deviceCode)
resp.SetUserCode(userCode)
resp.SetVerificationURI(d.Config.GetRFC8628UserVerificationURL(ctx))
resp.SetVerificationURIComplete(d.Config.GetRFC8628UserVerificationURL(ctx) + "?user_code=" + userCode)
resp.SetVerificationURIComplete(d.formCompleteURI(d.Config.GetRFC8628UserVerificationURL(ctx), userCode))
resp.SetExpiresIn(int64(time.Until(expireAt).Seconds()))
resp.SetInterval(int(d.Config.GetDeviceAuthTokenPollingInterval(ctx).Seconds()))
return nil
}

func (d *DeviceAuthorizeHandler) formCompleteURI(verificationURI, userCode string) string {
u, _ := url.Parse(verificationURI)
qp := u.Query()
qp["user_code"] = []string{userCode}
u.RawQuery = qp.Encode()
return u.String()
}

0 comments on commit 55da756

Please sign in to comment.