@@ -75,6 +75,8 @@ class AuthorizationView(BaseAuthorizationView, FormView):
75
75
server_class = Server
76
76
validator_class = oauth2_settings .OAUTH2_VALIDATOR_CLASS
77
77
78
+ skip_authorization_completely = False
79
+
78
80
def get_initial (self ):
79
81
# TODO: move this scopes conversion from and to string into a utils function
80
82
scopes = self .oauth2_data .get ('scope' , self .oauth2_data .get ('scopes' , []))
@@ -123,7 +125,17 @@ def get(self, request, *args, **kwargs):
123
125
# Check to see if the user has already granted access and return
124
126
# a successful response depending on 'approval_prompt' url parameter
125
127
require_approval = request .GET .get ('approval_prompt' , oauth2_settings .REQUEST_APPROVAL_PROMPT )
126
- if require_approval == 'auto' :
128
+
129
+ # if skip_authorization_completely is True, skip the authorization screen even
130
+ # if this is the first use of the application and there was no previous authorization
131
+ # useful for in-house applications-> assume an in-house applications are already approved.
132
+ if self .skip_authorization_completely :
133
+ uri , headers , body , status = self .create_authorization_response (
134
+ request = self .request , scopes = " " .join (scopes ),
135
+ credentials = credentials , allow = True )
136
+ return HttpResponseRedirect (uri )
137
+
138
+ elif require_approval == 'auto' :
127
139
tokens = request .user .accesstoken_set .filter (application = kwargs ['application' ],
128
140
expires__gt = timezone .now ()).all ()
129
141
# check past authorizations regarded the same scopes as the current one
0 commit comments