Review Board

beta

Improvement to post-review when using webauth

Updated 5 months, 1 week ago

Xavier Duret Reviewers
reviewboard
513 chipx86
None Review Board SVN
Ensure that "post-review" does not try to access the login page before checking whether webauth is enabled. There is a ugly hack in the patch. Instead to trying to access a review, "post-review" should access a specific page. I still have to figure out how to create a new webapi page on the server.
This was tested on the company server that is webauth enabled.

Diff revision 2 (Latest)

1 2
1 2

  1. /trunk/reviewboard/settings.py: 1 change [ 1 ]
  2. /trunk/reviewboard/contrib/tools/post-review: 1 change [ 1 ]
  3. /trunk/reviewboard/webapi/json.py: 1 change [ 1 ]
  4. /trunk/reviewboard/webapi/urls.py: 1 change [ 1 ]
/trunk/reviewboard/settings.py
Revision 1425 New Change
101
# features like the registration page and profile editing.  If you're tying
101
# features like the registration page and profile editing.  If you're tying
102
# reviewboard in to an existing authentication environment (such as NIS),
102
# reviewboard in to an existing authentication environment (such as NIS),
103
# this data will come in from outside.
103
# this data will come in from outside.
104
BUILTIN_AUTH = True
104
BUILTIN_AUTH = True
105
AUTH_PROFILE_MODULE = "accounts.Profile"
105
AUTH_PROFILE_MODULE = "accounts.Profile"
106
WEBAUTH = ('django.contrib.auth.middleware.RemoteUserAuthMiddleware' in MIDDLEWARE_CLASSES)
106
107
107
# Default repository path to use for the source code.
108
# Default repository path to use for the source code.
108
DEFAULT_REPOSITORY_PATH = None
109
DEFAULT_REPOSITORY_PATH = None
109
110
110
# Default expiration time for the cache.  Note that this has no effect unless
111
# Default expiration time for the cache.  Note that this has no effect unless
/trunk/reviewboard/contrib/tools/post-review
Revision 1425 New Change
158
        information if needed.
158
        information if needed.
159
        """
159
        """
160
        if self.has_valid_cookie():
160
        if self.has_valid_cookie():
161
            return
161
            return
162
162
163
        try:
164
            # Ask the server is webauth is activated.
165
            # If this is the case then urllib will transparently ask
166
            # for a username and a password.
167
            rsp = self.api_get('api/json/settings/webauth')
168
            webauth = rsp['webauth']
169
170
        except APIError, e:
171
            rsp, = e.args
172
173
            die("Unable to log in: %s (%s)" % (rsp["err"]["msg"],
174
                                               rsp["err"]["code"]))
175
176
177
        if not webauth:
163
        print "==> Review Board Login Required"
178
            print "==> Review Board Login Required"
164
        print "Enter username and password for Review Board at %s" % self.url
179
            print "Enter username and password for Review Board at %s" % self.url
165
        username = raw_input('Username: ')
180
            username = raw_input('Username: ')
166
        password = getpass.getpass('Password: ')
181
            password = getpass.getpass('Password: ')
167
182
/trunk/reviewboard/webapi/json.py
Revision 1425 New Change
215
        return None
215
        return None
216
    else:
216
    else:
217
        raise "Invalid status '%s'" % status
217
        raise "Invalid status '%s'" % status
218
218
219
219
220
def webauth_enabled(request):
221
    """
222
    Returns true is authentication through the web
223
    server is enabled.
224
    """
225
    return WebAPIResponse(request, {
226
        'webauth': settings.WEBAUTH,
227
    })
228
229
220
@webapi_login_required
230
@webapi_login_required
221
def repository_list(request):
231
def repository_list(request):
222
    """
232
    """
223
    Returns a list of all known repositories.
233
    Returns a list of all known repositories.
224
    """
234
    """
/trunk/reviewboard/webapi/urls.py
Revision 1425 New Change
1
from djblets.util.misc import never_cache_patterns
1
from djblets.util.misc import never_cache_patterns
2
2
3
from reviewboard.reviews.models import ReviewRequest
3
from reviewboard.reviews.models import ReviewRequest
4
4
5
5
6
urlpatterns = never_cache_patterns('djblets.webapi.auth',
6
urlpatterns = never_cache_patterns('djblets.webapi.auth',
7
    # Accounts
7
    # Accounts
8
    (r'^accounts/login/$', 'account_login'),
8
    (r'^accounts/login/$', 'account_login'),
9
    (r'^accounts/logout/$', 'account_logout'),
9
    (r'^accounts/logout/$', 'account_logout'),
10
)
10
)
11
11
12
12
13
urlpatterns += never_cache_patterns('reviewboard.webapi.json',
13
urlpatterns += never_cache_patterns('reviewboard.webapi.json',
14
    # Settings
15
    (r'^settings/webauth/$', 'webauth_enabled'),
16
14
    # Repositories
17
    # Repositories
15
    (r'^repositories/$', 'repository_list'),
18
    (r'^repositories/$', 'repository_list'),
16
    (r'^repositories/(?P<repository_id>[0-9]+)/info/$', 'repository_info'),
19
    (r'^repositories/(?P<repository_id>[0-9]+)/info/$', 'repository_info'),
17
20
18
    # Users
21
    # Users
  1. /trunk/reviewboard/settings.py: 1 change [ 1 ]
  2. /trunk/reviewboard/contrib/tools/post-review: 1 change [ 1 ]
  3. /trunk/reviewboard/webapi/json.py: 1 change [ 1 ]
  4. /trunk/reviewboard/webapi/urls.py: 1 change [ 1 ]