<s> import six <EOL> from girder . api import rest <EOL> from girder . models . model_base import AccessException <EOL> def admin ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and callable ( args [ <NUM_LIT:0> ] ) : <EOL> @ six . wraps ( args [ <NUM_LIT:0> ] ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> rest . requireAdmin ( rest . getCurrentUser ( ) ) <EOL> return args [ <NUM_LIT:0> ] ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT>' <EOL> return wrapped <EOL> else : <EOL> def dec ( fun ) : <EOL> @ six . wraps ( fun ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> rest . requireAdmin ( rest . getCurrentUser ( ) ) <EOL> return fun ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT>' <EOL> wrapped . requiredScopes = kwargs . get ( '<STR_LIT>' ) <EOL> return wrapped <EOL> return dec <EOL> def user ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and callable ( args [ <NUM_LIT:0> ] ) : <EOL> @ six . wraps ( args [ <NUM_LIT:0> ] ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> if not rest . getCurrentUser ( ) : <EOL> raise AccessException ( '<STR_LIT>' ) <EOL> return args [ <NUM_LIT:0> ] ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT:user>' <EOL> return wrapped <EOL> else : <EOL> def dec ( fun ) : <EOL> @ six . wraps ( fun ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> if not rest . getCurrentUser ( ) : <EOL> raise AccessException ( '<STR_LIT>' ) <EOL> return fun ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT:user>' <EOL> wrapped . requiredScopes = kwargs . get ( '<STR_LIT>' ) <EOL> return wrapped <EOL> return dec <EOL> def token ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and callable ( args [ <NUM_LIT:0> ] ) : <EOL> @ six . wraps ( args [ <NUM_LIT:0> ] ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> if not rest . getCurrentToken ( ) : <EOL> raise AccessException ( <EOL> '<STR_LIT>' ) <EOL> return args [ <NUM_LIT:0> ] ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT>' <EOL> return wrapped <EOL> else : <EOL> def dec ( fun ) : <EOL> @ six . wraps ( fun ) <EOL> def wrapped ( * iargs , ** ikwargs ) : <EOL> if not rest . getCurrentToken ( ) : <EOL> raise AccessException ( <EOL> '<STR_LIT>' ) <EOL> return fun ( * iargs , ** ikwargs ) <EOL> wrapped . accessLevel = '<STR_LIT>' <EOL> wrapped . requiredScopes = kwargs . get ( '<STR_LIT>' ) <EOL> return wrapped <EOL> return dec <EOL> def public ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and callable ( args [ <NUM_LIT:0> ] ) : <EOL> args [ <NUM_LIT:0> ] . accessLevel = '<STR_LIT>' <EOL> return args [ <NUM_LIT:0> ] <EOL> else : <EOL> def dec ( fun ) : <EOL> fun . accessLevel = '<STR_LIT>' <EOL> fun . requiredScopes = kwargs . get ( '<STR_LIT>' ) <EOL> return fun <EOL> return dec <EOL> def cookie ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and callable ( args [ <NUM_LIT:0> ] ) : <EOL> force = False <EOL> args [ <NUM_LIT:0> ] . cookieAuth = ( True , force ) <EOL> return args [ <NUM_LIT:0> ] <EOL> else : <EOL> def decorator ( fun ) : <EOL> fun . cookieAuth = ( True , kwargs . get ( '<STR_LIT>' , False ) ) <EOL> return fun <EOL> return decorator </s>
