def request_authorization_code(): provider = FlaskAuthorizationProvider() response_type = request.args.get("response_type", "code") client_id = request.args.get("client_id", None) redirect_uri = request.args.get("redirect_uri", None) scope = request.args.get("scope", None) if not current_user.is_authenticated or not provider.validate_has_scopes( client_id, current_user.db_user().username, scope ): if not provider.validate_redirect_uri(client_id, redirect_uri): current_app = provider.get_application_for_client_id(client_id) if not current_app: abort(404) return provider._make_redirect_error_response( current_app.redirect_uri, "redirect_uri_mismatch" ) # Load the scope information. scope_info = scopes.get_scope_information(scope) if not scope_info: abort(404) return # Load the application information. oauth_app = provider.get_application_for_client_id(client_id) app_email = oauth_app.avatar_email or oauth_app.organization.email oauth_app_view = { "name": oauth_app.name, "description": oauth_app.description, "url": oauth_app.application_uri, "avatar": json.dumps(avatar.get_data(oauth_app.name, app_email, "app")), "organization": { "name": oauth_app.organization.username, "avatar": json.dumps(avatar.get_data_for_org(oauth_app.organization)), }, } # Show the authorization page. has_dangerous_scopes = any([check_scope["dangerous"] for check_scope in scope_info]) return render_page_template_with_routedata( "oauthorize.html", scopes=scope_info, has_dangerous_scopes=has_dangerous_scopes, application=oauth_app_view, enumerate=enumerate, client_id=client_id, redirect_uri=redirect_uri, scope=scope, csrf_token_val=generate_csrf_token(), ) if response_type == "token": return provider.get_token_response(response_type, client_id, redirect_uri, scope=scope) else: return provider.get_authorization_code(response_type, client_id, redirect_uri, scope=scope)
def request_authorization_code(): provider = FlaskAuthorizationProvider() response_type = request.args.get('response_type', 'code') client_id = request.args.get('client_id', None) redirect_uri = request.args.get('redirect_uri', None) scope = request.args.get('scope', None) if (not current_user.is_authenticated or not provider.validate_has_scopes(client_id, current_user.db_user().username, scope)): if not provider.validate_redirect_uri(client_id, redirect_uri): current_app = provider.get_application_for_client_id(client_id) if not current_app: abort(404) return provider._make_redirect_error_response(current_app.redirect_uri, 'redirect_uri_mismatch') # Load the scope information. scope_info = scopes.get_scope_information(scope) if not scope_info: abort(404) return # Load the application information. oauth_app = provider.get_application_for_client_id(client_id) app_email = oauth_app.avatar_email or oauth_app.organization.email oauth_app_view = { 'name': oauth_app.name, 'description': oauth_app.description, 'url': oauth_app.application_uri, 'avatar': json.dumps(avatar.get_data(oauth_app.name, app_email, 'app')), 'organization': { 'name': oauth_app.organization.username, 'avatar': json.dumps(avatar.get_data_for_org(oauth_app.organization)) } } # Show the authorization page. has_dangerous_scopes = any([check_scope['dangerous'] for check_scope in scope_info]) return render_page_template_with_routedata('oauthorize.html', scopes=scope_info, has_dangerous_scopes=has_dangerous_scopes, application=oauth_app_view, enumerate=enumerate, client_id=client_id, redirect_uri=redirect_uri, scope=scope, csrf_token_val=generate_csrf_token()) if response_type == 'token': return provider.get_token_response(response_type, client_id, redirect_uri, scope=scope) else: return provider.get_authorization_code(response_type, client_id, redirect_uri, scope=scope)
def authorization_view(access_token): oauth_app = access_token.application app_email = oauth_app.avatar_email or oauth_app.organization.email return { "application": { "name": oauth_app.name, "description": oauth_app.description, "url": oauth_app.application_uri, "avatar": avatar.get_data(oauth_app.name, app_email, "app"), "organization": { "name": oauth_app.organization.username, "avatar": avatar.get_data_for_org(oauth_app.organization), }, }, "scopes": scopes.get_scope_information(access_token.scope), "uuid": access_token.uuid, }
def authorization_view(access_token): oauth_app = access_token.application app_email = oauth_app.avatar_email or oauth_app.organization.email return { 'application': { 'name': oauth_app.name, 'description': oauth_app.description, 'url': oauth_app.application_uri, 'avatar': avatar.get_data(oauth_app.name, app_email, 'app'), 'organization': { 'name': oauth_app.organization.username, 'avatar': avatar.get_data_for_org(oauth_app.organization) } }, 'scopes': scopes.get_scope_information(access_token.scope), 'uuid': access_token.uuid }