mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-04 12:46:45 +00:00
feat: process nonce within device authorization flow (#1185)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -139,6 +139,7 @@ type OidcDeviceAuthorizationRequestDto struct {
|
|||||||
ClientSecret string `form:"client_secret"`
|
ClientSecret string `form:"client_secret"`
|
||||||
ClientAssertion string `form:"client_assertion"`
|
ClientAssertion string `form:"client_assertion"`
|
||||||
ClientAssertionType string `form:"client_assertion_type"`
|
ClientAssertionType string `form:"client_assertion_type"`
|
||||||
|
Nonce string `form:"nonce"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OidcDeviceAuthorizationResponseDto struct {
|
type OidcDeviceAuthorizationResponseDto struct {
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ type OidcDeviceCode struct {
|
|||||||
DeviceCode string
|
DeviceCode string
|
||||||
UserCode string
|
UserCode string
|
||||||
Scope string
|
Scope string
|
||||||
|
Nonce string
|
||||||
ExpiresAt datatype.DateTime
|
ExpiresAt datatype.DateTime
|
||||||
IsAuthorized bool
|
IsAuthorized bool
|
||||||
|
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ func (s *OidcService) createTokenFromDeviceCode(ctx context.Context, input dto.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly use the input clientID for the audience claim to ensure consistency
|
// Explicitly use the input clientID for the audience claim to ensure consistency
|
||||||
idToken, err := s.jwtService.GenerateIDToken(userClaims, input.ClientID, "")
|
idToken, err := s.jwtService.GenerateIDToken(userClaims, input.ClientID, deviceAuth.Nonce)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return CreatedTokens{}, err
|
return CreatedTokens{}, err
|
||||||
}
|
}
|
||||||
@@ -1282,6 +1282,7 @@ func (s *OidcService) CreateDeviceAuthorization(ctx context.Context, input dto.O
|
|||||||
ExpiresAt: datatype.DateTime(time.Now().Add(DeviceCodeDuration)),
|
ExpiresAt: datatype.DateTime(time.Now().Add(DeviceCodeDuration)),
|
||||||
IsAuthorized: false,
|
IsAuthorized: false,
|
||||||
ClientID: client.ID,
|
ClientID: client.ID,
|
||||||
|
Nonce: input.Nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.db.Create(deviceAuth).Error; err != nil {
|
if err := s.db.Create(deviceAuth).Error; err != nil {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE oidc_device_codes DROP COLUMN nonce;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE oidc_device_codes ADD COLUMN nonce VARCHAR(255);
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
BEGIN;
|
||||||
|
ALTER TABLE oidc_device_codes DROP COLUMN nonce;
|
||||||
|
COMMIT;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
BEGIN;
|
||||||
|
ALTER TABLE oidc_device_codes ADD COLUMN nonce TEXT;
|
||||||
|
COMMIT;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
Reference in New Issue
Block a user