File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ $(document).ready(function() {
1212 scope : 'openid profile' ,
1313 responseType : 'code' ,
1414 redirectUri : AUTH0_CALLBACK_URL
15- } ) ;
15+ } ) ;
1616 } ) ;
17+
18+ $ ( '.btn-logout' ) . click ( function ( e ) {
19+ e . preventDefault ( ) ;
20+ window . location . href = '/logout' ;
21+ } )
1722} ) ;
Original file line number Diff line number Diff line change 11"""Python Flask WebApp Auth0 integration example
22"""
33from functools import wraps
4+ from urllib .parse import urlparse
45from os import environ as env , path
56import json
67
@@ -47,8 +48,14 @@ def home():
4748@requires_auth
4849def dashboard ():
4950 return render_template ('dashboard.html' ,
50- user = session [constants .PROFILE_KEY ])
51+ user = session [constants .PROFILE_KEY ], env = env )
5152
53+ @APP .route ('/logout' )
54+ def logout ():
55+ session .clear ()
56+ parsed_base_url = urlparse (AUTH0_CALLBACK_URL )
57+ base_url = parsed_base_url .scheme + '://' + parsed_base_url .netloc
58+ return redirect ('https://%s/v2/logout?returnTo=%s&client_id=%s' % (AUTH0_DOMAIN , base_url , AUTH0_CLIENT_ID ))
5259
5360@APP .route ('/public/<path:filename>' )
5461def static_files (filename ):
Original file line number Diff line number Diff line change 55 <!-- font awesome from BootstrapCDN -->
66 < link href ="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css " rel ="stylesheet ">
77 < link href ="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css " rel ="stylesheet ">
8-
8+ < script src ="http://code.jquery.com/jquery-3.1.0.min.js " type ="text/javascript "> </ script >
9+ < script src ="https://cdn.auth0.com/js/auth0/8.6.0/auth0.min.js "> </ script >
10+ < script src ="/public/app.js "> </ script >
911 < link href ="/public/app.css " rel ="stylesheet ">
12+ < script >
13+ var AUTH0_CLIENT_ID = '{{env.AUTH0_CLIENT_ID}}' ;
14+ var AUTH0_DOMAIN = '{{env.AUTH0_DOMAIN}}' ;
15+ var AUTH0_CALLBACK_URL = '{{env.AUTH0_CALLBACK_URL if env.AUTH0_CALLBACK_URL else "http://localhost:3000/callback" }}' ;
16+ var API_AUDIENCE = '{{env.API_ID}}' ;
17+ </ script >
1018 </ head >
1119 < body class ="home ">
1220 < div class ="container ">
1523 < h1 id ="logo "> < img src ="//cdn.auth0.com/samples/auth0_logo_final_blue_RGB.png " /> </ h1 >
1624 < img class ="avatar " src ="{{user['picture']}} "/>
1725 < h2 > Welcome {{user['nickname']}}</ h2 >
26+ < a class ="btn btn-primary btn-lg btn-logout btn-block "> Logout</ a >
1827 </ div >
1928 </ div >
2029 </ div >
You can’t perform that action at this time.
0 commit comments