14
14
from ..exceptions import OAuthToolkitError
15
15
from ..forms import AllowForm
16
16
from ..models import get_application_model
17
+ from .http import UnsafeHttpResponseRedirect
17
18
from .mixins import OAuthLibMixin
18
19
19
20
Application = get_application_model ()
@@ -102,9 +103,8 @@ def form_valid(self, form):
102
103
allow = form .cleaned_data .get ('allow' )
103
104
uri , headers , body , status = self .create_authorization_response (
104
105
request = self .request , scopes = scopes , credentials = credentials , allow = allow )
105
- self .success_url = uri
106
- log .debug ("Success url for the request: {0}" .format (self .success_url ))
107
- return super (AuthorizationView , self ).form_valid (form )
106
+ # uri is already safety-checked by create_authorization_response()
107
+ return UnsafeHttpResponseRedirect (uri )
108
108
109
109
except OAuthToolkitError as error :
110
110
return self .error_response (error )
@@ -135,7 +135,8 @@ def get(self, request, *args, **kwargs):
135
135
uri , headers , body , status = self .create_authorization_response (
136
136
request = self .request , scopes = " " .join (scopes ),
137
137
credentials = credentials , allow = True )
138
- return HttpResponseRedirect (uri )
138
+ # uri is already safety-checked by create_authorization_response()
139
+ return UnsafeHttpResponseRedirect (uri )
139
140
140
141
elif require_approval == 'auto' :
141
142
tokens = request .user .accesstoken_set .filter (application = kwargs ['application' ],
@@ -146,7 +147,8 @@ def get(self, request, *args, **kwargs):
146
147
uri , headers , body , status = self .create_authorization_response (
147
148
request = self .request , scopes = " " .join (scopes ),
148
149
credentials = credentials , allow = True )
149
- return HttpResponseRedirect (uri )
150
+ # uri is already safety-checked by create_authorization_response()
151
+ return UnsafeHttpResponseRedirect (uri )
150
152
151
153
return self .render_to_response (self .get_context_data (** kwargs ))
152
154
0 commit comments