galaxy-dist commit 0736d9af9e6e: Allow access to API Key creation when use_remote_user is true.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Nate Coraor <nate@bx.psu.edu> # Date 1280416177 14400 # Node ID 0736d9af9e6e7facef8fad93baa3a303e0cf9526 # Parent d27912281a74ba74a8df6f5d72db7c553ca846c5 Allow access to API Key creation when use_remote_user is true. --- /dev/null +++ b/templates/webapps/galaxy/user/api_keys.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + +<div class="toolForm"> + <form name="user_api_keys" id="user_api_keys" action="${h.url_for( controller='user', action='api_keys' )}" method="post" > + <div class="toolFormTitle">Web API Key</div> + <div class="toolFormBody"> + <div class="form-row"> + <label>Current API key:</label> + %if user.api_keys: + ${user.api_keys[0].key} + %else: + none set + %endif + </div> + <div class="form-row"> + <input type="submit" name="new_api_key_button" value="Generate a new key now"/> + %if user.api_keys: + (invalidates old key) + %endif + <div class="toolParamHelp" style="clear: both;"> + An API key will allow you to access Galaxy via its web + API (documentation forthcoming). Please note that + <strong>this key acts as an alternate means to access + your account, and should be treated with the same care + as your login password</strong>. + </div> + </div> + </div> + </form> +</div> --- a/lib/galaxy/web/framework/middleware/remoteuser.py +++ b/lib/galaxy/web/framework/middleware/remoteuser.py @@ -95,6 +95,8 @@ class RemoteUser( object ): return self.error( start_response, title, message ) if path_info.startswith( '/user/create' ) and environ[ 'HTTP_REMOTE_USER' ] in self.admin_users: pass # admins can create users + elif path_info.startswith( '/user/api_keys' ): + pass elif path_info.startswith( '/user' ): title = "Access to Galaxy user controls is disabled" message = """ --- a/lib/galaxy/web/controllers/user.py +++ b/lib/galaxy/web/controllers/user.py @@ -1003,24 +1003,20 @@ class User( BaseController ): @web.expose - def new_api_key( self, trans, **kwd ): + def api_keys( self, trans, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - admin_view = util.string_as_bool( params.get( 'admin_view', False ) ) error = '' - user = trans.sa_session.query( trans.app.model.User ).get( int( params.get( 'user_id', None ) ) ) if params.get( 'new_api_key_button', None ) == 'Generate a new key now': new_key = trans.app.model.APIKeys() - new_key.user_id = user.id + new_key.user_id = trans.user.id new_key.key = trans.app.security.get_new_guid() trans.sa_session.add( new_key ) trans.sa_session.flush() message = "Generated a new web API key" status = "done" - return trans.response.send_redirect( web.url_for( controller='user', - action='show_info', - admin_view=admin_view, - user_id=user.id, - message=message, - status=status ) ) + return trans.fill_template( 'webapps/galaxy/user/api_keys.mako', + user=trans.user, + message=message, + status=status ) --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -130,6 +130,9 @@ %if app.config.get_bool( 'enable_pages', False ): <li><a href="${h.url_for( controller='/page', action='list' )}">Pages</a></li> %endif + %if app.config.enable_api: + <li><a target="galaxy_main" href="${h.url_for( controller='/user', action='api_keys' )}">API Keys</a></li> + %endif </ul></div></td> --- a/templates/webapps/galaxy/user/info.mako +++ b/templates/webapps/galaxy/user/info.mako @@ -120,36 +120,3 @@ </div></form></div> - -<p/> - -%if trans.app.config.enable_api: - <div class="toolForm"> - <form name="user_api_keys" id="user_api_keys" action="${h.url_for( controller='user', action='new_api_key', user_id=user.id, admin_view=admin_view )}" method="post" > - <div class="toolFormTitle">Web API Key</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Current API key:</label> - %if user.api_keys: - ${user.api_keys[0].key} - %else: - none set - %endif - </div> - <div class="form-row"> - <input type="submit" name="new_api_key_button" value="Generate a new key now"/> - %if user.api_keys: - (invalidates old key) - %endif - <div class="toolParamHelp" style="clear: both;"> - An API key will allow you to access Galaxy via its web - API (documentation forthcoming). Please note that - <strong>this key acts as an alternate means to access - your account, and should be treated with the same care - as your login password</strong>. - </div> - </div> - </div> - </form> - </div> -%endif --- a/templates/user/index.mako +++ b/templates/user/index.mako @@ -12,6 +12,9 @@ %if webapp == 'galaxy': <li><a href="${h.url_for( controller='user', action='show_info' )}">${_('Manage your information')}</a></li><li><a href="${h.url_for( controller='user', action='set_default_permissions' )}">${_('Change default permissions')}</a> for new histories</li> + %if trans.app.config.enable_api: + <li><a href="${h.url_for( controller='user', action='api_keys' )}">${_('Manage your API Keys')}</a> for new histories</li> + %endif %else: <li><a href="${h.url_for( controller='user', action='show_info', webapp='community' )}">${_('Manage your information')}</a></li> %endif
participants (1)
-
commits-noreply@bitbucket.org