Skip to content

Commit 1478e8c

Browse files
committed
os2web_key
1 parent 43f2d2f commit 1478e8c

17 files changed

+793
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
indent_style = space
12+
indent_size = 2

.github/workflows/pr.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
on: pull_request
2+
name: Review
3+
jobs:
4+
changelog:
5+
runs-on: ubuntu-latest
6+
name: Changelog should be updated
7+
strategy:
8+
fail-fast: false
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 2
14+
15+
- name: Git fetch
16+
run: git fetch
17+
18+
- name: Check that changelog has been updated.
19+
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0
20+
21+
test-composer-files:
22+
name: Validate composer
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
php-versions: [ '8.1' ]
27+
dependency-version: [ prefer-lowest, prefer-stable ]
28+
steps:
29+
- uses: actions/checkout@master
30+
- name: Setup PHP, with composer and extensions
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php-versions }}
34+
extensions: json
35+
coverage: none
36+
tools: composer:v2
37+
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
38+
- name: Get composer cache directory
39+
id: composer-cache
40+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
41+
- name: Cache dependencies
42+
uses: actions/cache@v2
43+
with:
44+
path: ${{ steps.composer-cache.outputs.dir }}
45+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46+
restore-keys: ${{ runner.os }}-composer-
47+
- name: Validate composer files
48+
run: |
49+
composer validate --strict composer.json
50+
# Check that dependencies resolve.
51+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
52+
- name: Check that composer file is normalized
53+
run: |
54+
composer normalize --dry-run
55+
56+
php-coding-standards:
57+
name: PHP coding standards
58+
runs-on: ubuntu-latest
59+
strategy:
60+
matrix:
61+
php-versions: [ '8.1' ]
62+
steps:
63+
- uses: actions/checkout@master
64+
- name: Setup PHP, with composer and extensions
65+
uses: shivammathur/setup-php@v2
66+
with:
67+
php-version: ${{ matrix.php-versions }}
68+
extensions: json
69+
coverage: none
70+
tools: composer:v2
71+
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
72+
- name: Get composer cache directory
73+
id: composer-cache
74+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
75+
- name: Cache dependencies
76+
uses: actions/cache@v2
77+
with:
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
80+
restore-keys: ${{ runner.os }}-composer-
81+
- name: Install Dependencies
82+
run: |
83+
composer install --no-interaction --no-progress
84+
- name: PHPCS
85+
run: |
86+
composer coding-standards-check/phpcs
87+
88+
php-code-analysis:
89+
name: PHP code analysis
90+
runs-on: ubuntu-latest
91+
strategy:
92+
matrix:
93+
php-versions: [ '8.1' ]
94+
steps:
95+
- uses: actions/checkout@master
96+
- name: Setup PHP, with composer and extensions
97+
uses: shivammathur/setup-php@v2
98+
with:
99+
php-version: ${{ matrix.php-versions }}
100+
extensions: json
101+
coverage: none
102+
tools: composer:v2
103+
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
104+
- name: Get composer cache directory
105+
id: composer-cache
106+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
107+
- name: Cache dependencies
108+
uses: actions/cache@v2
109+
with:
110+
path: ${{ steps.composer-cache.outputs.dir }}
111+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
112+
restore-keys: ${{ runner.os }}-composer-
113+
- name: Code analysis
114+
run: |
115+
./scripts/code-analysis
116+
117+
coding-standards-markdown:
118+
name: Markdown coding standards
119+
runs-on: ubuntu-latest
120+
steps:
121+
- name: Checkout
122+
uses: actions/checkout@master
123+
124+
- name: Coding standards
125+
run: |
126+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor/

.markdownlint.jsonc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
4+
"line-length": {
5+
"line_length": 120,
6+
"code_blocks": false,
7+
"tables": false
8+
},
9+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
10+
"no-duplicate-heading": {
11+
"siblings_only": true
12+
}
13+
}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
[Unreleased]: https://github.com/rimi-itk/os2web_key

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
11
# OS2Web key
22

33
Key stuff for OS2Web.
4+
5+
Implements certificate key providers for [the Key module](https://www.drupal.org/project/key). A *certificate key
6+
provider* provides a passwordless certificate.
7+
8+
## Installation
9+
10+
``` shell
11+
composer require os2web/os2web_key
12+
drush pm:install os2web_key
13+
```
14+
15+
## Usage
16+
17+
Go to `/admin/config/system/keys` and add a key with Key type "Certificate" and one of the following key providers:
18+
19+
* Certificate (file): Provides a certificate stored in the local file system.
20+
21+
## Example
22+
23+
`@todo`
24+
25+
## Coding standards
26+
27+
Our coding are checked by GitHub Actions (cf.
28+
[.github/workflows/pr.yml](.github/workflows/pr.yml)). Use the commands below to
29+
run the checks locally.
30+
31+
### PHP
32+
33+
```shell
34+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install
35+
# Fix (some) coding standards issues
36+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply
37+
# Check that code adheres to the coding standards
38+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check
39+
```
40+
41+
### Markdown
42+
43+
```shell
44+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix
45+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
46+
```
47+
48+
## Code analysis
49+
50+
We use [PHPStan](https://phpstan.org/) for static code analysis.
51+
52+
Running statis code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the
53+
analysis:
54+
55+
```shell
56+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm ./scripts/code-analysis
57+
```

composer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "os2web/os2web_key",
3+
"description": "OS2Web key",
4+
"license": "EUPL-1.2",
5+
"type": "drupal-module",
6+
"authors": [
7+
{
8+
"name": "Mikkel Ricky",
9+
"email": "rimi@aarhus.dk"
10+
}
11+
],
12+
"require": {
13+
"php": "^8.1",
14+
"ext-openssl": "*",
15+
"drupal/core": "^9 || ^10",
16+
"drupal/key": "^1.17"
17+
},
18+
"require-dev": {
19+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
20+
"drupal/coder": "^8.3",
21+
"ergebnis/composer-normalize": "^2.42",
22+
"mglaman/phpstan-drupal": "^1.2",
23+
"phpstan/extension-installer": "^1.3",
24+
"phpstan/phpstan-deprecation-rules": "^1.1"
25+
},
26+
"repositories": [
27+
{
28+
"type": "composer",
29+
"url": "https://packages.drupal.org/8"
30+
}
31+
],
32+
"config": {
33+
"allow-plugins": {
34+
"dealerdirect/phpcodesniffer-composer-installer": true,
35+
"ergebnis/composer-normalize": true,
36+
"phpstan/extension-installer": true
37+
},
38+
"sort-packages": true
39+
},
40+
"scripts": {
41+
"coding-standards-apply": [
42+
"@coding-standards-apply/phpcs"
43+
],
44+
"coding-standards-apply/phpcs": [
45+
"phpcbf --standard=phpcs.xml.dist"
46+
],
47+
"coding-standards-check": [
48+
"@coding-standards-check/phpcs"
49+
],
50+
"coding-standards-check/phpcs": [
51+
"phpcs --standard=phpcs.xml.dist"
52+
]
53+
}
54+
}

os2web_key.info.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: 'OS2Web key'
2+
type: module
3+
description: 'Key stuff for OS2Web'
4+
package: 'OS2web'
5+
core_version_requirement: ^9 || ^10

os2web_key.services.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
logger.channel.os2web_key:
3+
parent: logger.channel_base
4+
arguments: [ 'os2web_key' ]
5+
6+
Drupal\os2web_key\CertificateHelper:
7+
arguments:
8+
- '@logger.channel.os2web_key'

phpcs.xml.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="PHP_CodeSniffer">
3+
<description>PHP Code Sniffer configuration</description>
4+
5+
<file>.</file>
6+
<exclude-pattern>vendor/</exclude-pattern>
7+
8+
<!-- Show progress of the run -->
9+
<arg value="p"/>
10+
<arg value="s"/>
11+
12+
<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/>
13+
<config name="drupal_core_version" value="10"/>
14+
15+
<rule ref="Drupal">
16+
<!-- We want to be able to use "package" and "version" in our custom modules -->
17+
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/>
18+
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>
19+
</rule>
20+
21+
<rule ref="DrupalPractice"/>
22+
</ruleset>

0 commit comments

Comments
 (0)