| | |
| | |
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.wicket.models.UserModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.wicket.pages.BasePage;
|
| | | import com.gitblit.wicket.pages.RepositoriesPage;
|
| | |
|
| | | public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements
|
| | |
| | | @SuppressWarnings({ "unchecked", "rawtypes" })
|
| | | @Override
|
| | | protected boolean isPageAuthorized(Class pageClass) {
|
| | | if (RepositoriesPage.class.equals(pageClass)) {
|
| | | // allow all requests to get to the RepositoriesPage with its inline
|
| | | // authentication form
|
| | | return true;
|
| | | }
|
| | |
|
| | | if (BasePage.class.isAssignableFrom(pageClass)) {
|
| | | boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
|
| | | boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
|
| | |
| | | }
|
| | |
|
| | | UserModel user = session.getUser();
|
| | | if (pageClass.isAnnotationPresent(AdminPage.class)) {
|
| | | if (pageClass.isAnnotationPresent(RequiresAdminRole.class)) {
|
| | | // admin page
|
| | | if (allowAdmin) {
|
| | | if (authenticateAdmin) {
|
| | |
| | | @Override
|
| | | public void onUnauthorizedInstantiation(Component component) {
|
| | | if (component instanceof BasePage) {
|
| | | GitBlitWebSession session = GitBlitWebSession.get();
|
| | | if (!session.isLoggedIn()) {
|
| | | throw new RestartResponseAtInterceptPageException(LoginPage.class);
|
| | | } else {
|
| | | throw new RestartResponseAtInterceptPageException(RepositoriesPage.class);
|
| | | }
|
| | | throw new RestartResponseAtInterceptPageException(RepositoriesPage.class);
|
| | | }
|
| | | }
|
| | | }
|