#2977 add a 'clear key' or ability to 0 out ssh key in fas
Closed: Fixed None Opened 12 years ago by kevin.

It would be good if contributors had a way to remove an existing ssh public key associated with their account. Some possible reasons:

  • They don't do anything in fedora that needs ssh acess.

  • They want to revoke a key, but haven't yet made a new one.

  • They are traveling or are going to be away and want to make sure no one uses their account.

Just a 'clear' key would be great.


Marking EasyFix. Talke to me (abadger1999) on irc.freenode.net if you need help getting started on this.

I add lines at line 106 of edit.html


<label for="ssh_key">${_('Clear SSH Key')}:</label>
<input type="checkbox" name="ssh_key" id="ssh_key" value=" "/>

When submitting the form, it kept saying "Internal Server Error". I am not sure if I changed other things accidentally or my code is not right.

Next step will be how to bypass ValidSSHKey after we clear ssh key.

I am also thinking about maybe it will be clearer if adding "clear key" on "view" page, like changing password action.

You may be right -- go ahead and add the clear key button to the view page instead. Doing it that way, we can implement a new method to clear the key and then send the user back to the view page with a turbogears.flash() message that says the key has been cleared.

The reason you're getting an internal server error is that the server is probably that the server is getting unexpected values. since it is expecting a file upload, it's probably not able to interpret the checkbox value correctly (the ssh key file upload is also called ssh_key).

Toshio,

I suspect I messed up edit template a bit, because it still gave me a error even when I commented out the lines I added. Is there any way I can look up TG log or revert changes I made through version control?

Thanks,

Jun

Yep. To revert the working tree to what is in revision control you'd do "git reset --hard"

You might want to see what files you changed and back them up first (for instance, reset --hard will also revert changes to configuration files if they're checked into revision control). So run "git status" and backup the files that git says have been modified before running git reset --hard

Function available_languages() causes "TypeError: iterable argument required" in the form submission of Edit page. My method to bypass it is to define languages in fas.cfg, such as
available_languages = ['en', 'de', 'es', 'hu', 'it', 'pl', 'zh_CN']

For this ticket, added clearkey method in user.py:

@identity.require(identity.not_anonymous())
@expose()
def clearkey(self):
    username = identity.current.user_name
    person  = People.by_username(username)
    person.ssh_key = ''
    turbogears.flash(_('Your key have been removed.'))
    turbogears.redirect('/user/view/%s' % username)
    return dict()

Accordingly, adding clear key entry in view.html(line 64-66):

${person.ssh_key[:20]}.... 
(clear)

By simple testing it seems to work fine.

Reopen this ticket if there is any problem arise.

Login to comment on this ticket.

Metadata