#NEWLINE# @ staticmethod #NEWLINE# def AuthPage( svc , rduri , cid , name , pw , state , resptype , scope ) : #NEWLINE# #INDENT# clients = clientdb . ClientDB ( ) #NEWLINE# try : #NEWLINE# #INDENT# client = clients . find_client ( cid ) #NEWLINE# if ( client is None ) : #NEWLINE# #INDENT# raise AuthClientError ( ) #NEWLINE# #UNINDENT# if ( not client . check_redirect_uri ( rduri ) ) : #NEWLINE# #INDENT# raise AuthClientError ( ) #NEWLINE# #UNINDENT# if ( not client . check_response_type ( resptype ) ) : #NEWLINE# #INDENT# raise AuthError ( rduri , 'invalid_client' ) #NEWLINE# #UNINDENT# user = UserManager . LoadUser ( name ) #NEWLINE# if ( user == None ) : #NEWLINE# #INDENT# raise AuthError ( rduri , 'access_denied' ) #NEWLINE# #UNINDENT# if ( not scope ) : #NEWLINE# #INDENT# scopes = client . get_scopes ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# scopes = scope . split ( ' ' ) #NEWLINE# for one_scope in scopes : #NEWLINE# #INDENT# if ( not client . check_scope ( one_scope ) ) : #NEWLINE# #INDENT# raise AuthError ( rduri , 'invalid_scope' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if user . Authorize ( pw ) : #NEWLINE# #INDENT# session = Session ( user , svc . client_address [ 0 ] , scopes = scopes ) #NEWLINE# session . RecordLogin ( True ) #NEWLINE# if ( resptype == 'code' ) : #NEWLINE# #INDENT# code = Auth . RecordSession ( session , cid ) #NEWLINE# target_uri = ( '%s?code=%s' % ( rduri , code ) ) #NEWLINE# if state : #NEWLINE# #INDENT# target_uri += ( '&state=%s' % state ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( resptype == 'token' ) : #NEWLINE# #INDENT# token = session . GetID ( ) #NEWLINE# target_uri = ( '%s?access_token=%s&token_type=session&expires_in=%d&scope=%s' % ( rduri , token , Config . SESSION_TIMEOUT_SECONDS , ' ' . join ( scopes ) ) ) #NEWLINE# if state : #NEWLINE# #INDENT# target_uri += ( '&state=%s' % state ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise AuthError ( rduri , 'unsupported_response_type' ) #NEWLINE# #UNINDENT# #UNINDENT# svc . send_response ( 302 ) #NEWLINE# svc . send_header ( 'Location' , target_uri ) #NEWLINE# svc . send_header ( 'Content-Length' , 0 ) #NEWLINE# svc . end_headers ( ) #NEWLINE# svc . wfile . flush ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise AuthError ( rduri , 'access_denied' ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# clients . close ( )