- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.2k
 
GPG Key Ownership verification with Signed Token #14054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            48 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      33ee748
              
                Add option to provide signed token to verify key ownership
              
              
                zeripath 527a22b
              
                Merge remote-tracking branch 'origin/master' into gpg-key-token-signed
              
              
                zeripath 68b6228
              
                Ensure verified keys can act for all active emails for the user
              
              
                zeripath 6c72b6a
              
                Add code to mark keys as verified
              
              
                zeripath 0ece493
              
                Slight UI adjustments
              
              
                zeripath 175c003
              
                Slight UI adjustments 2
              
              
                zeripath 66f6e7d
              
                Simplify signature verification slightly
              
              
                zeripath 3d145ec
              
                fix postgres test
              
              
                zeripath 3105706
              
                add api routes
              
              
                zeripath c4529b8
              
                prepare for merge
              
              
                zeripath 9818df0
              
                Merge branch 'master' into gpg-key-token-signed
              
              
                zeripath e3a2770
              
                as per @6543
              
              
                zeripath 43b967c
              
                Merge remote-tracking branch 'origin/master' into gpg-key-token-signed
              
              
                zeripath f006ef7
              
                Merge branch 'master' into gpg-key-token-signed
              
              
                zeripath 223c71e
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                zeripath 164daeb
              
                prepare for update
              
              
                zeripath 068fef3
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath c4d94ef
              
                pre-merge
              
              
                zeripath de80f0a
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath 47d9cad
              
                prepare merge
              
              
                zeripath 830f345
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath cee8a8c
              
                handle swapped primarykeys
              
              
                zeripath 34d2ac7
              
                prepare to merge
              
              
                zeripath a2b733b
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath eb69eff
              
                prepare merge
              
              
                zeripath f10251e
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath 7609edd
              
                pre-merge
              
              
                zeripath 5275103
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath bf7ef6c
              
                Merge remote-tracking branch 'origin/main' into gpg-key-token-signed
              
              
                zeripath 4e5c668
              
                Verify the no-reply address for verified keys
              
              
                zeripath 4aa4015
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                6543 18df555
              
                Only add email addresses that are activated to keys
              
              
                zeripath 020d5f7
              
                fix committer shortcut properly
              
              
                zeripath 6e2a15a
              
                Restructure gpg_keys.go
              
              
                zeripath 4af7d8c
              
                Use common Verification Token code
              
              
                zeripath 4caba0d
              
                Merge branch 'gpg-key-token-signed' of github.com:zeripath/gitea into…
              
              
                zeripath 3bb22c4
              
                fix tests
              
              
                zeripath 26e401b
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                6543 c728845
              
                Update models/gpg_key_verify.go
              
              
                6543 64801a0
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                6543 452eca3
              
                Merge branch 'master' into gpg-key-token-signed
              
              
                6543 6446bb7
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                6543 ce2a2d2
              
                Update models/gpg_key_add.go
              
              
                techknowlogick 408ba96
              
                Update models/gpg_key_commit_verification.go
              
              
                techknowlogick caf4b6e
              
                Merge commit 'bc6f060b8cd89685cc32980c4f03cba58850cab1' into merge-at…
              
              
                zeripath e7bc4c9
              
                Merge commit 'e0296b6a6de6450c474fdf7fe62635a05beb49ab' into merge-at…
              
              
                zeripath 4b4de16
              
                Merge remote-tracking branch 'origin/main' into merge-attempts
              
              
                zeripath 49690df
              
                Merge branch 'main' into gpg-key-token-signed
              
              
                6543 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -29,10 +29,10 @@ func TestGPGKeys(t *testing.T) { | |
| results []int | ||
| }{ | ||
| {name: "NoLogin", makeRequest: MakeRequest, token: "", | ||
| results: []int{http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized}, | ||
| results: []int{http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized}, | ||
| }, | ||
| {name: "LoggedAsUser2", makeRequest: session.MakeRequest, token: token, | ||
| results: []int{http.StatusOK, http.StatusOK, http.StatusNotFound, http.StatusNoContent, http.StatusUnprocessableEntity, http.StatusNotFound, http.StatusCreated, http.StatusCreated}}, | ||
| results: []int{http.StatusOK, http.StatusOK, http.StatusNotFound, http.StatusNoContent, http.StatusUnprocessableEntity, http.StatusNotFound, http.StatusCreated, http.StatusNotFound, http.StatusCreated}}, | ||
| } | ||
| 
     | 
||
| for _, tc := range tt { | ||
| 
          
            
          
           | 
    @@ -60,7 +60,7 @@ func TestGPGKeys(t *testing.T) { | |
| t.Run("CreateValidGPGKey", func(t *testing.T) { | ||
| testCreateValidGPGKey(t, tc.makeRequest, tc.token, tc.results[6]) | ||
| }) | ||
| t.Run("CreateValidSecondaryEmailGPGKey", func(t *testing.T) { | ||
| t.Run("CreateValidSecondaryEmailGPGKeyNotActivated", func(t *testing.T) { | ||
| testCreateValidSecondaryEmailGPGKey(t, tc.makeRequest, tc.token, tc.results[7]) | ||
| }) | ||
| }) | ||
| 
        
          
        
         | 
    @@ -74,6 +74,7 @@ func TestGPGKeys(t *testing.T) { | |
| req := NewRequest(t, "GET", "/api/v1/user/gpg_keys?token="+token) //GET all keys | ||
| resp := session.MakeRequest(t, req, http.StatusOK) | ||
| DecodeJSON(t, resp, &keys) | ||
| assert.Len(t, keys, 1) | ||
| 
     | 
||
| primaryKey1 := keys[0] //Primary key 1 | ||
| assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID) | ||
| 
        
          
        
         | 
    @@ -85,12 +86,6 @@ func TestGPGKeys(t *testing.T) { | |
| assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID) | ||
| assert.Empty(t, subKey.Emails) | ||
| 
     | 
||
| primaryKey2 := keys[1] //Primary key 2 | ||
| assert.EqualValues(t, "3CEF46EF40BEFC3E", primaryKey2.KeyID) | ||
| assert.Len(t, primaryKey2.Emails, 1) | ||
| assert.EqualValues(t, "[email protected]", primaryKey2.Emails[0].Email) | ||
| assert.False(t, primaryKey2.Emails[0].Verified) | ||
| 
     | 
||
| var key api.GPGKey | ||
| req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)+"?token="+token) //Primary key 1 | ||
| resp = session.MakeRequest(t, req, http.StatusOK) | ||
| 
        
          
        
         | 
    @@ -105,15 +100,6 @@ func TestGPGKeys(t *testing.T) { | |
| DecodeJSON(t, resp, &key) | ||
| assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID) | ||
| assert.Empty(t, key.Emails) | ||
| 
     | 
||
| req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey2.ID, 10)+"?token="+token) //Primary key 2 | ||
| resp = session.MakeRequest(t, req, http.StatusOK) | ||
| DecodeJSON(t, resp, &key) | ||
| assert.EqualValues(t, "3CEF46EF40BEFC3E", key.KeyID) | ||
| assert.Len(t, key.Emails, 1) | ||
| assert.EqualValues(t, "[email protected]", key.Emails[0].Email) | ||
| assert.False(t, key.Emails[0].Verified) | ||
| 
     | 
||
| }) | ||
| 
     | 
||
| //Check state after basic add | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.