summaryrefslogtreecommitdiffstats
path: root/models/ssh_key.go
Commit message (Collapse)AuthorAgeFilesLines
* Better logging (#6038) (#6095)zeripath2019-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Panic don't fatal on create new logger Fixes #5854 Signed-off-by: Andrew Thornton <art27@cantab.net> * partial broken * Update the logging infrastrcture Signed-off-by: Andrew Thornton <art27@cantab.net> * Reset the skip levels for Fatal and Error Signed-off-by: Andrew Thornton <art27@cantab.net> * broken ncsa * More log.Error fixes Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove nal * set log-levels to lowercase * Make console_test test all levels * switch to lowercased levels * OK now working * Fix vetting issues * Fix lint * Fix tests * change default logging to match current gitea * Improve log testing Signed-off-by: Andrew Thornton <art27@cantab.net> * reset error skip levels to 0 * Update documentation and access logger configuration * Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE * Fix broken level caching * Refactor the router log * Add Router logger * Add colorizing options * Adjust router colors * Only create logger if they will be used * update app.ini.sample * rename Attribute ColorAttribute * Change from white to green for function * Set fatal/error levels * Restore initial trace logger * Fix Trace arguments in modules/auth/auth.go * Properly handle XORMLogger * Improve admin/config page * fix fmt * Add auto-compression of old logs * Update error log levels * Remove the unnecessary skip argument from Error, Fatal and Critical * Add stacktrace support * Fix tests * Remove x/sync from vendors? * Add stderr option to console logger * Use filepath.ToSlash to protect against Windows in tests * Remove prefixed underscores from names in colors.go * Remove not implemented database logger This was removed from Gogs on 4 Mar 2016 but left in the configuration since then. * Ensure that log paths are relative to ROOT_PATH * use path.Join * rename jsonConfig to logConfig * Rename "config" to "jsonConfig" to make it clearer * Requested changes * Requested changes: XormLogger * Try to color the windows terminal If successful default to colorizing the console logs * fixup * Colorize initially too * update vendor * Colorize logs on default and remove if this is not a colorizing logger * Fix documentation * fix test * Use go-isatty to detect if on windows we are on msys or cygwin * Fix spelling mistake * Add missing vendors * More changes * Rationalise the ANSI writer protection * Adjust colors on advice from @0x5c * Make Flags a comma separated list * Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING * Ensure matching is done on the non-colored message - to simpify EXPRESSION
* Fix ssh deploy and user key constraints (#1357) (#5939)zeripath2019-02-031-35/+56
| | | | | | | | | | | | | | | | 1. A key can either be an ssh user key or a deploy key. It cannot be both. 2. If a key is a user key - it can only be associated with one user. 3. If a key is a deploy key - it can be used in multiple repositories and the permissions it has on those repositories can be different. 4. If a repository is deleted, its deploy keys must be deleted too. We currently don't enforce any of this and multiple repositories access with different permissions doesn't work at all. This PR enforces the following constraints: - [x] You should not be able to add the same user key as another user - [x] You should not be able to add a ssh user key which is being used as a deploy key - [x] You should not be able to add a ssh deploy key which is being used as a user key - [x] If you add an ssh deploy key to another repository you should be able to use it in different modes without losing the ability to use it in the other mode. - [x] If you delete a repository you must delete all its deploy keys. Fix #1357
* fix public will not be reused as public key after deleting as deploy key (#5671)Lunny Xiao2019-01-091-0/+5
|
* Synchronize SSH keys on login with LDAP + Fix SQLite deadlock on ldap ssh ↵zeripath2018-12-271-4/+8
| | | | | | | | key deletion (#5557) * Synchronize SSH keys on login with LDAP * BUG: Fix hang on sqlite during LDAP key deletion
* fix forgot removed records when deleting user (#5429)Lunny Xiao2018-12-181-1/+6
| | | | | | | | | | * fix forgot removed records when deleting user * fix migration * fix rewritekey lock on sqlite * remove unused codes
* Restrict permission check on repositories and fix some problems (#5314)Lunny Xiao2018-11-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix units permission problems * fix some bugs and merge LoadUnits to repoAssignment * refactor permission struct and add some copyright heads * remove unused codes * fix routes units check * improve permission check * add unit tests for permission * fix typo * fix tests * fix some routes * fix api permission check * improve permission check * fix some permission check * fix tests * fix tests * improve some permission check * fix some permission check * refactor AccessLevel * fix bug * fix tests * fix tests * fix tests * fix AccessLevel * rename CanAccess * fix tests * fix comment * fix bug * add missing unit for test repos * fix bug * rename some functions * fix routes check
* Create AuthorizedKeysCommand (#5236)zeripath2018-11-011-1/+1
|
* Keys API changes (#4960)zeripath2018-10-311-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add private information to the deploy keys api This commit adds more information to the deploy keys to allow for back reference in to the main keys list. It also adds information about the repository that the key is referring to. Signed-off-by: Andrew Thornton <art27@cantab.net> * Add private information to the user keys API This adjusts the keys API to give out private information to user keys if the current user is the owner or an admin. Signed-off-by: Andrew Thornton <art27@cantab.net> * Add ability to search keys by fingerprint This commit adds the functionality to search ssh-keys by fingerprint of the ssh-key. Deploy keys per repository can also be searched. There is no current clear API point to allow search of all deploy keys by fingerprint or keyID. Signed-off-by: Andrew Thornton <art27@cantab.net> * Add integration test
* Remove check for negative length (#5120)Oleg Kovalov2018-10-201-1/+1
|
* make sure to catch the right error so it is displayed as an error on the ui ↵Lanre Adelowo2018-09-161-1/+1
| | | | not a 500 (#4945)
* feat(repo): support search repository by topic name (#4505)Bo-Yi Wu2018-09-131-4/+4
| | | | * feat(repo): support search repository by topic name
* LDAP Public SSH Keys synchronization (#1844)Magnus Lindvall2018-05-241-14/+24
| | | | | | | | | | | | | | | | | | | * Add LDAP Key Synchronization feature Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Add migration: add login source id column for public_key table * Only update keys if needed * Add function to only list pubkey synchronized from ldap * Only list pub ssh keys synchronized from ldap. Do not sort strings as ExistsInSlice does it. * Only get keys belonging to current login source id * Set default login source id to 0 * Some minor cleanup. Add integration tests (updete dep testify)
* Remove useless check (#3384)Antoine GIRARD2018-01-191-4/+0
| | | In #3377, I put check inside all write key function. This one is useless no.
* Add integrations tests from git cli (#3377)Antoine GIRARD2018-01-161-0/+10
| | | | | | | | | | | * test: integration add git cli tests Extracted form for easing review process and debug #3152 * test: integration add git cli big file commit * fix: Don't rewrite key if internal server
* Writable deploy keys (closes #671) (#3225)Vlad Temian2018-01-071-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add is_writable checkbox to deploy keys interface * Add writable key option to deploy key form * Add support for writable ssh keys in the interface * Rename IsWritable to ReadOnly * Test: create read-only and read-write deploy keys via api * Add DeployKey access mode migration * Update gitea sdk via govendor * Fix deploykey migration * Add unittests for writable deploy keys * Move template text to locale * Remove implicit column update * Remove duplicate locales * Replace ReadOnly field with IsReadOnly method * Fix deploy_keys related integration test * Rename v54 migration with v55 * Fix migration hell
* Improvements for supporting UI Location (#3146)Lunny Xiao2017-12-141-10/+12
| | | | | | * improvements for supporting UI Location * improved the comment
* Refactor struct's time to remove unnecessary memory usage (#3142)Lunny Xiao2017-12-111-11/+8
| | | | | | | | | | | | | | * refactor struct's time to remove unnecessary memory usage * use AsTimePtr simple code * fix tests * fix time compare * fix template on gpg * use AddDuration instead of Add
* Delete a user's public key via admin api (closes #3014) (#3059)Vlad Temian2017-12-061-4/+1
| | | | | | | | | | | | | | | | * Delete a user's public key via admin api * Test admin ssh endpoint for creating a new ssh key * Adapt public ssh key test to also test the delete operation * Test that deleting a missing key will result in a 404 * Test that a normal user can't delete another user's ssh key * Make DeletePublicKey return err * Update swagger doc
* Disable add key button if SSH is disabled (#2873)Michael Kuhn2017-11-211-1/+1
|
* don't check minimum key size when disabled (#1754)Gibheer2017-10-261-5/+5
| | | | | | | | | | | | | | * cleanup old comments for ed25519 These comments were added when x/crypto/ed25519 could not yet handle ed25519. It does now, so it should be removed. Also the key type is now replaced with the proper constant. * move the minimum key size config before the check This moves the actual config lookup before any check is done. This avoids problems with calling to ssh-keygen which doesn't support the expected output format and returning an error, when the check is disabled.
* Replace deprecated Id method with ID (#2655)Ethan Koenig2017-10-051-3/+3
|
* Use AfterLoad instead of AfterSet on Structs (#2628)Lunny Xiao2017-10-011-22/+14
| | | | | | | | * use AfterLoad instead of AfterSet on Structs * fix the comments on AfterLoad * fix the comments on action AfterLoad
* Reduce usage of allcols on update (#2596)Lunny Xiao2017-09-251-9/+1
| | | | | | * reduce usage of allcols on update * fix bug and tests
* Fix lint errors (#2547)Ethan Koenig2017-09-191-5/+1
|
* Use created & updated instead BeforeInsert & BeforeUpdate (#2482)Lunny Xiao2017-09-131-28/+8
| | | | | | | | | | | | * use created & updated instead BeforeInsert & BeforeUpdate * fix vendor checksum * only show generated SQL when development mode * remove extra update column updated_unix * remove trace config
* Fix key usage time update if the key is used in parallel for multiple ↵Lauris BH2017-07-201-4/+9
| | | | operations (#2185)
* Setting to disable authorized_keys backup (#1856)Dan Magnus Lindvall2017-06-281-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add setting to disable authorized_keys backup when rewriting public keys Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Update default value to comply with documentation Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Use tmp-file instead of bak-file for saving manually added keys. Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Change casing Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Change casing and build bakpath with sprintf only Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Only close file once Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Do not modify calcFingerprint Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Fix casing Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Change style from disable to enable Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Change name, just SSH_BACKUP_AUTHORIZED_KEYS Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Do not check for directory existence if backup is disabled Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
* Refactor session close as xorm already does everything needed internally (#2020)Lauris BH2017-06-211-4/+4
|
* Delete Public SSH Key tmp file after calculating fingerprint (#1855)Dan Magnus Lindvall2017-06-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | * Delete public key tmp file after calculating fingerprint Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Move line Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Remove defer statement Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Readd defer statement and move remove Signed-off-by: Magnus Lindvall <magnus@dnmgns.com> * Delete space Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
* use writeTmpKeyFile in calcFingerprint (#1828)Timo Myyrä2017-05-291-10/+2
| | | this makes calcFingerprint use SSH.KeyTestpath instead of os temp dir.
* Add internal routes for ssh hook comands (#1471)Lunny Xiao2017-04-191-2/+4
| | | | | | | | | | | | | | | | * add internal routes for ssh hook comands * fix lint * add comment on why package named private not internal but the route name is internal * add comment above package private why package named private not internal but the route name is internal * remove exp time on internal access * move routes from /internal to /api/internal * add comment and defer on UpdatePublicKeyUpdated
* refactor update ssh key use time (#1466)Lunny Xiao2017-04-071-0/+14
|
* Refactor and fix incorrect comment (#1247)Ethan Koenig2017-03-151-1/+1
|
* Don't rewrite non-gitea public keys (#906)Lunny Xiao2017-03-031-4/+30
| | | | | | * don't rewrite non-gitea public keys * add comment for public key
* Use fingerprint to check instead content for public key (#911)Lunny Xiao2017-02-141-23/+42
| | | | | | * use fingerprint to check instead content for public key * add fingerprint field for ErrKeyAlreadyExist
* Cleanup log messagingGabriel Jackson2017-02-021-1/+1
| | | | | | | | | This change corrects a few logging issues: * Standardized formatting errors with '%v'. * Standardized failure warning word usage. * Corrected an instance of using the standard log library when the gitea log library should be used instead.
* refactor: Remove unnecessary type conversions (#772)Bo-Yi Wu2017-01-271-1/+1
|
* Refactor process package and introduce ProcessManager{} with tests (#75)Matthias Loibl2017-01-171-2/+2
| | | | | | | | | | * Add a process.Manager singleton with process.GetManager() * Use process.GetManager everywhere * Fix godoc comments for process module * Increment process counter id after locking the mutex
* Fix typos in models/ (#576)Ethan Koenig2017-01-051-2/+2
|
* Replace Gogs with Gitea (#520)Bwko2016-12-281-1/+1
|
* Catch os... errorsBwko2016-12-021-1/+6
|
* Lint models/ssh_key.goBwko2016-11-261-23/+32
|
* Handle ssh key import better (#224)stroucki2016-11-241-0/+2
| | | | | | | | | | | * Handle user ssh key input better ssh_key: when user submitted keys had a newline at the end, strings.Split would have created a slice with an empty last element, and the key type check would be incorrect. Perhaps a better way is to look for 'ssh-rsa' or 'ssh-dsa' at the beginning of the string, but this is simple. * ssh_key: correct indentation
* use in instead string join (#155)Lunny Xiao2016-11-121-2/+1
|
* Merge remote-tracking branch 'upstream/master' into feature/rewrite-xorm-queriesThibault Meyer2016-11-101-4/+4
|\ | | | | | | | | | | | | | | | | # Conflicts: # models/git_diff.go # models/issue.go # models/org.go # models/pull.go # models/repo.go
| * Update import paths from github.com/go-gitea to code.gitea.io (#135)Sandro Santilli2016-11-101-4/+4
| | | | | | | | | | | | | | - Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
* | Rewrite XORM queriesThibault Meyer2016-11-101-9/+27
|/
* And othersSandro Santilli2016-11-071-7/+7
|
* ACCESS_MODE_* -> AccessMode*Sandro Santilli2016-11-071-3/+3
|
* Change import reference to match gitea instead of gogs (#37)Rémy Boulanouar2016-11-031-4/+4
|