37 | {{!-- UBC custom, remove persistent main menu state so that we're hiding
38 | the menu on every page load by default. Original code:
39 |
44 | --}}
45 |
49 |
50 | {{>Header}}
51 |
62 | {{! `role` is unnecessary but kept to support selectors in any gadgets or user styles. }}
63 |
64 |
65 | {{>ContentHeader}}
66 | {{>ArticleToolbar}}
67 |
{{! END mw-page-container }}
86 | {{#data-vector-sticky-header}}{{>StickyHeader}}{{/data-vector-sticky-header}}
87 |
--------------------------------------------------------------------------------
/mediawiki.conf:
--------------------------------------------------------------------------------
1 | # Set upload limit to 210MB to allow for larger file uploads
2 | # NOTE: this limit is also enforced by php's limits, see /etc/php.ini
3 | LimitRequestBody 220200960
4 | # has to set to NoDecode so that the URLs with "/"(slash) can be accepted and applied to RewriteRule
5 | AllowEncodedSlashes NoDecode
6 |
7 | # for mod_remoteip to get real client IP
8 | RemoteIPHeader X-Forwarded-For
9 | #RemoteIPInternalProxy 127.0.0.1/8
10 | # %a uses IP from mod_remoteip
11 | LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
12 | CustomLog ${APACHE_LOG_DIR}/access.log combined
13 |
14 | # Support for SSL, redirect HTTP to HTTPS and place in SSL stuff.
15 |
16 |
17 | RewriteEngine On
18 | RewriteCond %{HTTPS} off
19 | RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
20 |
21 |
22 |
23 | SSLEngine on
24 | SSLCertificateFile /etc/apache2/ssl.crt
25 | SSLCertificateKeyFile /etc/apache2/ssl.key
26 | SSLCertificateChainFile /etc/apache2/ssl.bundle.crt
27 |
28 |
29 |
30 | ProxyPass /api/rest_v1 ${RESTBASE_URL}/localhost/v1 nocanon
31 | ProxyPassReverse /api/rest_v1 ${RESTBASE_URL}/localhost/v1 nocanon
32 |
33 |
34 | # Use of .htaccess files exposes a lot of security risk,
35 | # disable them and put all the necessary configuration here instead.
36 | AllowOverride None
37 |
38 | RewriteEngine On
39 | RewriteBase /
40 | # Expose REST API at /api/rest_v1/
41 | # "NE" is needed so that the correct URL encoding such as "%2F" (slash) being passed to backend correctly
42 | # RewriteCond %{ENV:RESTBASE_URL} "!^restbase-is-not-specified$"
43 | # RewriteRule ^api/rest_v1/(.*)$ %{ENV:RESTBASE_URL}/localhost/v1/$1 [P,L,NE]
44 | # RewriteRule ^w/(.*)$ %{DOCUMENT_ROOT}/$1 [L]
45 | # Short url for wiki pages
46 | RewriteRule ^wiki/(.*)?$ %{DOCUMENT_ROOT}/index.php [L]
47 | RewriteRule ^wiki$ /wiki/ [R,L]
48 |
49 | # Redirect / to Main Page
50 | # RewriteRule ^$ /wiki/ [R,L]
51 |
52 |
53 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
54 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
55 | RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
56 |
57 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
58 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
59 | RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]
60 |
61 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
62 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
63 | RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
64 |
65 |
66 |
67 |
68 | # Ignore .htaccess files
69 | AllowOverride None
70 |
71 | # Serve HTML as plaintext, don't execute SHTML
72 | AddType text/plain .html .htm .shtml .php
73 |
74 | # Don't run arbitrary PHP code.
75 | php_admin_flag engine off
76 |
77 |
78 | # Protect risky directory from abuse
79 |
80 | Deny from all
81 |
82 |
83 | Deny from all
84 |
85 |
86 | Deny from all
87 |
88 |
89 | Deny from all
90 |
91 |
92 | Deny from all
93 |
94 |
95 | Deny from all
96 |
97 |
98 | Deny from all
99 |
100 |
101 | Allow from all
102 |
103 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: CI to Docker Hub
2 |
3 | # Controls when the workflow will run
4 | on:
5 | # Triggers the workflow on push or pull request events but only for the master branch
6 | push:
7 | branches: [ "*" ]
8 | tags: [ "*" ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | # Allows you to run this workflow manually from the Actions tab
13 | workflow_dispatch:
14 |
15 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
16 | jobs:
17 | # This workflow contains a single job called "build"
18 | build:
19 | # The type of runner that the job will run on
20 | runs-on: ubuntu-latest
21 |
22 | # Steps represent a sequence of tasks that will be executed as part of the job
23 | steps:
24 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25 | - name: Set up QEMU
26 | uses: docker/setup-qemu-action@v3
27 |
28 | - name: Login to Docker Hub
29 | uses: docker/login-action@v3
30 | with:
31 | username: ${{ secrets.DOCKER_HUB_USERNAME }}
32 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
33 |
34 | - name: Docker meta
35 | id: meta
36 | uses: docker/metadata-action@v5
37 | with:
38 | images: ubcctlt/mediawiki
39 | # generate Docker tags based on the following events/attributes
40 | tags: |
41 | type=schedule
42 | type=ref,event=branch
43 | type=ref,event=pr
44 | type=ref,event=tag
45 | type=semver,pattern={{version}}
46 | type=semver,pattern={{major}}.{{minor}}
47 | type=semver,pattern={{major}}
48 | type=sha
49 |
50 | - name: Set up Docker Buildx
51 | uses: docker/setup-buildx-action@v3
52 |
53 | - name: Build and push
54 | id: docker_build
55 | uses: docker/build-push-action@v6
56 | with:
57 | push: ${{ github.event_name != 'pull_request' }}
58 | tags: ${{ steps.meta.outputs.tags }}
59 | labels: ${{ steps.meta.outputs.labels }}
60 |
61 | - name: Image digest
62 | run: echo ${{ steps.docker_build.outputs.digest }}
63 | buildSimplesamlphp:
64 | # builds and pushes the SimpleSAMLphp SP component to a separate docker hub
65 | # repo
66 | runs-on: ubuntu-latest
67 | steps:
68 | - name: Set up QEMU
69 | uses: docker/setup-qemu-action@v3
70 |
71 | - name: Login to Docker Hub
72 | uses: docker/login-action@v3
73 | with:
74 | username: ${{ secrets.DOCKER_HUB_USERNAME }}
75 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
76 |
77 | - name: Docker meta
78 | id: meta
79 | uses: docker/metadata-action@v5
80 | with:
81 | images: ubcctlt/mediawiki-simplesamlphp
82 | # generate Docker tags based on the following events/attributes
83 | tags: |
84 | type=schedule
85 | type=ref,event=branch
86 | type=ref,event=pr
87 | type=ref,event=tag
88 | type=semver,pattern={{version}}
89 | type=semver,pattern={{major}}.{{minor}}
90 | type=semver,pattern={{major}}
91 | type=sha
92 |
93 | - name: Set up Docker Buildx
94 | uses: docker/setup-buildx-action@v3
95 |
96 | - name: Build and push
97 | id: docker_build
98 | uses: docker/build-push-action@v6
99 | with:
100 | context: "{{defaultContext}}:docker/simplesamlphp/sp/"
101 | file: Dockerfile.sp
102 | push: ${{ github.event_name != 'pull_request' }}
103 | tags: ${{ steps.meta.outputs.tags }}
104 | labels: ${{ steps.meta.outputs.labels }}
105 |
106 | - name: Image digest
107 | run: echo ${{ steps.docker_build.outputs.digest }}
108 |
--------------------------------------------------------------------------------
/skins/Vector/resources/skins.vector.styles/layouts/screen.less:
--------------------------------------------------------------------------------
1 | /**
2 | * Vector modern layout styles for screen
3 | *
4 | * Layout rules divide the page into sections and how VectorComponents should be arranged in the skin.
5 | * The rules here should only define the layout, not color or typography.
6 | */
7 |
8 | @import '../../common/variables.less';
9 | @import 'mediawiki.mixins.less';
10 |
11 | @selector-sidebar-no-toc-sidebar-closed: ~'.vector-sidebar-container-no-toc';
12 |
13 | // Content container
14 |
15 | // Note this uses variables defined in mediawiki.skin.variables so that VisualEditor can read them
16 | // see T259331.
17 | @padding-content: @padding-top-content @padding-horizontal-content 1.5em;
18 |
19 | // Breakpoints
20 |
21 | // Defines the minimum viewport width, at which point the layout will not get any
22 | // smaller and will start horizontal scrolling instead.
23 | @min-width-supported:
24 | unit( 500px / @font-size-browser, em ) -
25 | ( 2 * @padding-horizontal-page-container-wide );
26 | // 31.25em - 3.75em = 27.5em @ 16
27 |
28 | body {
29 | background-color: @background-color-secondary--modern;
30 | color: @color-base;
31 | // Vertical scrollbar always visible.
32 | overflow-y: scroll;
33 | }
34 |
35 | .mw-body,
36 | .parsoid-body {
37 | direction: ltr;
38 | }
39 |
40 | .mw-body {
41 | border-top: @border-width-base @border-style-base transparent;
42 | /* Merge the border with tabs' one (in their background image) */
43 | margin-top: -@border-width-base;
44 | padding: @padding-content;
45 |
46 | .firstHeading {
47 | /* Change the default from mediawiki.skinning CSS to let indicators float into heading area */
48 | overflow: visible;
49 | margin-bottom: 0;
50 | }
51 | }
52 |
53 | .mw-header {
54 | // allow z-index to apply so search results overlay article
55 | position: relative;
56 | z-index: @z-index-header;
57 | }
58 |
59 | .mw-body-content {
60 | margin-top: 16px;
61 | }
62 |
63 | /* Main column */
64 | .mw-body,
65 | #mw-data-after-content,
66 | .mw-footer {
67 | margin-left: 0;
68 | }
69 |
70 | /* Content */
71 | .mw-indicators {
72 | z-index: @z-index-indicators;
73 | }
74 |
75 | .mw-body-header,
76 | .mw-body-subheader {
77 | .mixin-clearfix();
78 | }
79 |
80 | .mw-body .mw-portlet-lang {
81 | float: right;
82 | }
83 |
84 | #siteSub {
85 | // By default its hidden as it was hidden in Vector legacy but site styles can reveal.
86 | display: none;
87 | }
88 |
89 | .vector-body {
90 | position: relative;
91 | z-index: @z-index-base;
92 |
93 | #siteSub {
94 | margin-top: 8px; // T311564
95 | }
96 |
97 | #contentSub,
98 | #contentSub2 {
99 | font-size: 84%;
100 | line-height: 1.2em;
101 | // T311564
102 | margin: 8px 0 0;
103 | color: #54595d;
104 | width: auto;
105 | }
106 | }
107 |
108 | #left-navigation {
109 | float: left;
110 | margin-left: -@padding-horizontal-tabs;
111 | }
112 |
113 | #right-navigation {
114 | float: right;
115 | margin-right: -@padding-horizontal-tabs;
116 | // Any dropdowns inside the right navigation in modern Vector (e.g. "more" menu).
117 | // should be right-aligned to prevent horizontal scrolling.
118 | .vector-menu-content {
119 | left: auto;
120 | right: -@border-width-base;
121 | }
122 | }
123 |
124 | .parsoid-body {
125 | padding: @padding-content;
126 | }
127 |
128 | .mw-footer {
129 | border-top: @border-base;
130 | padding: 0.75em;
131 | }
132 |
133 | // Container logic.
134 | .mw-page-container {
135 | // Setting position and z-index is important as it allows overlays appended to the body tag
136 | // to position themselves over the Vector interface. This forms another stacking context for
137 | // elements placed inside this element
138 | position: relative;
139 | z-index: 0;
140 | max-width: @max-width-page-container;
141 | // Fill the viewport even if the content height is small. This also helps
142 | // mitigate a long sidebar overflowing the page container (T257518).
143 | min-height: 100%;
144 | margin-left: auto;
145 | margin-right: auto;
146 | // Use non-zero padding to disable margin collapse.
147 | // Be careful not to use overflow-y: scroll here (see T270146 and T271868)
148 | padding: 0.05px ( @padding-horizontal-page-container / 2 );
149 | background-color: @background-color-page-container;
150 | // Set a min-width to make explicit we do not support anything below this threshold.
151 | // For devices too small, they should be more useable with horizontal scrolling.
152 | // e.g. Portrait on an iPad
153 | min-width: @min-width-supported;
154 |
155 | @media ( min-width: @min-width-desktop ) {
156 | padding-left: @padding-horizontal-page-container;
157 | padding-right: @padding-horizontal-page-container;
158 | }
159 |
160 | @media ( min-width: @min-width-desktop-wide ) {
161 | padding-left: @padding-horizontal-page-container-wide;
162 | padding-right: @padding-horizontal-page-container-wide;
163 | }
164 | }
165 |
166 | .skin--responsive .mw-page-container {
167 | min-width: auto;
168 | }
169 |
170 | @import 'grid.less';
171 |
--------------------------------------------------------------------------------
/skins/Vector/resources/skins.vector.styles/components/TableOfContents.less:
--------------------------------------------------------------------------------
1 | @import '../../common/variables.less';
2 |
3 | @sidebar-toc-fade-height: 30px;
4 | @sidebar-toc-vertical-padding: 20px;
5 | @sidebar-toc-right-padding: 12px;
6 | // Sidebar TOC uses increased left padding and a negative left margin to achieve
7 | // a 15px spacing without clipping the chevron icon
8 | // https://phabricator.wikimedia.org/T312156#8095894
9 | @sidebar-toc-left-padding: ~'calc( 15px + @{margin-start-sidebar-content} )';
10 | @toc-subsection-toggle-icon-size: 1.834em;
11 |
12 | .mw-table-of-contents-container {
13 | // Needed for Grid-based layout
14 | align-self: start;
15 | height: 100%;
16 | }
17 |
18 | // FIXME: Remove selector after Ia263c606dce5a6060b6b29fbaedc49cef3e17a5c has been in prod for 5 days
19 | .mw-table-of-contents-container.mw-sticky-header-element {
20 | // stylelint-disable-next-line plugin/no-unsupported-browser-features
21 | position: sticky;
22 | top: 0;
23 | // Needed for Grid-based layout
24 | align-self: start;
25 | height: unset;
26 |
27 | // Needed to align TOC with bottom of title
28 | // 1.5em from .mw-table-of-contents-container + 1.5em from .sidebar-toc = 3em
29 | @media ( min-width: @min-width-desktop ) {
30 | .vector-toc-not-collapsed @{selector-main-menu-closed} ~ & {
31 | //margin-top: 1.5em;
32 | }
33 | }
34 | }
35 |
36 | .vector-sticky-toc-container {
37 | // stylelint-disable-next-line plugin/no-unsupported-browser-features
38 | position: sticky;
39 | top: 0;
40 |
41 | @media ( min-width: @min-width-desktop ) {
42 | .vector-toc-not-collapsed & {
43 | // Default spacing separating the sidebar TOC from the main menu or viewport.
44 | // Need to use padding in order for the spacing to apply when sticky
45 | padding-top: 1.5em;
46 | }
47 |
48 | .vector-toc-not-collapsed @{selector-main-menu-closed} ~ .mw-table-of-contents-container & {
49 | // Needed to align TOC with bottom of title, 1.5em padding + 1.5em margin = 3em
50 | //margin-top: 1.5em;
51 | }
52 | }
53 | }
54 |
55 | // FIXME: Remove selector after Ia263c606dce5a6060b6b29fbaedc49cef3e17a5c has been in prod for 5 days
56 | .mw-table-of-contents-container > .sidebar-toc {
57 | margin-top: 1.5em;
58 | }
59 |
60 | .sidebar-toc {
61 | max-height: 75vh;
62 | padding: @sidebar-toc-vertical-padding @sidebar-toc-right-padding @sidebar-toc-vertical-padding @sidebar-toc-left-padding;
63 | box-sizing: border-box;
64 | overflow: auto;
65 | background-color: @background-color-page-container;
66 |
67 | .sidebar-toc-header {
68 | padding-bottom: 12px;
69 | }
70 |
71 | .sidebar-toc-title {
72 | color: @color-base--subtle;
73 | font-size: @font-size-base;
74 | margin: 0;
75 | padding: 0;
76 | border: 0;
77 | }
78 |
79 | .sidebar-toc-numb {
80 | display: none;
81 | }
82 |
83 | .sidebar-toc-toggle {
84 | // For no-js users, toggling is disabled and icon is hidden
85 | display: none;
86 | position: absolute;
87 | top: 1px; // visually center icon
88 | left: ~'calc( -1 * @{toc-subsection-toggle-icon-size} - 1px )'; // leaves 6px between icon + text
89 | width: @toc-subsection-toggle-icon-size; // ~22px @ 12
90 | height: @toc-subsection-toggle-icon-size;
91 | font-size: 0.75em; // reduces size of toggle icon to 12px @ 16
92 | transition: @transition-duration-base;
93 | cursor: pointer;
94 | }
95 |
96 | .sidebar-toc-link {
97 | word-break: break-word;
98 | color: @color-link;
99 | display: block;
100 | }
101 |
102 | .sidebar-toc-list-item-active > .sidebar-toc-link {
103 | // Highlight active section
104 | color: @color-base;
105 | font-weight: bold;
106 | // increase width to prevent line wrapping due to bold text
107 | width: ~'calc( 100% + @{sidebar-toc-right-padding} )';
108 | }
109 |
110 | .sidebar-toc-text {
111 | padding: 4px 0;
112 | }
113 |
114 | .sidebar-toc-contents,
115 | .sidebar-toc-list {
116 | margin: 0;
117 | list-style: none;
118 | line-height: 18px;
119 | }
120 |
121 | .sidebar-toc-list-item {
122 | display: block;
123 | position: relative;
124 | list-style-type: none;
125 | padding-left: 8px;
126 |
127 | &.sidebar-toc-level-1 {
128 | padding-left: 0;
129 | }
130 |
131 | a {
132 | font-size: @font-size-base;
133 | }
134 | }
135 | }
136 |
137 | // T302076: Add fade scrollable indicator when TOC is in sidebar
138 | // Avoid showing indicator when the TOC is floating, or collapsed in the page title/sticky header
139 | @media ( min-width: @min-width-desktop ) {
140 | .vector-toc-not-collapsed .sidebar-toc:after {
141 | content: '';
142 | display: block;
143 | position: absolute;
144 | bottom: 0;
145 | left: 0;
146 | right: 0;
147 | height: @sidebar-toc-fade-height;
148 | background: linear-gradient( rgba( 255, 255, 255, 0 ), @background-color-page-container );
149 | background-repeat: no-repeat;
150 | background-position: -@sidebar-toc-right-padding; // T311436 Hacky way to prevent the fade from covering the scrollbar
151 | pointer-events: none; // Make the link below the fade clickable
152 | }
153 | }
154 |
155 | // Collapse ToC sections by default, excluding no-js
156 | .client-js .sidebar-toc {
157 | .sidebar-toc-level-1 .sidebar-toc-list-item {
158 | display: none;
159 | }
160 |
161 | .sidebar-toc-level-1.sidebar-toc-list-item-expanded .sidebar-toc-list-item {
162 | display: block;
163 | }
164 |
165 | .sidebar-toc-toggle {
166 | display: block;
167 | }
168 |
169 | .sidebar-toc-level-1.sidebar-toc-list-item-expanded .sidebar-toc-toggle {
170 | transform: rotate( 0deg );
171 | }
172 | }
173 |
174 | .client-js body.ltr .sidebar-toc .sidebar-toc-toggle {
175 | transform: rotate( -90deg );
176 | }
177 |
178 | .client-js body.rtl .sidebar-toc .sidebar-toc-toggle {
179 | transform: rotate( 90deg );
180 | }
181 |
182 | // FIXME: Can be removed when https://github.com/cssjanus/cssjanus/issues/82 is fixed and in production.
183 | body.rtl .sidebar-toc {
184 | padding: @sidebar-toc-vertical-padding @sidebar-toc-left-padding @sidebar-toc-vertical-padding @sidebar-toc-right-padding;
185 | }
186 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-apache
2 |
3 | ENV WIKI_VERSION_MAJOR_MINOR=1.43
4 | ENV WIKI_VERSION_BUGFIX=6
5 | ENV WIKI_VERSION=$WIKI_VERSION_MAJOR_MINOR.$WIKI_VERSION_BUGFIX
6 | ENV WIKI_VERSION_STR=1_43
7 |
8 | RUN apt-get update && apt-get install -y --no-install-recommends \
9 | libfreetype6-dev \
10 | libjpeg62-turbo-dev \
11 | libpng-dev \
12 | libmagickwand-dev \
13 | libicu-dev \
14 | libldap-dev \
15 | libldap-common \
16 | netcat-traditional \
17 | git \
18 | imagemagick \
19 | unzip \
20 | vim \
21 | libonig-dev \
22 | # for simpleSAMLphp
23 | libzip-dev \
24 | # for TimedMediaHandler
25 | ffmpeg \
26 | && rm -rf /var/lib/apt/lists/* \
27 | && rm -rf /var/cache/apt/archives/* \
28 | && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
29 | && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
30 | && docker-php-source extract
31 |
32 | # install php extensions
33 | # pcntl for Scribunto, zip for SimpleSAMLphp
34 | COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
35 | RUN install-php-extensions mbstring xml intl mysqli ldap pcntl opcache calendar zip imagick redis memcached
36 |
37 | RUN a2enmod rewrite
38 |
39 | WORKDIR /var/www/html
40 |
41 | RUN curl -L https://releases.wikimedia.org/mediawiki/$WIKI_VERSION_MAJOR_MINOR/mediawiki-$WIKI_VERSION.tar.gz | tar xz --strip=1
42 |
43 | COPY php.ini /usr/local/etc/php/
44 |
45 | COPY mediawiki.conf /etc/apache2/
46 | RUN echo "Include /etc/apache2/mediawiki.conf" >> /etc/apache2/apache2.conf \
47 | && rm /etc/apache2/sites-enabled/000-default.conf \
48 | && a2enmod proxy \
49 | && a2enmod proxy_http \
50 | && a2enmod remoteip
51 |
52 | COPY docker-entrypoint.sh /entrypoint.sh
53 | COPY docker-startuptasks.sh /startuptasks.sh
54 | COPY LocalSettings.php /var/www/html/LocalSettings.php
55 | COPY CustomHooks.php /var/www/html/CustomHooks.php
56 | COPY composer.local.json /var/www/html/composer.local.json
57 | COPY robots.txt /var/www/html/robots.txt
58 | COPY resourcesCustom /var/www/html/resourcesCustom
59 |
60 | # composer won't load plugins if we don't explicitly allow executing as root
61 | ENV COMPOSER_ALLOW_SUPERUSER=1
62 | RUN curl -L https://getcomposer.org/installer | php \
63 | && php composer.phar install --no-dev
64 |
65 | RUN EXTS=`curl https://extdist.wmflabs.org/dist/extensions/ | awk 'BEGIN { FS = "\"" } ; {print $2}'` \
66 | && for i in SmiteSpam VisualEditor Scribunto LiquidThreads Cite WikiEditor LDAPProvider PluggableAuth LDAPAuthentication2 ParserFunctions TemplateData InputBox Widgets Variables RightFunctions CategoryTree LabeledSectionTransclusion UserPageEditProtection Quiz Collection DeleteBatch LinkTarget HitCounters Math 3D MultimediaViewer TimedMediaHandler SimpleSAMLphp; do \
67 | FILENAME=`echo "$EXTS" | grep ^${i}-REL${WIKI_VERSION_STR}`; \
68 | echo "Installing https://extdist.wmflabs.org/dist/extensions/$FILENAME"; \
69 | curl -Ls https://extdist.wmflabs.org/dist/extensions/$FILENAME | tar xz -C /var/www/html/extensions; \
70 | done \
71 | && echo "Installing https://github.com/ubc/EmbedPage/archive/v2.0.2.tar.gz" \
72 | && mkdir /var/www/html/extensions/EmbedPage \
73 | && curl -Ls https://github.com/ubc/EmbedPage/archive/v2.0.1.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/EmbedPage \
74 | && echo "Installing https://github.com/ubc/mediawiki-extensions-UploadWizard/archive/refs/heads/REL1_43.tar.gz" \
75 | && mkdir /var/www/html/extensions/UploadWizard \
76 | && curl -Ls https://github.com/ubc/mediawiki-extensions-UploadWizard/archive/refs/heads/REL1_43.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/UploadWizard \
77 | && echo "Installing https://github.com/smarty-php/smarty/archive/v3.1.44.tar.gz" \
78 | && mkdir -p /var/www/html/extensions/Widgets/smarty \
79 | && curl -Ls https://github.com/smarty-php/smarty/archive/v3.1.44.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/Widgets/smarty \
80 | && echo "Installing https://github.com/SkizNet/mediawiki-GTag/archive/master.tar.gz" \
81 | && mkdir -p /var/www/html/extensions/GTag \
82 | && curl -Ls https://github.com/SkizNet/mediawiki-GTag/archive/master.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/GTag\
83 | && echo "Installing https://github.com/ubc/mediawiki-extensions-caliper/archive/v2.0.5.tar.gz" \
84 | && mkdir -p /var/www/html/extensions/caliper \
85 | && curl -Ls https://github.com/ubc/mediawiki-extensions-caliper/archive/v2.0.5.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/caliper \
86 | && echo "Installing https://github.com/ubc/mediawiki-extensions-ubcauth/archive/REL1_43.tar.gz" \
87 | && mkdir -p /var/www/html/extensions/UBCAuth\
88 | && curl -Ls https://github.com/ubc/mediawiki-extensions-ubcauth/archive/REL1_43.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/UBCAuth \
89 | && echo "Installing https://github.com/ubc/mediawiki-extensions-AutoCreatedUserRedirector/archive/master.tar.gz" \
90 | && mkdir -p /var/www/html/extensions/AutoCreatedUserRedirector \
91 | && curl -Ls https://github.com/ubc/mediawiki-extensions-AutoCreatedUserRedirector/archive/master.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/AutoCreatedUserRedirector \
92 | # WARNING: if updating DynamicPageList3 from 3.5.1, check if fix below is still required \
93 | && echo "Installing https://github.com/Universal-Omega/DynamicPageList3/archive/refs/tags/3.6.4.tar.gz" \
94 | && mkdir -p /var/www/html/extensions/DynamicPageList \
95 | && curl -Ls https://github.com/Universal-Omega/DynamicPageList3/archive/refs/tags/3.6.4.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/DynamicPageList
96 | ##Comment out to use with MW Extension method
97 | ##&& echo "Installing SmiteSpam https://github.com/wikimedia/mediawiki-extensions-SmiteSpam/archive/REL1_39.zip" \
98 | ##&& curl -L -o smitespam.zip https://github.com/wikimedia/mediawiki-extensions-SmiteSpam/archive/REL1_39.zip \
99 | ##&& unzip smitespam.zip -d /var/www/html/extensions/ \
100 | ##&& mv /var/www/html/extensions/mediawiki-extensions-SmiteSpam-REL1_39 /var/www/html/extensions/SmiteSpam
101 | #&& echo "Installing patched Math extension from https://github.com/ubc/mediawiki-extensions-Math/archive/REL1_35.tar.gz" \
102 | #&& mkdir -p /var/www/html/extensions/Math \
103 | #&& curl -Ls https://github.com/ubc/mediawiki-extensions-Math/archive/REL1_35.tar.gz | tar xz --strip=1 -C /var/www/html/extensions/Math
104 |
105 | # composer.local.json merges in composer.json from caliper extension, so we
106 | # need to run composer update after getting the extensions.
107 | RUN php composer.phar update --no-dev
108 |
109 | RUN mkdir -p /data \
110 | && chmod a+rw /var/www/html/extensions/Widgets/compiled_templates
111 |
112 | VOLUME /data
113 |
114 | EXPOSE 80
115 |
116 | ENTRYPOINT ["/entrypoint.sh"]
117 | CMD ["apachectl", "-e", "info", "-D", "FOREGROUND"]
118 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | services:
2 | db:
3 | image: mariadb:10.11
4 | environment:
5 | - MYSQL_ROOT_PASSWORD=password
6 | - MARIADB_DATABASE=mediawiki
7 | - MARIADB_AUTO_UPGRADE=1
8 | volumes:
9 | - ./.data/db:/var/lib/mysql
10 | ports:
11 | - 3306:3306
12 | adminer:
13 | image: "adminer:4"
14 | ports:
15 | - "8089:8080"
16 | depends_on:
17 | - db
18 | idp: # dev use only
19 | build:
20 | context: ./docker/simplesamlphp/idp/
21 | dockerfile: Dockerfile.idp
22 | ports:
23 | - "8190:80"
24 | # direct internal docker network traffic from idp external port 8190 to idp internal port 80
25 | socat:
26 | image: alpine/socat:1.8.0.0
27 | depends_on:
28 | - idp
29 | command: "TCP-LISTEN:8190,fork,reuseaddr TCP:idp:80"
30 | networks:
31 | default:
32 | aliases:
33 | - idp.docker
34 | sp:
35 | build:
36 | context: ./docker/simplesamlphp/sp/
37 | dockerfile: Dockerfile.sp
38 | volumes:
39 | - simplesamlphp:/var/www/simplesamlphp
40 | # dev cert, do not use for prod
41 | - ./docker/simplesamlphp/sp/cert/:/var/www/simplesamlphp-base/cert/
42 | environment: &simplesamlphpVars
43 | SIMPLESAMLPHP_DEV: 1
44 | SIMPLESAMLPHP_MEMCACHED_SERVER: memcached
45 | SIMPLESAMLPHP_TRUSTED_DOMAIN: wiki.docker:8080
46 | SIMPLESAMLPHP_BASEURL: 'http://wiki.docker:8080'
47 | SIMPLESAMLPHP_BASEURLPATH: 'http://wiki.docker:8080/_saml2'
48 | SIMPLESAMLPHP_SP_ENTITY_ID: 'http://wiki.docker:8080/_saml2'
49 | SIMPLESAMLPHP_IDP_ENTITY_ID: 'http://idp.docker:8190'
50 | SIMPLESAMLPHP_IDP_METADATA_URL: 'http://idp.docker:8190/simplesaml/module.php/saml/idp/metadata'
51 | SIMPLESAMLPHP_CRON_SECRET: IWEUMmYowDIpyJ4QgV4Pnis81AUxEsnY
52 | depends_on:
53 | - idp
54 | labels:
55 | - "traefik.enable=true"
56 | - "traefik.http.routers.sp.rule=PathPrefix(`/_saml2`)"
57 | - "traefik.http.routers.sp.entrypoints=wiki"
58 | - "traefik.http.services.sp.loadBalancer.server.port=8080"
59 | web: &app
60 | #image: ubcctlt/mediawiki
61 | build: .
62 | # use the links section if you want to use a container for a database.
63 | # if not, and you want to use an external database server, configure
64 | # if with the environment variables in the 'environment' section.
65 | # see README.md for more details.
66 | links:
67 | - db
68 | # uncomment the 'volumes' section to enable a shared volume with docker-compose
69 | volumes:
70 | - ./.data/web:/data:rw
71 | - ./CustomSettings.php:/conf/CustomSettings.php
72 | # do not uncomment this when starting a new instance from scratch as
73 | # init script won't be able to move this file
74 | #- ./LocalSettings.php:/var/www/html/LocalSettings.php
75 | #- ./CustomHooks.php:/var/www/html/CustomHooks.php
76 | - simplesamlphp:/var/www/simplesamlphp:ro
77 | environment:
78 | MEDIAWIKI_SITE_SERVER: http://wiki.docker:8080
79 | MEDIAWIKI_SITE_NAME: My Awesome Wiki
80 | MEDIAWIKI_DB_HOST: db
81 | MEDIAWIKI_DB_PASSWORD: password
82 | # uncomment 'MEDIAWIKI_ENABLE_SSL' to enable SSL support
83 | # MEDIAWIKI_ENABLE_SSL: true
84 | MEDIAWIKI_EXTENSIONS: SmiteSpam,VisualEditor,WikiEditor,ParserFunctions,Cite,TemplateData,Scribunto,InputBox,Widgets,Maps,Math,LiquidThreads,Variables,RightFunctions,PageInCat,CategoryTree,LabeledSectionTransclusion,UserPageEditProtection,Quiz,UploadWizard,Collection,DynamicPageList,EmbedPage,UWUBCMessages,googleAnalytics,Renameuser,caliper,DeleteBatch,LinkTarget,HitCounters,GTag,3D,TimedMediaHandler,Nuke
85 | MEDIAWIKI_ALLOW_SITE_CSS_ON_RESTRICTED_PAGES: true
86 | # Add a logo to the wiki, can be relative paths to uploaded wiki images
87 | # Note: ICON (required) used by newer themes, LEGACY (optional) by older
88 | #MEDIAWIKI_LOGO_ICON: /path/to/100x100/image/or/50x50/svg.svg
89 | #MEDIAWIKI_LOGO_LEGACY1X: /path/to/135px_wide/image.png
90 | #MEDIAWIKI_LOGO_LEGACY2X: /images/d/d5/Ubcwiki_logo_2x.png
91 | PARSOID_DOMAIN: localhost
92 | RESTBASE_URL: http://nodeservices:7231
93 | #LDAP_DOMAIN=CWL
94 | #LDAP_SERVER=ldap
95 | #LDAP_ENCRYPTION_TYPE=clear
96 | #LDAP_SEARCH_ATTRS=cn
97 | #LDAP_PROXY_AGENT=cn=admin,dc=example,dc=org
98 | #LDAP_PROXY_PASSWORD=admin
99 | #LDAP_BASE_DN=dc=example,dc=org
100 | #LDAP_USER_BASE_DN=dc=example,dc=org
101 | #LDAP_USERNAME_ATTR=cn
102 | #LDAP_REALNAME_ATTR=displayname
103 | #LDAP_EMAIL_ATTR=mail
104 | #UBC_AUTH_ENABLED=true
105 | # FIXME skip domain checking in Parsoid. used in our own ParsoidHandler_custom_xxxx.php.
106 | # in our Apache conf file, we are redirecting requests to restbase with domain "localhost",
107 | # but the Parsoid domain is not configurable. hence disable the check.
108 | PARSOID_SKIP_DOAMIN_CHECK: true
109 | AUTO_CREATED_USER_REDIRECT: UBC_Wiki:Welcome
110 | AUTO_BLOCKED_USER_REDIRECT: UBC_Wiki:Blocked
111 | # use Redis for cache
112 | #MEDIAWIKI_MAIN_CACHE: redis
113 | #MEDIAWIKI_REDIS_HOST: redis
114 | #MEDIAWIKI_REDIS_PORT: 6379
115 | #MEDIAWIKI_REDIS_PASSWORD:
116 | #MEDIAWIKI_REDIS_PERSISTENT: true
117 | # Use Memcache for cache
118 | MEDIAWIKI_MAIN_CACHE: CACHE_MEMCACHED
119 | MEDIAWIKI_MEMCACHED_SERVERS: '["memcached:11211"]'
120 | # Use nothing for cache
121 | #MEDIAWIKI_MAIN_CACHE: CACHE_NONE
122 | # uncomment to specify the wgUploadPath
123 | # MEDIAWIKI_UPLOAD_PATH:
124 | #GOOGLE_ANALYTICS_ID: UA-XXXXXXX-XX
125 | # GoogleAnalyticsMetrics: https://www.mediawiki.org/wiki/Extension:GoogleAnalyticsMetrics
126 | #GOOGLE_ANALYTICS_METRICS_ALLOWED:
127 | #GOOGLE_ANALYTICS_METRICS_PATH:
128 | #GOOGLE_ANALYTICS_METRICS_VIEWID:
129 | DEBUG: true
130 | # CALIPER_HOST: https://caliper.imsglobal.org/caliper/PUT_TEST_BEARER_TOKEN_HERE/message
131 | # CALIPER_API_KEY: PUT_TEST_BEARER_TOKEN_HERE
132 | # CALIPER_BASE_URL: http://localhost:8888/test_url/
133 | # CALIPER_LDAP_ACTOR_HOMEPAGE: http://media_wiki_ldap_homepage
134 | MEDIAWIKI_UPGRADE_KEY: upgrade
135 | MEMCACHED_SERVER: memcached
136 | SIMPLESAMLPHP_ENABLED: true
137 | UBC_AUTH_ENABLED: true
138 | <<: *simplesamlphpVars
139 | labels:
140 | - "traefik.enable=true"
141 | - "traefik.http.routers.wiki.rule=PathPrefix(`/`)"
142 | - "traefik.http.routers.wiki.entrypoints=wiki"
143 | job_runner:
144 | <<: *app
145 | command: php /var/www/html/maintenance/runJobs.php --wait
146 | ports:
147 | - 8081:80
148 | labels: []
149 |
150 | # use combined image for now
151 | # parsoid:
152 | # image: ubcctlt/parsoid
153 | # environment:
154 | # - MEDIAWIKI_API_URL=http://web/w/api.php
155 | # - MEDIAWIKI_DOMAIN=localhost
156 | # - MEDIAWIKI_PREFIX=localhost
157 | # restbase:
158 | # image: ubcctlt/restbase
159 | # environment:
160 | # - MEDIAWIKI_API_URL=http://web/w/api.php
161 | # - PARSOID_DOMAIN=localhost
162 | # - PARSOID_URL=http://parsoid:8000
163 | # parsoid is now integrated into mediawiki since 1.35
164 | # restbase is being deprecated
165 | # TODO: we might not need nodeservices anymore in the next lts
166 | nodeservices:
167 | image: ubcctlt/mediawiki-node-services
168 | ports:
169 | - 7231:7231
170 | environment:
171 | - MEDIAWIKI_API_URL=http://web/api.php
172 | - MEDIAWIKI_REST_URL=http://web/rest.php
173 | - LOG_LEVEL=debug
174 | volumes:
175 | - ./.data/services:/data
176 | traefik:
177 | image: traefik:v3.3
178 | command:
179 | - "--api.insecure=true"
180 | - "--providers.docker=true"
181 | - "--providers.docker.exposedbydefault=false"
182 | - "--entryPoints.wiki.address=:8080"
183 | - "--entryPoints.traefik.address=:8195" # dashboard and api port
184 | ports:
185 | - "8080:8080"
186 | - "8195:8195"
187 | volumes:
188 | - "/var/run/docker.sock:/var/run/docker.sock:ro"
189 | # restbase:
190 | # image: restbase
191 | # restart: always
192 | # ports:
193 | # - 7231:7231
194 | # environment:
195 | # - RB_CONF_NUM_WORKERS=0
196 | # - RB_CONF_DOMAIN_web=http://web/w/api.php
197 | # - RB_CONF_PARSOID_HOST=http://parsoid:8000
198 | # - RB_CONF_BASE_URI_TEMPLATE=http://web/api/rest_v1
199 | # - RB_CONF_API_URI_TEMPLATE=http://web/api.php
200 | # - RB_CONF_LOGGING_LEVEL=debug #trace
201 | # - RB_CONF_PDF_URI=http://pdf:3000
202 | # parsoid:
203 | # image: thenets/parsoid:0.10
204 | # ports:
205 | # - 8142:8000
206 | # environment:
207 | # - PARSOID_DOMAIN_web=http://web/api.php
208 | # - PARSOID_LOGGING_LEVEL=debug
209 | ldap:
210 | image: osixia/openldap:1.1.9
211 | command: --copy-service
212 | ports:
213 | - 1389:389
214 | volumes:
215 | - ./dev/ldapadd_ubcedu.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/ldapadd_ubcedu.ldif
216 | - ./.data/ldap:/var/lib/ldap
217 | - ./.data/slapd.d:/etc/ldap/slapd.d
218 | memcached:
219 | image: memcached:1.6-alpine
220 | # redis:
221 | # image: redis:6.0-alpine
222 |
223 | volumes:
224 | nslaveCache:
225 | simplesamlphp:
226 |
--------------------------------------------------------------------------------
/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | : ${MEDIAWIKI_SITE_NAME:=MediaWiki}
6 | : ${MEDIAWIKI_SITE_LANG:=en}
7 | : ${MEDIAWIKI_ADMIN_USER:=admin}
8 | : ${MEDIAWIKI_ADMIN_PASS:=admin12345}
9 | : ${MEDIAWIKI_DB_TYPE:=mysql}
10 | : ${MEDIAWIKI_ENABLE_SSL:=false}
11 | : ${MEDIAWIKI_UPDATE:=false}
12 |
13 | if [ -z "$MEDIAWIKI_DB_HOST" ]; then
14 | if [ -n "$MYSQL_PORT_3306_TCP_ADDR" ]; then
15 | MEDIAWIKI_DB_HOST=$MYSQL_PORT_3306_TCP_ADDR
16 | elif [ -n "$POSTGRES_PORT_5432_TCP_ADDR" ]; then
17 | MEDIAWIKI_DB_TYPE=postgres
18 | MEDIAWIKI_DB_HOST=$POSTGRES_PORT_5432_TCP_ADDR
19 | elif [ -n "$DB_PORT_3306_TCP_ADDR" ]; then
20 | MEDIAWIKI_DB_HOST=$DB_PORT_3306_TCP_ADDR
21 | elif [ -n "$DB_PORT_5432_TCP_ADDR" ]; then
22 | MEDIAWIKI_DB_TYPE=postgres
23 | MEDIAWIKI_DB_HOST=$DB_PORT_5432_TCP_ADDR
24 | else
25 | echo >&2 'error: missing MEDIAWIKI_DB_HOST environment variable'
26 | echo >&2 ' Did you forget to --link your database?'
27 | exit 1
28 | fi
29 | fi
30 |
31 | if [ -z "$RESTBASE_URL" ]; then
32 | export RESTBASE_URL=restbase-is-not-specified
33 | fi
34 |
35 | if [ -z "$MEDIAWIKI_DB_USER" ]; then
36 | if [ "$MEDIAWIKI_DB_TYPE" = "mysql" ]; then
37 | echo >&2 'info: missing MEDIAWIKI_DB_USER environment variable, defaulting to "root"'
38 | MEDIAWIKI_DB_USER=root
39 | elif [ "$MEDIAWIKI_DB_TYPE" = "postgres" ]; then
40 | echo >&2 'info: missing MEDIAWIKI_DB_USER environment variable, defaulting to "postgres"'
41 | MEDIAWIKI_DB_USER=postgres
42 | else
43 | echo >&2 'error: missing required MEDIAWIKI_DB_USER environment variable'
44 | exit 1
45 | fi
46 | fi
47 |
48 | if [ -z "$MEDIAWIKI_DB_PASSWORD" ]; then
49 | if [ -n "$MYSQL_ENV_MYSQL_ROOT_PASSWORD" ]; then
50 | MEDIAWIKI_DB_PASSWORD=$MYSQL_ENV_MYSQL_ROOT_PASSWORD
51 | elif [ -n "$POSTGRES_ENV_POSTGRES_PASSWORD" ]; then
52 | MEDIAWIKI_DB_PASSWORD=$POSTGRES_ENV_POSTGRES_PASSWORD
53 | elif [ -n "$DB_ENV_MYSQL_ROOT_PASSWORD" ]; then
54 | MEDIAWIKI_DB_PASSWORD=$DB_ENV_MYSQL_ROOT_PASSWORD
55 | elif [ -n "$DB_ENV_POSTGRES_PASSWORD" ]; then
56 | MEDIAWIKI_DB_PASSWORD=$DB_ENV_POSTGRES_PASSWORD
57 | else
58 | echo >&2 'error: missing required MEDIAWIKI_DB_PASSWORD environment variable'
59 | echo >&2 ' Did you forget to -e MEDIAWIKI_DB_PASSWORD=... ?'
60 | echo >&2
61 | echo >&2 ' (Also of interest might be MEDIAWIKI_DB_USER and MEDIAWIKI_DB_NAME)'
62 | exit 1
63 | fi
64 | fi
65 |
66 | : ${MEDIAWIKI_DB_NAME:=mediawiki}
67 |
68 | if [ -z "$MEDIAWIKI_DB_PORT" ]; then
69 | if [ -n "$MYSQL_PORT_3306_TCP_PORT" ]; then
70 | MEDIAWIKI_DB_PORT=$MYSQL_PORT_3306_TCP_PORT
71 | elif [ -n "$POSTGRES_PORT_5432_TCP_PORT" ]; then
72 | MEDIAWIKI_DB_PORT=$POSTGRES_PORT_5432_TCP_PORT
73 | elif [ -n "$DB_PORT_3306_TCP_PORT" ]; then
74 | MEDIAWIKI_DB_PORT=$DB_PORT_3306_TCP_PORT
75 | elif [ -n "$DB_PORT_5432_TCP_PORT" ]; then
76 | MEDIAWIKI_DB_PORT=$DB_PORT_5432_TCP_PORT
77 | elif [ "$MEDIAWIKI_DB_TYPE" = "mysql" ]; then
78 | MEDIAWIKI_DB_PORT="3306"
79 | elif [ "$MEDIAWIKI_DB_TYPE" = "postgres" ]; then
80 | MEDIAWIKI_DB_PORT="5432"
81 | fi
82 | fi
83 |
84 | # Wait for the DB to come up
85 | while [ `/bin/nc -w 1 $MEDIAWIKI_DB_HOST $MEDIAWIKI_DB_PORT < /dev/null > /dev/null; echo $?` != 0 ]; do
86 | echo "Waiting for database to come up at $MEDIAWIKI_DB_HOST:$MEDIAWIKI_DB_PORT..."
87 | sleep 1
88 | done
89 |
90 | export MEDIAWIKI_DB_TYPE MEDIAWIKI_DB_HOST MEDIAWIKI_DB_USER MEDIAWIKI_DB_PASSWORD MEDIAWIKI_DB_NAME
91 |
92 | TERM=dumb php -- <<'EOPHP'
93 | connect_error) {
101 | file_put_contents('php://stderr', 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
102 | exit(1);
103 | }
104 |
105 | if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($_ENV['MEDIAWIKI_DB_NAME']) . '`')) {
106 | file_put_contents('php://stderr', 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
107 | }
108 |
109 | $mysql->close();
110 | }
111 | EOPHP
112 |
113 | cd /var/www/html
114 |
115 | : ${MEDIAWIKI_SHARED:=/data}
116 | if [ ! -d "$MEDIAWIKI_SHARED" ]; then
117 | mkdir -p $MEDIAWIKI_SHARED
118 | fi
119 | mkdir -p "$MEDIAWIKI_SHARED/images"
120 |
121 | # If the images directory only contains a README, then link it to
122 | # $MEDIAWIKI_SHARED/images, creating the shared directory if necessary
123 | if [ "$(ls images)" = "README" -a ! -L images ]; then
124 | rm -fr images
125 | ln -s "$MEDIAWIKI_SHARED/images" images
126 | fi
127 |
128 | # If an extensions folder exists inside the shared directory, as long as
129 | # /var/www/html/extensions is not already a symbolic link, then replace it
130 | if [ -d "$MEDIAWIKI_SHARED/extensions" -a ! -h /var/www/html/extensions ]; then
131 | echo >&2 "Found 'extensions' folder in data volume, creating symbolic link."
132 | rm -rf /var/www/html/extensions
133 | ln -s "$MEDIAWIKI_SHARED/extensions" /var/www/html/extensions
134 | fi
135 |
136 | # If a skins folder exists inside the shared directory, as long as
137 | # /var/www/html/skins is not already a symbolic link, then replace it
138 | if [ -d "$MEDIAWIKI_SHARED/skins" -a ! -h /var/www/html/skins ]; then
139 | echo >&2 "Found 'skins' folder in data volume, creating symbolic link."
140 | rm -rf /var/www/html/skins
141 | ln -s "$MEDIAWIKI_SHARED/skins" /var/www/html/skins
142 | fi
143 |
144 | # If a vendor folder exists inside the shared directory, as long as
145 | # /var/www/html/vendor is not already a symbolic link, then replace it
146 | if [ -d "$MEDIAWIKI_SHARED/vendor" -a ! -h /var/www/html/vendor ]; then
147 | echo >&2 "Found 'vendor' folder in data volume, creating symbolic link."
148 | rm -rf /var/www/html/vendor
149 | ln -s "$MEDIAWIKI_SHARED/vendor" /var/www/html/vendor
150 | fi
151 |
152 | # Attempt to enable SSL support if explicitly requested
153 | if [ $MEDIAWIKI_ENABLE_SSL = true ]; then
154 | if [ ! -f $MEDIAWIKI_SHARED/ssl.key -o ! -f $MEDIAWIKI_SHARED/ssl.crt -o ! -f $MEDIAWIKI_SHARED/ssl.bundle.crt ]; then
155 | echo >&2 'error: Detected MEDIAWIKI_ENABLE_SSL flag but found no data volume';
156 | echo >&2 ' Did you forget to mount the volume with -v?'
157 | exit 1
158 | fi
159 | echo >&2 'info: enabling ssl'
160 | a2enmod ssl
161 |
162 | cp "$MEDIAWIKI_SHARED/ssl.key" /etc/apache2/ssl.key
163 | cp "$MEDIAWIKI_SHARED/ssl.crt" /etc/apache2/ssl.crt
164 | cp "$MEDIAWIKI_SHARED/ssl.bundle.crt" /etc/apache2/ssl.bundle.crt
165 | elif [ -e "/etc/apache2/mods-enabled/ssl.load" ]; then
166 | echo >&2 'warning: disabling ssl'
167 | a2dismod ssl
168 | fi
169 |
170 | # If there is no LocalSettings.php, create one using maintenance/install.php
171 | if [ ! -e "$MEDIAWIKI_SHARED/installed" -a ! -f "$MEDIAWIKI_SHARED/install.lock" ]; then
172 | touch $MEDIAWIKI_SHARED/install.lock
173 | mv LocalSettings.php LocalSettings.php.bak
174 | php maintenance/install.php \
175 | --confpath /var/www/html \
176 | --dbname "$MEDIAWIKI_DB_NAME" \
177 | --dbport "$MEDIAWIKI_DB_PORT" \
178 | --dbserver "$MEDIAWIKI_DB_HOST" \
179 | --dbtype "$MEDIAWIKI_DB_TYPE" \
180 | --dbuser "$MEDIAWIKI_DB_USER" \
181 | --dbpass "$MEDIAWIKI_DB_PASSWORD" \
182 | --installdbuser "$MEDIAWIKI_DB_USER" \
183 | --installdbpass "$MEDIAWIKI_DB_PASSWORD" \
184 | --server "$MEDIAWIKI_SITE_SERVER" \
185 | --scriptpath "" \
186 | --lang "$MEDIAWIKI_SITE_LANG" \
187 | --pass "$MEDIAWIKI_ADMIN_PASS" \
188 | --with-extensions \
189 | "$MEDIAWIKI_SITE_NAME" \
190 | "$MEDIAWIKI_ADMIN_USER"
191 |
192 | touch $MEDIAWIKI_SHARED/installed
193 | mv LocalSettings.php.bak LocalSettings.php
194 | # run update.php as extensions need to create tables
195 | php maintenance/update.php --quick
196 | rm $MEDIAWIKI_SHARED/install.lock
197 | fi
198 |
199 | # TODO: Is this necessary?
200 | # Install extensions
201 | if [[ $MEDIAWIKI_EXTENSIONS ]]; then
202 | echo " CustomExtensions.php
203 | IFS="," read -ra exts <<< "$MEDIAWIKI_EXTENSIONS"
204 | for i in "${exts[@]}"; do
205 | if [[ -f /var/www/html/extensions/$i/extension.json ]]; then
206 | echo "wfLoadExtension('$i');" >> CustomExtensions.php
207 | fi
208 | done
209 | fi
210 |
211 | # If a composer.lock and composer.json file exist, use them to install
212 | # dependencies for MediaWiki and desired extensions, skins, etc.
213 | if [ -e "$MEDIAWIKI_SHARED/composer.lock" -a -e "$MEDIAWIKI_SHARED/composer.json" ]; then
214 | curl -sS https://getcomposer.org/installer | php
215 | cp "$MEDIAWIKI_SHARED/composer.lock" composer.lock
216 | cp "$MEDIAWIKI_SHARED/composer.json" composer.json
217 | php composer.phar install --no-dev
218 | fi
219 |
220 | # If LocalSettings.php exists, then attempt to run the update.php maintenance
221 | # script. If already up to date, it won't do anything, otherwise it will
222 | # migrate the database if necessary on container startup. It also will
223 | # verify the database connection is working.
224 | if [ -e "LocalSettings.php" -a "$MEDIAWIKI_UPDATE" = 'true' -a ! -f "$MEDIAWIKI_SHARED/update.lock" ]; then
225 | touch $MEDIAWIKI_SHARED/update.lock
226 | echo >&2 'info: Running maintenance/update.php';
227 | php maintenance/update.php --quick --conf ./LocalSettings.php
228 | rm $MEDIAWIKI_SHARED/update.lock
229 | fi
230 |
231 | # Run custom startup tasks
232 | chmod 755 /startuptasks.sh
233 | /startuptasks.sh
234 |
235 | # Ensure images folder exists
236 | mkdir -p images
237 |
238 | # Fix file ownership and permissions
239 | #chown -R www-data: . # takes long time to exec in k8s, plus it's not good to set everything owned by web user
240 | chown -R www-data: cache
241 | chmod 755 images
242 |
243 |
244 | exec "$@"
245 |
--------------------------------------------------------------------------------
/CustomSettings.php:
--------------------------------------------------------------------------------
1 | true,
274 | NS_USER => true,
275 | NS_HELP => true,
276 | NS_COURSE => true,
277 | NS_COURSE_TALK => true,
278 | NS_THREAD => true,
279 | NS_SUMMARY => true,
280 | NS_DOCUMENTATION => true,
281 | NS_FILE => true,
282 | NS_CATEGORY => true,
283 | NS_YOUTUBE => true,
284 | NS_ELEARNING => true,
285 | NS_LIBRARY => true,
286 | NS_NOTEPAD => true,
287 | NS_ARTS => true,
288 | NS_LEARNINGCOMMONS => true,
289 | NS_LFS => true,
290 | NS_SCIENCE => true,
291 | NS_COURSE => true,
292 | );
293 | #####################
294 | ## End Namepsace Area
295 | #####################
296 |
297 | $wgAllowExternalImages = true;
298 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MediaWiki Docker Image
2 |
3 | This repo is largely based on MediaWiki offical [docker repo](https://github.com/wikimedia/mediawiki-docker).
4 |
5 | The changes are:
6 |
7 | * Used "Vector" skin by default
8 | * Used PHP-Apache docker image as base
9 | * Used stable version of MediaWiki
10 | * Customized for the production use
11 |
12 | ## Configuration options
13 |
14 | Use the following environmental variables to generate a `LocalSettings.php` and perform automatic installation of MediaWiki. If you don't include these, you'll need to go through the installation wizard. See `Installation Wizard` below for more details. Please see [Manual:Configuration_settings](https://www.mediawiki.org/wiki/Manual:Configuration_settings) for details about what these configuration variables do.
15 |
16 | - `-e MEDIAWIKI_SITE_SERVER=` (**required** set this to the server host and include the protocol (and port if necessary) like `http://my-wiki:8080`; configures `$wgServer`)
17 | - `-e MEDIAWIKI_SITE_NAME=` (defaults to `MediaWiki`; configures `$wgSitename`)
18 | - `-e MEDIAWIKI_SITE_LANG=` (defaults to `en`; configures `$wgLanguageCode`)
19 | - `-e MEDIAWIKI_ADMIN_USER=` (defaults to `admin`; configures default administrator username)
20 | - `-e MEDIAWIKI_ADMIN_PASS=` (defaults to `rosebud`; configures default administrator password)
21 | - `-e MEDIAWIKI_UPDATE=true` (defaults to `false`; run `php maintenance/update.php`)
22 | - `-e MEDIAWIKI_SLEEP=` (defaults to `0`; delays startup of container, useful when using Docker Compose)
23 | - `-e MEDIAWIKI_EXTENSIONS` (defaults to empty; specify which extensions to enable, comma separated. Extensions are installed through docker image build)
24 | - `-e PARSOID_DOMAIN` (defaults to `localhost`, parsoid domain)
25 | - `-e RESTBASE_URL` (defaults not set, RestBase instance URL, if not set, no RestBase will be configured)
26 | - `-e LDAP_DOMAIN` (defaults not set, LDAP domain, e.g. CWL)
27 | - `-e LDAP_SERVER` (defaults not set, LDAP server address)
28 | - `-e LDAP_PORT` (defaults to `389`, LDAP server port)
29 | - `-e LDAP_ENCRYPTION_TYPE` (defaults to `clear`, LDAP connection encryption type, possible values are `clear`, `ldapi`, `tls` and `ssl`)
30 | - `-e LDAP_BASE_DN` (defaults to `ou=Users,ou=LOCAL,dc=domain,dc=local`, LDAP base DN for searching)
31 | - `-e LDAP_USER_BASE_DN` (defaults to `ou=Users,ou=LOCAL,dc=domain,dc=local`, LDAP base DN for user info)
32 | - `-e LDAP_SEARCH_STRINGS` (defaults not set, LDAP search string)
33 | - `-e LDAP_SEARCH_ATTRS` (defaults not set, LDAP search attribute)
34 | - `-e LDAP_PROXY_AGENT` (defaults not set, LDAP proxy agent)
35 | - `-e LDAP_PROXY_PASSWORD` (defaults not set, LDAP proxy agent password)
36 | - `-e LDAP_USERNAME_ATTR` (defaults to `cn`, LDAP attribute for user name)
37 | - `-e LDAP_REALNAME_ATTR` (defaults to `displayname`, LDAP attribute for real name)
38 | - `-e LDAP_EMAIL_ATTR` (defaults to `mail`, LDAP attribute for for email address)
39 | - `-e MEDIAWIKI_MAIN_CACHE` (defaults to `CACHE_NONE`, main cache)
40 | - `-e MEDIAWIKI_MEMCACHED_SERVERS` (defaults to `[]`, list of memcched servers, comma separated, e.g.["memcached:11211", "memcached1:11211"])
41 | - `-e UBC_AUTH` (defaults not set. Set o `true` to enable the UBC-specific authentication extension)
42 | - `-e AUTO_CREATED_USER_REDIRECT` (defaults not set. Set it to a wiki page [e.g. `Main_page`] to redirect new users to a specific page when they first login via LDAP)
43 |
44 | As mentioned, this will generate the `LocalSettings.php` file that is required by MediaWiki. If you mounted a shared volume (see `Shared Volume` below), the generated `LocalSettings.php` will be automatically moved to your share volume allowing you to edit it. If a `CustomSettings.php` file exists in your data file, a `require('/data/CustomSettings.php');` will be appended to the generated `LocalSettings.php` file.
45 |
46 | ## Docker Compose
47 |
48 | ```bash
49 | docker-compose up
50 | ```
51 | Customization can be done through the environment variables in `docker-compose.yaml`.
52 |
53 | ### Using Database Server
54 |
55 | You can use the following environment variables for connecting to another database server:
56 |
57 | - `-e MEDIAWIKI_DB_TYPE=...` (defaults to `mysql`, but can also be `postgres`)
58 | - `-e MEDIAWIKI_DB_HOST=...` (defaults to the address of the linked database container)
59 | - `-e MEDIAWIKI_DB_PORT=...` (defaults to the port of the linked database container or to the default for specified db type)
60 | - `-e MEDIAWIKI_DB_USER=...` (defaults to `root` or `postgres` based on db type being `mysql`, or `postgres` respsectively)
61 | - `-e MEDIAWIKI_DB_PASSWORD=...` (defaults to the password of the linked database container)
62 | - `-e MEDIAWIKI_DB_NAME=...` (defaults to `mediawiki`)
63 | - `-e MEDIAWIKI_DB_SCHEMA`... (defaults to `mediawiki`, applies only to when using postgres)
64 |
65 | If the `MEDIAWIKI_DB_NAME` specified does not already exist on the provided MySQL
66 | server, it will be created automatically upon container startup, provided
67 | that the `MEDIAWIKI_DB_USER` specified has the necessary permissions to create
68 | it.
69 |
70 | To use with an external database server, use `MEDIAWIKI_DB_HOST` (along with
71 | `MEDIAWIKI_DB_USER` and `MEDIAWIKI_DB_PASSWORD` if necessary):
72 |
73 | docker run --name some-mediawiki \
74 | -e MEDIAWIKI_DB_HOST=10.0.0.1
75 | -e MEDIAWIKI_DB_PORT=3306 \
76 | -e MEDIAWIKI_DB_USER=app \
77 | -e MEDIAWIKI_DB_PASSWORD=secure \
78 | wikimedia/mediawiki
79 |
80 | ## Shared Volume
81 |
82 | If provided mount a shared volume using the `-v` argument when running `docker run`, the mediawiki container will automatically look for a `LocalSettings.php` file and `images`, `skins` and `extensions` folders. When found symbolic links will be automatically created to the respsective file or folder to replace the ones included with the default MediaWiki install. This allows you to easily configure (`LocalSettings.php`), backup uploaded files (`images`), and customize (`skins` and `extensions`) your instance of MediaWiki.
83 |
84 | It is highly recommend you mount a shared volume so uploaded files and images will be outside of the docker container.
85 |
86 | By default the shared volume must be mounted to `/data` on the container, you can change this using by using `-e MEDIAWIKI_SHARED=/new/data/path`.
87 |
88 | Additionally if a `composer.lock` **and** a `composer.json` are detected, the container will automatically download [composer](https://getcomposer.org) and run `composer install`. Composer can be used to install additional extensions, skins and dependencies.
89 |
90 | ## Accessing MediaWiki
91 |
92 | Access it via `http://localhost:8080` or `http://host-ip:8080` in a browser.
93 |
94 | Database frontend Adminer is available at `http://localhost:8089`.
95 |
96 |
97 | ## Setting up instance for development
98 |
99 | First startup the application for the first time with:
100 |
101 | ```bash
102 | docker-compose up -d
103 | ```
104 |
105 | Next after startup run the following to add `the user_cwl_extended_account_data` table
106 |
107 | ```bash
108 | docker cp ./dev/add_table.sql mediawiki-docker_db_1:/add_table.sql
109 | docker exec -it mediawiki-docker_db_1 /bin/bash -c "mysql -u root -ppassword mediawiki < /add_table.sql"
110 | ```
111 |
112 | Next you need to uncomment the line `- ./LocalSettings.php:/var/www/html/LocalSettings.php` in the docker compose file.
113 |
114 | Finally restart all the containers with:
115 |
116 | ```bash
117 | docker-compose down
118 | docker-compose up -d
119 | ```
120 |
121 | ### Setting up SAML2 auth using the SimpleSAMLphp Extension.
122 |
123 | The dev docker compose configuration expects the wiki to be located at
124 | `wiki.docker` and the IDP to be located at `idp.docker`. This can be easily
125 | configured by editing the hosts file and mapping both `wiki.docker` and
126 | `idp.docker` to `127.0.0.1`.
127 |
128 | #### Generate Key & Cert
129 |
130 | **WARNING** the certs provided in `docker/simplesamlphp/sp/cert/` must NOT be
131 | used in any kind of prod environment. They are only there for easier setup of
132 | the docker compose dev environment.
133 |
134 | To generate your own cert and key:
135 |
136 | ```bash
137 | openssl req -newkey rsa:4096 -new -x509 -days 3652 -nodes -out wiki-sp.crt -keyout wiki-sp.pem
138 | ```
139 |
140 | The key and cert can replace the ones in `docker/simplesamlphp/sp/cert/` which
141 | will get mounted into the simplesamlphp container's
142 | /var/www/simplesamlphp/cert/ directory.
143 |
144 | #### SP Required Environment Variables
145 |
146 | Deployment of the SimpleSAMLphp SP is required if you want to use the
147 | SimpleSAMLphp extension. Note the IDP provided in docker compose is only for
148 | development purposes.
149 |
150 | The SP pulls metadata from the target IDP's metadata URL.
151 |
152 | Required SP environment variables:
153 |
154 | * SIMPLESAMLPHP_SECRET_SALT - Cryptographically secured random string used for salting purposes.
155 | * SIMPLESAMLPHP_ADMIN_PASSWORD - Password for the default admin user.
156 | * SIMPLESAMLPHP_MEMCACHED_SERVER - SimpleSAMLphp's SP cannot use the cookie cache as the wiki side SimpleSAMLphp extension will conflict with it. So we need to use a separate cache. For this purpose, we can just use the same Memcached server that the wiki uses.
157 | * SIMPLESAMLPHP_TRUSTED_DOMAIN - Enter the wiki's domain here so that the SP knows it is safe.
158 | * SIMPLESAMLPHP_BASEURL - Base URL for the SP (no path). The SP needs to share the same domain as the wiki (or you run into cookie domain issues), so the base URL should just be the wiki domain with an http:// or https:// prefix. This config lets SimpleSAMLphp knows it's running externally on https even if internally the backend server is plain http, such as when behind a load balancer/reverse proxy.
159 | * SIMPLESAMLPHP_BASEURLPATH - Base URL plus the path for the SP.
160 | * SIMPLESAMLPHP_SP_ENTITY_ID - The identifier that the SP uses to identify itself
161 | * SIMPLESAMLPHP_IDP_ENTITY_ID - The target IDP's identifier.
162 | * SIMPLESAMLPHP_IDP_METADATA_URL - URL where we can get the IDP's metadata.
163 | * SIMPLESAMLPHP_CRON_SECRET - Random alphanumeric string for cron security.
164 |
165 | Optional SP environment variables:
166 |
167 | * SIMPLESAMLPHP_DEV - This turns on dev mode which enables the admin interface at `/module.php/admin/`. It also allows SIMPLESAMLPHP_SECRET_SALT to default to 'secretsalt' if unset and SIMPLESAMLPHP_ADMIN_PASSWORD to default to 'admin' if unset.
168 |
169 | ### Adding new LDAP users
170 |
171 | You can connect to the LDAP container using your preferred LDAP GUI using `localhost:1389` with login `cn=admin,dc=example,dc=org` and password `admin`.
172 |
173 | When adding a new user, make sure to use `simpleSecurityObject`, `inetOrgPerson`, and `ubcEdu` classes.
174 |
175 | ## Customization with LDAP authentication enabled
176 |
177 | Customize the login button by modifying the page `MediaWiki:Pluggableauth-loginbutton-label`. The default is "Log in with PluggableAuth".
178 |
179 | Customize the login help message by modifying the page `MediaWiki:Userlogin-helplink2` and `MediaWiki:Helplogin-url`. The default is a hyperlink "Help with logging in" that links to mediawiki help page.
180 |
181 | Customize the help message on `Preferences` page about email addresses by editing the page `MediaWiki:Prefs-help-email`. The default help messages mentioned email addresses are used for password reset, which is irrelevant if mediawiki is setup with LDAP authentication.
182 |
183 | ## Custom Caliper actor data
184 |
185 | See the [mediawiki-extensions-caliper](https://github.com/ubc/mediawiki-extensions-caliper/blob/master/caliper/actor.php) repo's `CaliperActor` object for the default logged in and logged out users.
186 |
187 | You can customize the Caliper actor by using the `SetCaliperActorObject` hook. This container has uses this hook with the `SetCaliperActor` function inside of `CustomHooks.php`.
188 |
189 | By default, the `SetCaliperActor` function will use UBC `puid` for the identifier and `CALIPER_LDAP_ACTOR_HOMEPAGE` environment variable as the base string so the actor identifier will take the form of `CaliperLDAPActorHomepage/LDAP_PUID` (ex: `https://www.ubc.ca/SOME_PUID`). you can instead remove this function and create your own depending on your institution needs, deployment settings, and/or authorization methods.
190 |
191 | ## Debugging with Containers
192 |
193 | To change the files in container:
194 | ```bash
195 | docker exec -it CONTAINER_ID share
196 | vi FILE_TO_CHANGE
197 | ```
198 | You may need to restart the container to load the change, use:
199 | ```bash
200 | docker-compose restart SERIVCE_NAME
201 | ```
202 | where the SERIVCE_NAME can be any service in docker-compose, e.g. nodeservices, web, db, etc. The changes in the container will persist.
203 |
204 | ## Version and Release Tags
205 |
206 | The `REL*` branches track the upstream Mediawiki released versions. When something is updated in this repo and is ready to be deployed, a new tag should be created and the tag name should in the format of `BRANCH_NAME + BUILD NUMBER`, e.g. REL1_30_B2 or REL1_31_B5. The `BUILD_NUMBER` should be increased sequentially.
207 |
208 | The same rules apply to node-services repo as well.
209 |
210 | ## Upgrading
211 |
212 | When upgrading to a newer version, we can run the web updater, this requires
213 | setting an upgrade key. A default upgrade key with value 'value' is set in
214 | docker-compose.yml
215 |
216 | http://localhost:8080/mw-config/index.php?page=Upgrade
217 |
218 | There is also an maintenance update script that must be run, this can be done manually:
219 |
220 | php maintenance/update.php
221 |
222 | Alternatively, setting the env var `MEDIAWIKI_UPDATE` to true will run the
223 | maintenance update script on container startup.
224 |
225 | ## Admin Access
226 |
227 | Promote a existing user to have all admin permissions:
228 |
229 | php maintenance/createAndPromote.php Admin1 --force --bureaucrat --sysop --interface-admin
230 |
--------------------------------------------------------------------------------
/docker/simplesamlphp/sp/config/authsources.php:
--------------------------------------------------------------------------------
1 | [
25 | // The default is to use core:AdminPassword, but it can be replaced with
26 | // any authentication source.
27 |
28 | 'core:AdminPassword',
29 | ],
30 |
31 |
32 | // An authentication source which can authenticate against SAML 2.0 IdPs.
33 | 'wiki-sp' => [
34 | 'saml:SP',
35 |
36 | // The entity ID of this SP.
37 | 'entityID' => $_ENV['SIMPLESAMLPHP_SP_ENTITY_ID'],
38 |
39 | // The entity ID of the IdP this SP should contact.
40 | // Can be NULL/unset, in which case the user will be shown a list of available IdPs.
41 | 'idp' => $_ENV['SIMPLESAMLPHP_IDP_ENTITY_ID'],
42 |
43 | // The URL to the discovery service.
44 | // Can be NULL/unset, in which case a builtin discovery service will be used.
45 | 'discoURL' => null,
46 |
47 | 'privatekey' => 'wiki-sp.pem',
48 | 'certificate' => 'wiki-sp.crt',
49 |
50 | /*
51 | * If SP behind the SimpleSAMLphp in IdP/SP proxy mode requests
52 | * AuthnContextClassRef, decide whether the AuthnContextClassRef will be
53 | * processed by the IdP/SP proxy or if it will be passed to the original
54 | * IdP in front of the IdP/SP proxy.
55 | */
56 | 'proxymode.passAuthnContextClassRef' => false,
57 |
58 | /*
59 | * The attributes parameter must contain an array of desired attributes by the SP.
60 | * The attributes can be expressed as an array of names or as an associative array
61 | * in the form of 'friendlyName' => 'name'. This feature requires 'name' to be set.
62 | * The metadata will then be created as follows:
63 | *
64 | */
65 | /*
66 | 'name' => [
67 | 'en' => 'A service',
68 | 'no' => 'En tjeneste',
69 | ],
70 |
71 | 'attributes' => [
72 | 'attrname' => 'urn:oid:x.x.x.x',
73 | ],
74 | 'attributes.required' => [
75 | 'urn:oid:x.x.x.x',
76 | ],
77 | */
78 |
79 | // IDP message security error on singlelogout without this
80 | 'sign.logout' => true,
81 | ],
82 |
83 |
84 | /*
85 | 'example-sql' => [
86 | 'sqlauth:SQL',
87 | 'dsn' => 'pgsql:host=sql.example.org;port=5432;dbname=simplesaml',
88 | 'username' => 'simplesaml',
89 | 'password' => 'secretpassword',
90 | 'query' => 'SELECT uid, givenName, email, eduPersonPrincipalName FROM users WHERE uid = :username ' .
91 | 'AND password = SHA2(CONCAT((SELECT salt FROM users WHERE uid = :username), :password), 256);',
92 | ],
93 | */
94 |
95 | /*
96 | 'example-static' => [
97 | 'exampleauth:StaticSource',
98 | 'uid' => ['testuser'],
99 | 'eduPersonAffiliation' => ['member', 'employee'],
100 | 'cn' => ['Test User'],
101 | ],
102 | */
103 |
104 | /*
105 | 'example-userpass' => [
106 | 'exampleauth:UserPass',
107 |
108 | // Give the user an option to save their usernamehttp://idp.docker:6102 for future login attempts
109 | // And when enabled, what should the default be, to save the username or not
110 | //'remember.username.enabled' => false,
111 | //'remember.username.checked' => false,
112 |
113 | 'users' => [
114 | 'student:studentpass' => [
115 | 'uid' => ['test'],
116 | 'eduPersonAffiliation' => ['member', 'student'],
117 | ],
118 | 'employee:employeepass' => [
119 | 'uid' => ['employee'],
120 | 'eduPersonAffiliation' => ['member', 'employee'],
121 | ],
122 | ],
123 | ],
124 | */
125 |
126 | /*
127 | 'crypto-hash' => [
128 | 'authcrypt:Hash',
129 | // hashed version of 'verysecret', made with bin/pwgen.php
130 | 'professor:{SSHA256}P6FDTEEIY2EnER9a6P2GwHhI5JDrwBgjQ913oVQjBngmCtrNBUMowA==' => [
131 | 'uid' => ['prof_a'],
132 | 'eduPersonAffiliation' => ['member', 'employee', 'board'],
133 | ],
134 | ],
135 | */
136 |
137 | /*
138 | 'htpasswd' => [
139 | 'authcrypt:Htpasswd',
140 | 'htpasswd_file' => '/var/www/foo.edu/legacy_app/.htpasswd',
141 | 'static_attributes' => [
142 | 'eduPersonAffiliation' => ['member', 'employee'],
143 | 'Organization' => ['University of Foo'],
144 | ],
145 | ],
146 | */
147 |
148 | /*
149 | // This authentication source serves as an example of integration with an
150 | // external authentication engine. Take a look at the comment in the beginning
151 | // of modules/exampleauth/lib/Auth/Source/External.php for a description of
152 | // how to adjust it to your own site.
153 | 'example-external' => [
154 | 'exampleauth:External',
155 | ],
156 | */
157 |
158 | /*
159 | 'yubikey' => [
160 | 'authYubiKey:YubiKey',
161 | 'id' => '000',
162 | // 'key' => '012345678',
163 | ],
164 | */
165 |
166 | /*
167 | 'facebook' => [
168 | 'authfacebook:Facebook',
169 | // Register your Facebook application on http://www.facebook.com/developers
170 | // App ID or API key (requests with App ID should be faster; https://github.com/facebook/php-sdk/issues/214)
171 | 'api_key' => 'xxxxxxxxxxxxxxxx',
172 | // App Secret
173 | 'secret' => 'xxxxxxxxxxxxxxxx',
174 | // which additional data permissions to request from user
175 | // see http://developers.facebook.com/docs/authentication/permissions/ for the full list
176 | // 'req_perms' => 'email,user_birthday',
177 | // Which additional user profile fields to request.
178 | // When empty, only the app-specific user id and name will be returned
179 | // See https://developers.facebook.com/docs/graph-api/reference/v2.6/user for the full list
180 | // 'user_fields' => 'email,birthday,third_party_id,name,first_name,last_name',
181 | ],
182 | */
183 |
184 | /*
185 | // Twitter OAuth Authentication API.
186 | // Register your application to get an API key here:
187 | // http://twitter.com/oauth_clients
188 | 'twitter' => [
189 | 'authtwitter:Twitter',
190 | 'key' => 'xxxxxxxxxxxxxxxx',
191 | 'secret' => 'xxxxxxxxxxxxxxxx',
192 | // Forces the user to enter their credentials to ensure the correct users account is authorized.
193 | // Details: https://dev.twitter.com/docs/api/1/get/oauth/authenticate
194 | 'force_login' => false,
195 | ],
196 | */
197 |
198 | /*
199 | // Microsoft Account (Windows Live ID) Authentication API.
200 | // Register your application to get an API key here:
201 | // https://apps.dev.microsoft.com/
202 | 'windowslive' => [
203 | 'authwindowslive:LiveID',
204 | 'key' => 'xxxxxxxxxxxxxxxx',
205 | 'secret' => 'xxxxxxxxxxxxxxxx',
206 | ],
207 | */
208 |
209 | /*
210 | // Example of a LDAP authentication source.
211 | 'example-ldap' => [
212 | 'ldap:Ldap',
213 |
214 | // The connection string for the LDAP-server.
215 | // You can add multiple by separating them with a space.
216 | 'connection_string' => 'ldap.example.org',
217 |
218 | // Whether SSL/TLS should be used when contacting the LDAP server.
219 | // Possible values are 'ssl', 'tls' or 'none'
220 | 'encryption' => 'ssl',
221 |
222 | // The LDAP version to use when interfacing the LDAP-server.
223 | // Defaults to 3
224 | 'version' => 3,
225 |
226 | // Set to TRUE to enable LDAP debug level. Passed to the LDAP connector class.
227 | //
228 | // Default: FALSE
229 | // Required: No
230 | 'ldap.debug' => false,
231 |
232 | // The LDAP-options to pass when setting up a connection
233 | // See [Symfony documentation][1]
234 | 'options' => [
235 |
236 | // Set whether to follow referrals.
237 | // AD Controllers may require 0x00 to function.
238 | // Possible values are 0x00 (NEVER), 0x01 (SEARCHING),
239 | // 0x02 (FINDING) or 0x03 (ALWAYS).
240 | 'referrals' => 0x00,
241 |
242 | 'network_timeout' => 3,
243 | ],
244 |
245 | // The connector to use.
246 | // Defaults to '\SimpleSAML\Module\ldap\Connector\Ldap', but can be set
247 | // to '\SimpleSAML\Module\ldap\Connector\ActiveDirectory' when
248 | // authenticating against Microsoft Active Directory. This will
249 | // provide you with more specific error messages.
250 | 'connector' => '\SimpleSAML\Module\ldap\Connector\Ldap',
251 |
252 | // Which attributes should be retrieved from the LDAP server.
253 | // This can be an array of attribute names, or NULL, in which case
254 | // all attributes are fetched.
255 | 'attributes' => null,
256 |
257 | // Which attributes should be base64 encoded after retrieval from
258 | // the LDAP server.
259 | 'attributes.binary' => [
260 | 'jpegPhoto',
261 | 'objectGUID',
262 | 'objectSid',
263 | 'mS-DS-ConsistencyGuid'
264 | ],
265 |
266 | // The pattern which should be used to create the user's DN given
267 | // the username. %username% in this pattern will be replaced with
268 | // the user's username.
269 | //
270 | // This option is not used if the search.enable option is set to TRUE.
271 | 'dnpattern' => 'uid=%username%,ou=people,dc=example,dc=org',
272 |
273 | // As an alternative to specifying a pattern for the users DN, it is
274 | // possible to search for the username in a set of attributes. This is
275 | // enabled by this option.
276 | 'search.enable' => false,
277 |
278 | // An array on DNs which will be used as a base for the search. In
279 | // case of multiple strings, they will be searched in the order given.
280 | 'search.base' => [
281 | 'ou=people,dc=example,dc=org',
282 | ],
283 |
284 | // The scope of the search. Valid values are 'sub' and 'one' and
285 | // 'base', first one being the default if no value is set.
286 | 'search.scope' => 'sub',
287 |
288 | // The attribute(s) the username should match against.
289 | //
290 | // This is an array with one or more attribute names. Any of the
291 | // attributes in the array may match the value the username.
292 | 'search.attributes' => ['uid', 'mail'],
293 |
294 | // Additional filters that must match for the entire LDAP search to
295 | // be true.
296 | //
297 | // This should be a single string conforming to [RFC 1960][2]
298 | // and [RFC 2544][3]. The string is appended to the search attributes
299 | 'search.filter' => '(&(objectClass=Person)(|(sn=Doe)(cn=John *)))',
300 |
301 | // The username & password where SimpleSAMLphp should bind to before
302 | // searching. If this is left NULL, no bind will be performed before
303 | // searching.
304 | 'search.username' => null,
305 | 'search.password' => null,
306 | ],
307 | */
308 |
309 | /*
310 | // Example of an LDAPMulti authentication source.
311 | 'example-ldapmulti' => [
312 | 'ldap:LdapMulti',
313 |
314 | // The way the organization as part of the username should be handled.
315 | // Three possible values:
316 | // - 'none': No handling of the organization. Allows '@' to be part
317 | // of the username.
318 | // - 'allow': Will allow users to type 'username@organization'.
319 | // - 'force': Force users to type 'username@organization'. The dropdown
320 | // list will be hidden.
321 | //
322 | // The default is 'none'.
323 | 'username_organization_method' => 'none',
324 |
325 | // Whether the organization should be included as part of the username
326 | // when authenticating. If this is set to TRUE, the username will be on
327 | // the form @. If this is FALSE, the
328 | // username will be used as the user enters it.
329 | //
330 | // The default is FALSE.
331 | 'include_organization_in_username' => false,
332 |
333 | // A list of available LDAP servers.
334 | //
335 | // The index is an identifier for the organization/group. When
336 | // 'username_organization_method' is set to something other than 'none',
337 | // the organization-part of the username is matched against the index.
338 | //
339 | // The value of each element is an array in the same format as an LDAP
340 | // authentication source.
341 | 'mapping' => [
342 | 'employees' => [
343 | // A short name/description for this group. Will be shown in a
344 | // dropdown list when the user logs on.
345 | //
346 | // This option can be a string or an array with
347 | // language => text mappings.
348 | 'description' => 'Employees',
349 | 'authsource' => 'example-ldap',
350 | ],
351 |
352 | 'students' => [
353 | 'description' => 'Students',
354 | 'authsource' => 'example-ldap-2',
355 | ],
356 | ],
357 | ],
358 | */
359 | ];
360 |
--------------------------------------------------------------------------------
/docker/simplesamlphp/idp/config/authsources.php:
--------------------------------------------------------------------------------
1 | [
18 | // The default is to use core:AdminPassword, but it can be replaced with
19 | // any authentication source.
20 |
21 | 'core:AdminPassword',
22 | ],
23 |
24 |
25 | // An authentication source which can authenticate against SAML 2.0 IdPs.
26 | //'default-sp' => [
27 | // 'saml:SP',
28 |
29 | // // The entity ID of this SP.
30 | // 'entityID' => 'https://myapp.example.org/',
31 |
32 | // // The entity ID of the IdP this SP should contact.
33 | // // Can be NULL/unset, in which case the user will be shown a list of available IdPs.
34 | // 'idp' => null,
35 |
36 | // // The URL to the discovery service.
37 | // // Can be NULL/unset, in which case a builtin discovery service will be used.
38 | // 'discoURL' => null,
39 |
40 | // /*
41 | // * If SP behind the SimpleSAMLphp in IdP/SP proxy mode requests
42 | // * AuthnContextClassRef, decide whether the AuthnContextClassRef will be
43 | // * processed by the IdP/SP proxy or if it will be passed to the original
44 | // * IdP in front of the IdP/SP proxy.
45 | // */
46 | // 'proxymode.passAuthnContextClassRef' => false,
47 |
48 | // /*
49 | // * The attributes parameter must contain an array of desired attributes by the SP.
50 | // * The attributes can be expressed as an array of names or as an associative array
51 | // * in the form of 'friendlyName' => 'name'. This feature requires 'name' to be set.
52 | // * The metadata will then be created as follows:
53 | // *
54 | // */
55 | // /*
56 | // 'name' => [
57 | // 'en' => 'A service',
58 | // 'no' => 'En tjeneste',
59 | // ],
60 |
61 | // 'attributes' => [
62 | // 'attrname' => 'urn:oid:x.x.x.x',
63 | // ],
64 | // 'attributes.required' => [
65 | // 'urn:oid:x.x.x.x',
66 | // ],
67 | // */
68 | //],
69 |
70 |
71 | /*
72 | 'example-sql' => [
73 | 'sqlauth:SQL',
74 | 'dsn' => 'pgsql:host=sql.example.org;port=5432;dbname=simplesaml',
75 | 'username' => 'simplesaml',
76 | 'password' => 'secretpassword',
77 | 'query' => 'SELECT uid, givenName, email, eduPersonPrincipalName FROM users WHERE uid = :username ' .
78 | 'AND password = SHA2(CONCAT((SELECT salt FROM users WHERE uid = :username), :password), 256);',
79 | ],
80 | */
81 |
82 | /*
83 | 'example-static' => [
84 | 'exampleauth:StaticSource',
85 | 'uid' => ['testuser'],
86 | 'eduPersonAffiliation' => ['member', 'employee'],
87 | 'cn' => ['Test User'],
88 | ],
89 | */
90 |
91 | 'example-userpass' => [
92 | 'exampleauth:UserPass',
93 |
94 | // Give the user an option to save their username for future login attempts
95 | // And when enabled, what should the default be, to save the username or not
96 | //'remember.username.enabled' => false,
97 | //'remember.username.checked' => false,
98 |
99 | 'users' => [
100 | 'student01:student01' => [
101 | 'uid' => ['student01'],
102 | 'displayName' => 'Student 01',
103 | 'urn:mace:dir:attribute-def:ubcEduCwlPuid' => 'PUIDST01',
104 | 'eduPersonAffiliation' => ['student'],
105 | 'mail' => 'student01@example.edu'
106 | ],
107 | 'instructor01:instructor01' => [
108 | 'uid' => ['instructor01'],
109 | 'displayName' => 'Instructor 01',
110 | 'urn:mace:dir:attribute-def:ubcEduCwlPuid' => 'PUIDIN01',
111 | 'alt' => '51092d7f-2f38-4a91-bfb0-13a021c02df3',
112 | 'eduPersonAffiliation' => ['faculty', 'student'],
113 | 'mail' => 'instructor01@example.edu'
114 | ],
115 | 'employee:employeepass' => [
116 | 'uid' => ['employee'],
117 | 'displayName' => 'Employee 00',
118 | 'urn:mace:dir:attribute-def:ubcEduCwlPuid' => 'PUIDEM00',
119 | 'eduPersonAffiliation' => ['staff', 'alumni'],
120 | 'mail' => 'employee@example.edu'
121 | ],
122 | # intended to simulate a basic CWL account
123 | 'blockme01:blockme01' => [
124 | 'uid' => ['blockme01'],
125 | 'displayName' => 'Block Me01',
126 | 'urn:mace:dir:attribute-def:ubcEduCwlPuid' => 'PUIDBM01',
127 | 'eduPersonAffiliation' => [],
128 | 'mail' => 'blockme01@example.edu'
129 | ],
130 | ],
131 | ],
132 |
133 | /*
134 | 'crypto-hash' => [
135 | 'authcrypt:Hash',
136 | // hashed version of 'verysecret', made with bin/pwgen.php
137 | 'professor:{SSHA256}P6FDTEEIY2EnER9a6P2GwHhI5JDrwBgjQ913oVQjBngmCtrNBUMowA==' => [
138 | 'uid' => ['prof_a'],
139 | 'eduPersonAffiliation' => ['member', 'employee', 'board'],
140 | ],
141 | ],
142 | */
143 |
144 | /*
145 | 'htpasswd' => [
146 | 'authcrypt:Htpasswd',
147 | 'htpasswd_file' => '/var/www/foo.edu/legacy_app/.htpasswd',
148 | 'static_attributes' => [
149 | 'eduPersonAffiliation' => ['member', 'employee'],
150 | 'Organization' => ['University of Foo'],
151 | ],
152 | ],
153 | */
154 |
155 | /*
156 | // This authentication source serves as an example of integration with an
157 | // external authentication engine. Take a look at the comment in the beginning
158 | // of modules/exampleauth/lib/Auth/Source/External.php for a description of
159 | // how to adjust it to your own site.
160 | 'example-external' => [
161 | 'exampleauth:External',
162 | ],
163 | */
164 |
165 | /*
166 | 'yubikey' => [
167 | 'authYubiKey:YubiKey',
168 | 'id' => '000',
169 | // 'key' => '012345678',
170 | ],
171 | */
172 |
173 | /*
174 | 'facebook' => [
175 | 'authfacebook:Facebook',
176 | // Register your Facebook application on http://www.facebook.com/developers
177 | // App ID or API key (requests with App ID should be faster; https://github.com/facebook/php-sdk/issues/214)
178 | 'api_key' => 'xxxxxxxxxxxxxxxx',
179 | // App Secret
180 | 'secret' => 'xxxxxxxxxxxxxxxx',
181 | // which additional data permissions to request from user
182 | // see http://developers.facebook.com/docs/authentication/permissions/ for the full list
183 | // 'req_perms' => 'email,user_birthday',
184 | // Which additional user profile fields to request.
185 | // When empty, only the app-specific user id and name will be returned
186 | // See https://developers.facebook.com/docs/graph-api/reference/v2.6/user for the full list
187 | // 'user_fields' => 'email,birthday,third_party_id,name,first_name,last_name',
188 | ],
189 | */
190 |
191 | /*
192 | // Twitter OAuth Authentication API.
193 | // Register your application to get an API key here:
194 | // http://twitter.com/oauth_clients
195 | 'twitter' => [
196 | 'authtwitter:Twitter',
197 | 'key' => 'xxxxxxxxxxxxxxxx',
198 | 'secret' => 'xxxxxxxxxxxxxxxx',
199 | // Forces the user to enter their credentials to ensure the correct users account is authorized.
200 | // Details: https://dev.twitter.com/docs/api/1/get/oauth/authenticate
201 | 'force_login' => false,
202 | ],
203 | */
204 |
205 | /*
206 | // Microsoft Account (Windows Live ID) Authentication API.
207 | // Register your application to get an API key here:
208 | // https://apps.dev.microsoft.com/
209 | 'windowslive' => [
210 | 'authwindowslive:LiveID',
211 | 'key' => 'xxxxxxxxxxxxxxxx',
212 | 'secret' => 'xxxxxxxxxxxxxxxx',
213 | ],
214 | */
215 |
216 | /*
217 | // Example of a LDAP authentication source.
218 | 'example-ldap' => [
219 | 'ldap:Ldap',
220 |
221 | // The connection string for the LDAP-server.
222 | // You can add multiple by separating them with a space.
223 | 'connection_string' => 'ldap.example.org',
224 |
225 | // Whether SSL/TLS should be used when contacting the LDAP server.
226 | // Possible values are 'ssl', 'tls' or 'none'
227 | 'encryption' => 'ssl',
228 |
229 | // The LDAP version to use when interfacing the LDAP-server.
230 | // Defaults to 3
231 | 'version' => 3,
232 |
233 | // Set to TRUE to enable LDAP debug level. Passed to the LDAP connector class.
234 | //
235 | // Default: FALSE
236 | // Required: No
237 | 'ldap.debug' => false,
238 |
239 | // The LDAP-options to pass when setting up a connection
240 | // See [Symfony documentation][1]
241 | 'options' => [
242 |
243 | // Set whether to follow referrals.
244 | // AD Controllers may require 0x00 to function.
245 | // Possible values are 0x00 (NEVER), 0x01 (SEARCHING),
246 | // 0x02 (FINDING) or 0x03 (ALWAYS).
247 | 'referrals' => 0x00,
248 |
249 | 'network_timeout' => 3,
250 | ],
251 |
252 | // The connector to use.
253 | // Defaults to '\SimpleSAML\Module\ldap\Connector\Ldap', but can be set
254 | // to '\SimpleSAML\Module\ldap\Connector\ActiveDirectory' when
255 | // authenticating against Microsoft Active Directory. This will
256 | // provide you with more specific error messages.
257 | 'connector' => '\SimpleSAML\Module\ldap\Connector\Ldap',
258 |
259 | // Which attributes should be retrieved from the LDAP server.
260 | // This can be an array of attribute names, or NULL, in which case
261 | // all attributes are fetched.
262 | 'attributes' => null,
263 |
264 | // Which attributes should be base64 encoded after retrieval from
265 | // the LDAP server.
266 | 'attributes.binary' => [
267 | 'jpegPhoto',
268 | 'objectGUID',
269 | 'objectSid',
270 | 'mS-DS-ConsistencyGuid'
271 | ],
272 |
273 | // The pattern which should be used to create the user's DN given
274 | // the username. %username% in this pattern will be replaced with
275 | // the user's username.
276 | //
277 | // This option is not used if the search.enable option is set to TRUE.
278 | 'dnpattern' => 'uid=%username%,ou=people,dc=example,dc=org',
279 |
280 | // As an alternative to specifying a pattern for the users DN, it is
281 | // possible to search for the username in a set of attributes. This is
282 | // enabled by this option.
283 | 'search.enable' => false,
284 |
285 | // An array on DNs which will be used as a base for the search. In
286 | // case of multiple strings, they will be searched in the order given.
287 | 'search.base' => [
288 | 'ou=people,dc=example,dc=org',
289 | ],
290 |
291 | // The scope of the search. Valid values are 'sub' and 'one' and
292 | // 'base', first one being the default if no value is set.
293 | 'search.scope' => 'sub',
294 |
295 | // The attribute(s) the username should match against.
296 | //
297 | // This is an array with one or more attribute names. Any of the
298 | // attributes in the array may match the value the username.
299 | 'search.attributes' => ['uid', 'mail'],
300 |
301 | // Additional filters that must match for the entire LDAP search to
302 | // be true.
303 | //
304 | // This should be a single string conforming to [RFC 1960][2]
305 | // and [RFC 2544][3]. The string is appended to the search attributes
306 | 'search.filter' => '(&(objectClass=Person)(|(sn=Doe)(cn=John *)))',
307 |
308 | // The username & password where SimpleSAMLphp should bind to before
309 | // searching. If this is left NULL, no bind will be performed before
310 | // searching.
311 | 'search.username' => null,
312 | 'search.password' => null,
313 | ],
314 | */
315 |
316 | /*
317 | // Example of an LDAPMulti authentication source.
318 | 'example-ldapmulti' => [
319 | 'ldap:LdapMulti',
320 |
321 | // The way the organization as part of the username should be handled.
322 | // Three possible values:
323 | // - 'none': No handling of the organization. Allows '@' to be part
324 | // of the username.
325 | // - 'allow': Will allow users to type 'username@organization'.
326 | // - 'force': Force users to type 'username@organization'. The dropdown
327 | // list will be hidden.
328 | //
329 | // The default is 'none'.
330 | 'username_organization_method' => 'none',
331 |
332 | // Whether the organization should be included as part of the username
333 | // when authenticating. If this is set to TRUE, the username will be on
334 | // the form @. If this is FALSE, the
335 | // username will be used as the user enters it.
336 | //
337 | // The default is FALSE.
338 | 'include_organization_in_username' => false,
339 |
340 | // A list of available LDAP servers.
341 | //
342 | // The index is an identifier for the organization/group. When
343 | // 'username_organization_method' is set to something other than 'none',
344 | // the organization-part of the username is matched against the index.
345 | //
346 | // The value of each element is an array in the same format as an LDAP
347 | // authentication source.
348 | 'mapping' => [
349 | 'employees' => [
350 | // A short name/description for this group. Will be shown in a
351 | // dropdown list when the user logs on.
352 | //
353 | // This option can be a string or an array with
354 | // language => text mappings.
355 | 'description' => 'Employees',
356 | 'authsource' => 'example-ldap',
357 | ],
358 |
359 | 'students' => [
360 | 'description' => 'Students',
361 | 'authsource' => 'example-ldap-2',
362 | ],
363 | ],
364 | ],
365 | */
366 | ];
367 |
--------------------------------------------------------------------------------
/skins/Vector/includes/Hooks.php:
--------------------------------------------------------------------------------
1 | ()
29 | * @package Vector
30 | * @internal
31 | */
32 | class Hooks implements
33 | GetPreferencesHook,
34 | LocalUserCreatedHook,
35 | MakeGlobalVariablesScriptHook,
36 | OutputPageBodyAttributesHook,
37 | ResourceLoaderSiteModulePagesHook,
38 | ResourceLoaderSiteStylesModulePagesHook,
39 | RequestContextCreateSkinHook,
40 | SkinPageReadyConfigHook
41 | {
42 | /**
43 | * Checks if the current skin is a variant of Vector
44 | *
45 | * @param string $skinName
46 | * @return bool
47 | */
48 | private static function isVectorSkin( string $skinName ): bool {
49 | return (
50 | $skinName === Constants::SKIN_NAME_LEGACY ||
51 | $skinName === Constants::SKIN_NAME_MODERN
52 | );
53 | }
54 |
55 | /**
56 | * @param Config $config
57 | * @return array
58 | */
59 | private static function getActiveABTest( $config ) {
60 | $ab = $config->get(
61 | Constants::CONFIG_WEB_AB_TEST_ENROLLMENT
62 | );
63 | if ( count( $ab ) === 0 ) {
64 | // If array is empty then no experiment and need to validate.
65 | return $ab;
66 | }
67 | if ( !array_key_exists( 'buckets', $ab ) ) {
68 | throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Must contain buckets key.' );
69 | }
70 | if ( !array_key_exists( 'unsampled', $ab['buckets'] ) ) {
71 | throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Must define an `unsampled` bucket.' );
72 | } else {
73 | // check bucket values.
74 | foreach ( $ab['buckets'] as $bucketName => $bucketDefinition ) {
75 | if ( !is_array( $bucketDefinition ) ) {
76 | throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Buckets should be arrays' );
77 | }
78 | $samplingRate = $bucketDefinition['samplingRate'];
79 | if ( is_string( $samplingRate ) ) {
80 | throw new RuntimeException(
81 | 'Invalid VectorWebABTestEnrollment value: Sampling rate should be number between 0 and 1.'
82 | );
83 | }
84 | }
85 | }
86 |
87 | return $ab;
88 | }
89 |
90 | /**
91 | * Passes config variables to Vector (modern) ResourceLoader module.
92 | * @param RL\Context $context
93 | * @param Config $config
94 | * @return array
95 | */
96 | public static function getVectorResourceLoaderConfig(
97 | RL\Context $context,
98 | Config $config
99 | ) {
100 | return [
101 | 'wgVectorSearchHost' => $config->get( 'VectorSearchHost' ),
102 | 'wgVectorWebABTestEnrollment' => self::getActiveABTest( $config ),
103 | ];
104 | }
105 |
106 | /**
107 | * Generates config variables for skins.vector.search Resource Loader module (defined in
108 | * skin.json).
109 | *
110 | * @param RL\Context $context
111 | * @param Config $config
112 | * @return array
113 | */
114 | public static function getVectorSearchResourceLoaderConfig(
115 | RL\Context $context,
116 | Config $config
117 | ): array {
118 | $result = $config->get( 'VectorWvuiSearchOptions' );
119 | $result['highlightQuery'] =
120 | VectorServices::getLanguageService()->canWordsBeSplitSafely( $context->getLanguage() );
121 |
122 | return $result;
123 | }
124 |
125 | /**
126 | * SkinPageReadyConfig hook handler
127 | *
128 | * Replace searchModule provided by skin.
129 | *
130 | * @since 1.35
131 | * @param RL\Context $context
132 | * @param mixed[] &$config Associative array of configurable options
133 | * @return void This hook must not abort, it must return no value
134 | */
135 | public function onSkinPageReadyConfig(
136 | RL\Context $context,
137 | array &$config
138 | ): void {
139 | // It's better to exit before any additional check
140 | if ( !self::isVectorSkin( $context->getSkin() ) ) {
141 | return;
142 | }
143 |
144 | // Tell the `mediawiki.page.ready` module not to wire up search.
145 | // This allows us to use the new Vue implementation.
146 | // Context has no knowledge of legacy / modern Vector
147 | // and from its point of view they are the same thing.
148 | // Please see the modules `skins.vector.js` and `skins.vector.legacy.js`
149 | // for the wire up of search.
150 | // The related method self::getVectorResourceLoaderConfig handles which
151 | // search to load.
152 | $config['search'] = false;
153 | }
154 |
155 | /**
156 | * Transforms watch item inside the action navigation menu
157 | *
158 | * @param array &$content_navigation
159 | */
160 | private static function updateActionsMenu( &$content_navigation ) {
161 | $key = null;
162 | if ( isset( $content_navigation['actions']['watch'] ) ) {
163 | $key = 'watch';
164 | }
165 | if ( isset( $content_navigation['actions']['unwatch'] ) ) {
166 | $key = 'unwatch';
167 | }
168 |
169 | // Promote watch link from actions to views and add an icon
170 | if ( $key !== null ) {
171 | self::appendClassToItem(
172 | $content_navigation['actions'][$key]['class'],
173 | [ 'icon' ]
174 | );
175 | $content_navigation['views'][$key] = $content_navigation['actions'][$key];
176 | unset( $content_navigation['actions'][$key] );
177 | }
178 | }
179 |
180 | /**
181 | * Adds class to a property
182 | *
183 | * @param array &$item to update
184 | * @param array|string $classes to add to the item
185 | */
186 | private static function appendClassToItem( &$item, $classes ) {
187 | $existingClasses = $item;
188 |
189 | if ( is_array( $existingClasses ) ) {
190 | // Treat as array
191 | $newArrayClasses = is_array( $classes ) ? $classes : [ trim( $classes ) ];
192 | $item = array_merge( $existingClasses, $newArrayClasses );
193 | } elseif ( is_string( $existingClasses ) ) {
194 | // Treat as string
195 | $newStrClasses = is_string( $classes ) ? trim( $classes ) : implode( ' ', $classes );
196 | $item .= ' ' . $newStrClasses;
197 | } else {
198 | // Treat as whatever $classes is
199 | $item = $classes;
200 | }
201 |
202 | if ( is_string( $item ) ) {
203 | $item = trim( $item );
204 | }
205 | }
206 |
207 | /**
208 | * Updates personal navigation menu (user links) dropdown for modern Vector:
209 | * - Adds icons
210 | * - Makes user page and watchlist collapsible
211 | *
212 | * @param SkinTemplate $sk
213 | * @param array &$content_navigation
214 | */
215 | private static function updateUserLinksDropdownItems( $sk, &$content_navigation ) {
216 | // For logged-in users in modern Vector, rearrange some links in the personal toolbar.
217 | $user = $sk->getUser();
218 | $isTemp = $user->isTemp();
219 | $isRegistered = $user->isRegistered();
220 | if ( $isTemp ) {
221 | if ( isset( $content_navigation['user-page']['tmpuserpage'] ) ) {
222 | $content_navigation['user-page']['tmpuserpage']['collapsible'] = true;
223 | $content_navigation['user-page']['tmpuserpage'] =
224 | self::updateMenuItemData( $content_navigation['user-page']['tmpuserpage'] );
225 | }
226 | if ( isset( $content_navigation['user-menu']['tmpuserpage'] ) ) {
227 | $content_navigation['user-menu']['tmpuserpage']['collapsible'] = true;
228 | $content_navigation['user-menu']['tmpuserpage'] =
229 | self::updateMenuItemData( $content_navigation['user-menu']['tmpuserpage'] );
230 | }
231 | } elseif ( $isRegistered ) {
232 | // Remove user page from personal menu dropdown for logged in use
233 | $content_navigation['user-menu']['userpage']['collapsible'] = true;
234 | // watchlist may be disabled if $wgGroupPermissions['*']['viewmywatchlist'] = false;
235 | // See [[phab:T299671]]
236 | if ( isset( $content_navigation['user-menu']['watchlist'] ) ) {
237 | $content_navigation['user-menu']['watchlist']['collapsible'] = true;
238 | }
239 | // Remove logout link from user-menu and recreate it in SkinVector,
240 | unset( $content_navigation['user-menu']['logout'] );
241 | }
242 |
243 | if ( $isRegistered ) {
244 | // Prefix user link items with associated icon.
245 | // Don't show icons for anon menu items (besides login and create account).
246 | // Loop through each menu to check/append its link classes.
247 | self::updateMenuItems( $content_navigation, 'user-menu' );
248 | } else {
249 | // Remove "Not logged in" from personal menu dropdown for anon users.
250 | unset( $content_navigation['user-menu']['anonuserpage'] );
251 | }
252 |
253 | if ( !$isRegistered || $isTemp ) {
254 | // "Create account" link is handled manually by Vector
255 | unset( $content_navigation['user-menu']['createaccount'] );
256 | // "Login" link is handled manually by Vector
257 | unset( $content_navigation['user-menu']['login'] );
258 | // Remove duplicate "Login" link added by SkinTemplate::buildPersonalUrls if group read permissions
259 | // are set to false.
260 | unset( $content_navigation['user-menu']['login-private'] );
261 | }
262 | }
263 |
264 | /**
265 | * Populates 'vector-user-menu-overflow' bucket for modern Vector with modified personal navigation (user links)
266 | * menu items, including 'notification', 'user-interface-preferences', 'user-page', 'vector-user-menu-overflow'
267 | *
268 | * @param SkinTemplate $sk
269 | * @param array &$content_navigation
270 | */
271 | private static function updateUserLinksOverflowItems( $sk, &$content_navigation ) {
272 | $overflow = 'vector-user-menu-overflow';
273 | $content_navigation[$overflow] = [];
274 |
275 | // Logged in and logged out overflow items
276 | if ( isset( $content_navigation['user-interface-preferences']['uls'] ) ) {
277 | $content_navigation[$overflow]['uls'] = array_merge(
278 | $content_navigation['user-interface-preferences']['uls'], [
279 | 'collapsible' => true,
280 | ] );
281 | }
282 |
283 | // Logged in overflow items
284 | if ( isset( $content_navigation['user-page']['userpage'] ) ) {
285 | $content_navigation[$overflow]['userpage'] = array_merge(
286 | $content_navigation['user-page']['userpage'], [
287 | // T312157: Style the userpage link as a blue link rather than a quiet button.
288 | 'button' => false,
289 | 'collapsible' => true,
290 | // Remove icon
291 | 'icon' => '',
292 | ] );
293 | }
294 | if ( isset( $content_navigation['notifications'] ) ) {
295 | foreach ( $content_navigation['notifications'] as $key => $data ) {
296 | $content_navigation[$overflow][$key] = $data;
297 | }
298 | }
299 | if ( isset( $content_navigation['user-menu']['watchlist'] ) ) {
300 | $content_navigation[$overflow]['watchlist'] = array_merge(
301 | $content_navigation['user-menu']['watchlist'], [
302 | 'id' => 'pt-watchlist-2',
303 | 'button' => true,
304 | 'collapsible' => true,
305 | 'text-hidden' => true,
306 | ] );
307 | }
308 |
309 | // Anon/temp overflow items
310 | $user = $sk->getUser();
311 | $isTemp = $user->isTemp();
312 | $isRegistered = $user->isRegistered();
313 | $isCreateAccountAllowed = ( !$isRegistered || $isTemp );
314 | if ( isset( $content_navigation['user-menu']['createaccount'] ) && $isCreateAccountAllowed ) {
315 | $content_navigation[$overflow]['createaccount'] = array_merge(
316 | $content_navigation['user-menu']['createaccount'], [
317 | 'id' => 'pt-createaccount-2',
318 | // T312157: Style the userpage link as a blue link rather than a quiet button.
319 | 'button' => false,
320 | 'collapsible' => true,
321 | // Remove icon
322 | 'icon' => '',
323 | ] );
324 | }
325 | # TODO: remove customization after 1.40+
326 | # ubc custom: backport from 1.40, add login button to the overflow menu
327 | # we're hiding the user links button, so the login button cannot be
328 | # allowed to collapse
329 | if ( isset( $content_navigation['user-menu']['login'] ) ) {
330 | $content_navigation[$overflow]['login'] = array_merge(
331 | $content_navigation['user-menu']['login'], [
332 | 'id' => 'pt-login-2',
333 | 'button' => true,
334 | 'collapsible' => false,
335 | // Remove icon
336 | //'icon' => '',
337 | ] );
338 | }
339 |
340 | self::updateMenuItems( $content_navigation, $overflow );
341 | }
342 |
343 | /**
344 | * Updates personal navigation menu (user links) for modern Vector wherein user page, create account and login links
345 | * are removed from the dropdown to be handled separately. In legacy Vector, the custom "user-page" bucket is
346 | * removed to preserve existing behavior.
347 | *
348 | * @param SkinTemplate $sk
349 | * @param array &$content_navigation
350 | */
351 | private static function updateUserLinksItems( $sk, &$content_navigation ) {
352 | $skinName = $sk->getSkinName();
353 | if ( self::isSkinVersionLegacy( $skinName ) ) {
354 | // Remove user page from personal toolbar since it will be inside the personal menu for logged-in
355 | // users in legacy Vector.
356 | unset( $content_navigation['user-page'] );
357 | } else {
358 | self::updateUserLinksOverflowItems( $sk, $content_navigation );
359 | self::updateUserLinksDropdownItems( $sk, $content_navigation );
360 | }
361 | }
362 |
363 | /**
364 | * Modifies list item to make it collapsible.
365 | *
366 | * @param array &$item
367 | * @param string $prefix defaults to user-links-
368 | */
369 | private static function makeMenuItemCollapsible( array &$item, string $prefix = 'user-links-' ) {
370 | $COLLAPSE_MENU_ITEM_CLASS = $prefix . 'collapsible-item';
371 | self::appendClassToItem( $item[ 'class' ], $COLLAPSE_MENU_ITEM_CLASS );
372 | }
373 |
374 | /**
375 | * Make an icon
376 | *
377 | * @internal for use inside Vector skin.
378 | * @param string $name
379 | * @return string of HTML
380 | */
381 | public static function makeIcon( $name ) {
382 | // Html::makeLink will pass this through rawElement
383 | return '';
384 | }
385 |
386 | /**
387 | * Update template data to include classes and html that handle buttons, icons, and collapsible items.
388 | *
389 | * @internal for use inside Vector skin.
390 | * @param array $item data to update
391 | * @param string $buttonClassProp property to append button classes
392 | * @param string $iconHtmlProp property to set icon HTML
393 | * @return array $item Updated data
394 | */
395 | private static function updateItemData( $item, $buttonClassProp, $iconHtmlProp ) {
396 | $hasButton = $item['button'] ?? false;
397 | $hideText = $item['text-hidden'] ?? false;
398 | $isCollapsible = $item['collapsible'] ?? false;
399 | $icon = $item['icon'] ?? '';
400 | unset( $item['button'] );
401 | unset( $item['icon'] );
402 | unset( $item['text-hidden'] );
403 | unset( $item['collapsible'] );
404 |
405 | if ( $isCollapsible ) {
406 | self::makeMenuItemCollapsible( $item );
407 | }
408 | if ( $hasButton ) {
409 | self::appendClassToItem( $item[ $buttonClassProp ], [ 'mw-ui-button', 'mw-ui-quiet' ] );
410 | }
411 | if ( $icon ) {
412 | if ( $hideText ) {
413 | $iconElementClasses = [ 'mw-ui-icon', 'mw-ui-icon-element',
414 | // Some extensions declare icons without the wikimedia- prefix. e.g. Echo
415 | 'mw-ui-icon-' . $icon,
416 | // FIXME: Some icon names are prefixed with `wikimedia-`.
417 | // We should seek to remove all these instances.
418 | 'mw-ui-icon-wikimedia-' . $icon
419 | ];
420 | self::appendClassToItem( $item[ $buttonClassProp ], $iconElementClasses );
421 | } else {
422 | $item[ $iconHtmlProp ] = self::makeIcon( $icon );
423 | }
424 | }
425 | return $item;
426 | }
427 |
428 | /**
429 | * Updates template data for Vector dropdown menus.
430 | *
431 | * @param array $item Menu data to update
432 | * @return array $item Updated menu data
433 | */
434 | public static function updateDropdownMenuData( $item ) {
435 | $buttonClassProp = 'heading-class';
436 | $iconHtmlProp = 'html-vector-heading-icon';
437 | return self::updateItemData( $item, $buttonClassProp, $iconHtmlProp );
438 | }
439 |
440 | /**
441 | * Updates template data for Vector link items.
442 | *
443 | * @param array $item link data to update
444 | * @return array $item Updated link data
445 | */
446 | public static function updateLinkData( $item ) {
447 | $buttonClassProp = 'class';
448 | $iconHtmlProp = 'link-html';
449 | return self::updateItemData( $item, $buttonClassProp, $iconHtmlProp );
450 | }
451 |
452 | /**
453 | * Updates template data for Vector menu items.
454 | *
455 | * @param array $item menu item data to update
456 | * @return array $item Updated menu item data
457 | */
458 | public static function updateMenuItemData( $item ) {
459 | $buttonClassProp = 'link-class';
460 | $iconHtmlProp = 'link-html';
461 | return self::updateItemData( $item, $buttonClassProp, $iconHtmlProp );
462 | }
463 |
464 | /**
465 | * Updates user interface preferences for modern Vector to upgrade icon/button menu items.
466 | *
467 | * @param array &$content_navigation
468 | * @param string $menu identifier
469 | */
470 | private static function updateMenuItems( &$content_navigation, $menu ) {
471 | foreach ( $content_navigation[$menu] as $key => $item ) {
472 | $content_navigation[$menu][$key] = self::updateMenuItemData( $item );
473 | }
474 | }
475 |
476 | /**
477 | * Vector 2022 only:
478 | * Creates an additional menu that will be injected inside the more (cactions)
479 | * dropdown menu. This menu is a clone of `views` and this menu will only be
480 | * shown at low resolutions (when the `views` menu is hidden).
481 | *
482 | * An additional menu is used instead of adding to the existing cactions menu
483 | * so that the emptyPortlet logic for that menu is preserved and the cactions menu
484 | * is not shown at large resolutions when empty (e.g. all items including collapsed
485 | * items are hidden).
486 | *
487 | * @param array &$content_navigation
488 | */
489 | private static function createMoreOverflowMenu( &$content_navigation ) {
490 | $clonedViews = [];
491 | foreach ( array_keys( $content_navigation['views'] ?? [] ) as $key ) {
492 | $newItem = $content_navigation['views'][$key];
493 | self::makeMenuItemCollapsible(
494 | $newItem,
495 | 'vector-more-'
496 | );
497 | $clonedViews['more-' . $key] = $newItem;
498 | }
499 | // Inject collapsible menu items ahead of existing actions.
500 | $content_navigation['views-overflow'] = $clonedViews;
501 | }
502 |
503 | /**
504 | * Upgrades Vector's watch action to a watchstar.
505 | * This is invoked inside SkinVector, not via skin registration, as skin hooks
506 | * are not guaranteed to run last.
507 | * This can possibly be revised based on the outcome of T287622.
508 | *
509 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
510 | * @param SkinTemplate $sk
511 | * @param array &$content_navigation
512 | */
513 | public static function onSkinTemplateNavigation( $sk, &$content_navigation ) {
514 | $title = $sk->getRelevantTitle();
515 |
516 | $skinName = $sk->getSkinName();
517 | if ( self::isVectorSkin( $skinName ) ) {
518 | if (
519 | $sk->getConfig()->get( 'VectorUseIconWatch' ) &&
520 | $title && $title->canExist()
521 | ) {
522 | self::updateActionsMenu( $content_navigation );
523 | }
524 |
525 | self::updateUserLinksItems( $sk, $content_navigation );
526 | }
527 | if ( $skinName === Constants::SKIN_NAME_MODERN ) {
528 | self::createMoreOverflowMenu( $content_navigation );
529 | }
530 | }
531 |
532 | /**
533 | * Adds MediaWiki:Vector.css as the skin style that controls classic Vector.
534 | *
535 | * @param string $skin
536 | * @param array &$pages
537 | */
538 | public function onResourceLoaderSiteStylesModulePages( $skin, &$pages ): void {
539 | if ( $skin === Constants::SKIN_NAME_MODERN ) {
540 | $pages['MediaWiki:Vector.css'] = [ 'type' => 'style' ];
541 | }
542 | }
543 |
544 | /**
545 | * Adds MediaWiki:Vector.css as the skin style that controls classic Vector.
546 | *
547 | * @param string $skin
548 | * @param array &$pages
549 | */
550 | public function onResourceLoaderSiteModulePages( $skin, &$pages ): void {
551 | if ( $skin === Constants::SKIN_NAME_MODERN ) {
552 | $pages['MediaWiki:Vector.js'] = [ 'type' => 'script' ];
553 | }
554 | }
555 |
556 | /**
557 | * Adds the persistent sidebar hidden API preference.
558 | *
559 | * @param User $user User whose preferences are being modified.
560 | * @param array[] &$prefs Preferences description array, to be fed to a HTMLForm object.
561 | */
562 | public function onGetPreferences( $user, &$prefs ): void {
563 | $config = MediaWikiServices::getInstance()->getMainConfig();
564 | $vectorPrefs = [
565 | Constants::PREF_KEY_SIDEBAR_VISIBLE => [
566 | 'type' => 'api',
567 | 'default' => $config->get(
568 | Constants::CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_AUTHORISED_USER
569 | ),
570 | ],
571 | ];
572 | $prefs += $vectorPrefs;
573 | }
574 |
575 | /**
576 | * Called one time when initializing a users preferences for a newly created account.
577 | *
578 | * @param User $user Newly created user object.
579 | * @param bool $isAutoCreated
580 | */
581 | public function onLocalUserCreated( $user, $isAutoCreated ) {
582 | $config = MediaWikiServices::getInstance()->getMainConfig();
583 | $default = $config->get( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS );
584 | if ( $default ) {
585 | $optionsManager = MediaWikiServices::getInstance()->getUserOptionsManager();
586 | $optionsManager->setOption(
587 | $user,
588 | Constants::PREF_KEY_SKIN,
589 | $default === Constants::SKIN_VERSION_LEGACY ?
590 | Constants::SKIN_NAME_LEGACY : Constants::SKIN_NAME_MODERN
591 | );
592 | }
593 | }
594 |
595 | /**
596 | * Returns the necessary TOC classes.
597 | *
598 | * @param Skin $sk
599 | * @param Config $config
600 | * @return string[]
601 | */
602 | private static function getTocClasses( Skin $sk, $config ): array {
603 | if ( !( $sk instanceof SkinVector22 ) ) {
604 | return [];
605 | }
606 |
607 | $classes = [];
608 | if (
609 | $sk->isTOCABTestEnabled() &&
610 | $sk->isTableOfContentsVisibleInSidebar() &&
611 | !$sk->getUser()->isAnon()
612 | ) {
613 | $userBucket = !$sk->isUserInTocTreatmentBucket()
614 | ? 'control'
615 | : 'treatment';
616 | $experimentConfig = $config->get( Constants::CONFIG_WEB_AB_TEST_ENROLLMENT );
617 | $experimentName = $experimentConfig[ 'name' ];
618 | $classes[] = $experimentName;
619 | $classes[] = "$experimentName-$userBucket";
620 | }
621 |
622 | return $classes;
623 | }
624 |
625 | /**
626 | * Called when OutputPage::headElement is creating the body tag to allow skins
627 | * and extensions to add attributes they might need to the body of the page.
628 | *
629 | * @param OutputPage $out
630 | * @param Skin $sk
631 | * @param string[] &$bodyAttrs
632 | */
633 | public function onOutputPageBodyAttributes( $out, $sk, &$bodyAttrs ): void {
634 | $skinName = $out->getSkin()->getSkinName();
635 | if ( !self::isVectorSkin( $skinName ) ) {
636 | return;
637 | }
638 | $config = $sk->getConfig();
639 |
640 | // As of 2020/08/13, this CSS class is referred to by the following deployed extensions:
641 | //
642 | // - VisualEditor
643 | // - CodeMirror
644 | // - WikimediaEvents
645 | //
646 | // See https://codesearch.wmcloud.org/deployed/?q=skin-vector-legacy for an up-to-date
647 | // list.
648 | if ( self::isSkinVersionLegacy( $skinName ) ) {
649 | $bodyAttrs['class'] .= ' skin-vector-legacy';
650 | }
651 |
652 | $tocClasses = self::getTocClasses( $sk, $config );
653 | if ( $tocClasses ) {
654 | $bodyAttrs['class'] .= ' ' . implode( ' ', $tocClasses );
655 | }
656 |
657 | // Should we disable the max-width styling?
658 | if ( !self::isSkinVersionLegacy( $skinName ) && $sk->getTitle() && self::shouldDisableMaxWidth(
659 | $config->get( 'VectorMaxWidthOptions' ),
660 | $sk->getTitle(),
661 | $out->getRequest()->getValues()
662 | ) ) {
663 | $bodyAttrs['class'] .= ' skin-vector-disable-max-width';
664 | }
665 |
666 | $featureManager = VectorServices::getFeatureManager();
667 | $bodyAttrs['class'] .= ' ' . implode( ' ', $featureManager->getFeatureBodyClass() );
668 | $bodyAttrs['class'] = trim( $bodyAttrs['class'] );
669 | }
670 |
671 | /**
672 | * Temporary RequestContextCreateSkin hook handler.
673 | * Switches to new Vector on certain pages.
674 | *
675 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/RequestContextCreateSkin
676 | *
677 | * @param IContextSource $context The RequestContext object the skin is being created for.
678 | * @param Skin|null|string &$skin A variable reference you may set a Skin instance or string
679 | * key on to override the skin that will be used for the context.
680 | * @return bool|void
681 | */
682 | public function onRequestContextCreateSkin( $context, &$skin ) {
683 | if ( !$skin ) {
684 | // user is anonymous
685 | $user = $context->getUser();
686 | $config = $context->getConfig();
687 | $titles = $config->get( 'Vector2022PreviewPages' );
688 | $title = $context->getTitle();
689 | $titleText = $title ? $title->getPrefixedText() : null;
690 | if ( $titleText && $user->isAnon() && in_array( $titleText, $titles ) ) {
691 | $skin = 'vector-2022';
692 | }
693 | }
694 | }
695 |
696 | /**
697 | * Per the $options configuration (for use with $wgVectorMaxWidthOptions)
698 | * determine whether max-width should be disabled on the page.
699 | * For the main page: Check the value of $options['exclude']['mainpage']
700 | * For all other pages, the following will happen:
701 | * - the array $options['include'] of canonical page names will be checked
702 | * against the current page. If a page has been listed there, function will return false
703 | * (max-width will not be disabled)
704 | * Max width is disabled if:
705 | * 1) The current namespace is listed in array $options['exclude']['namespaces']
706 | * OR
707 | * 2) A query string parameter matches one of the regex patterns in $exclusions['querystring'].
708 | *
709 | * @internal only for use inside tests.
710 | * @param array $options
711 | * @param Title $title
712 | * @param array $requestValues
713 | * @return bool
714 | */
715 | public static function shouldDisableMaxWidth( array $options, Title $title, array $requestValues ) {
716 | $canonicalTitle = $title->getRootTitle();
717 |
718 | $inclusions = $options['include'] ?? [];
719 | $exclusions = $options['exclude'] ?? [];
720 |
721 | if ( $title->isMainPage() ) {
722 | // only one check to make
723 | return $exclusions['mainpage'] ?? false;
724 | } elseif ( $canonicalTitle->isSpecialPage() ) {
725 | $canonicalTitle->fixSpecialName();
726 | }
727 |
728 | //
729 | // Check the inclusions based on the canonical title
730 | // The inclusions are checked first as these trump any exclusions.
731 | //
732 | // Now we have the canonical title and the inclusions link we look for any matches.
733 | foreach ( $inclusions as $titleText ) {
734 | $includedTitle = Title::newFromText( $titleText );
735 |
736 | if ( $canonicalTitle->equals( $includedTitle ) ) {
737 | return false;
738 | }
739 | }
740 |
741 | //
742 | // Check the exclusions
743 | // If nothing matches the exclusions to determine what should happen
744 | //
745 | $excludeNamespaces = $exclusions['namespaces'] ?? [];
746 | // Max width is disabled on certain namespaces
747 | if ( $title->inNamespaces( $excludeNamespaces ) ) {
748 | return true;
749 | }
750 | $excludeQueryString = $exclusions['querystring'] ?? [];
751 |
752 | foreach ( $excludeQueryString as $param => $excludedParamPattern ) {
753 | $paramValue = $requestValues[$param] ?? false;
754 | if ( $paramValue ) {
755 | if ( $excludedParamPattern === '*' ) {
756 | // Backwards compatibility for the '*' wildcard.
757 | $excludedParamPattern = '.+';
758 | }
759 | return (bool)preg_match( "/$excludedParamPattern/", $paramValue );
760 | }
761 | }
762 |
763 | return false;
764 | }
765 |
766 | /**
767 | * NOTE: Please use ResourceLoaderGetConfigVars hook instead if possible
768 | * for adding config to the page.
769 | * Adds config variables to JS that depend on current page/request.
770 | *
771 | * Adds a config flag that can disable saving the VectorSidebarVisible
772 | * user preference when the sidebar menu icon is clicked.
773 | *
774 | * @param array &$vars Array of variables to be added into the output.
775 | * @param OutputPage $out OutputPage instance calling the hook
776 | */
777 | public function onMakeGlobalVariablesScript( &$vars, $out ): void {
778 | $skin = $out->getSkin();
779 | $skinName = $skin->getSkinName();
780 | if ( !self::isVectorSkin( $skinName ) ) {
781 | return;
782 | }
783 | $config = $out->getConfig();
784 | $user = $out->getUser();
785 |
786 | if ( $user->isRegistered() && self::isSkinVersionLegacy( $skinName ) ) {
787 | $vars[ 'wgVectorDisableSidebarPersistence' ] =
788 | $config->get(
789 | Constants::CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE
790 | );
791 | }
792 | // Must be exposed to CentralNotice banners via mw.config
793 | $vars[ 'wgVector2022PreviewPages' ] = $config->get( 'Vector2022PreviewPages' );
794 | }
795 |
796 | /**
797 | * Gets whether the current skin version is the legacy version.
798 | * Should mirror SkinVector::isLegacy
799 | *
800 | * @param string $skinName hint that can be used to detect modern vector.
801 | * @return bool
802 | */
803 | private static function isSkinVersionLegacy( $skinName ): bool {
804 | return $skinName === Constants::SKIN_NAME_LEGACY;
805 | }
806 | }
807 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
--------------------------------------------------------------------------------