예제 #1
0
def get_session(
        session_manager: GalaxySessionManager = Depends(get_session_manager),
        security: IdEncodingHelper = depends(IdEncodingHelper),
        galaxysession: Optional[str] = Cookie(None)
) -> Optional[model.GalaxySession]:
    if galaxysession:
        session_key = security.decode_guid(galaxysession)
        if session_key:
            return session_manager.get_session_from_session_key(session_key)
        # TODO: What should we do if there is no session? Since this is the API, maybe nothing is the right choice?
    return None
예제 #2
0
parser.add_argument('value',
                    metavar='VALUE',
                    type=str,
                    default=None,
                    help='value to encode or decode')
populate_config_args(parser)
args = parser.parse_args()

app_properties = app_properties_from_args(args)

# We need the ID secret for configuring the security helper to decrypt
# galaxysession cookies.
if "id_secret" not in app_properties:
    log.warning(
        'No ID_SECRET specified. Please set the "id_secret" in your galaxy.yml.'
    )

id_secret = app_properties.get('id_secret', 'dangerous_default')

security_helper = IdEncodingHelper(id_secret=id_secret)
# And get access to the models
# Login manager to manage current_user functionality

if args.action == 'decode':
    sys.stdout.write(security_helper.decode_guid(args.value.lstrip('F')))
elif args.action == 'encode':
    sys.stdout.write(unicodify(security_helper.encode_guid(args.value)))
else:
    sys.stdout.write("Unknown argument")
sys.stdout.write('\n')