Skip to content

Commit cdf3cc3

Browse files
author
Reng van Oord
committed
Implemented lightweight version of signon plugin
1 parent 05b4f9c commit cdf3cc3

File tree

6 files changed

+597
-0
lines changed

6 files changed

+597
-0
lines changed

.env-example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OIDC_CLIENT_ID=YOUR_CLIENT_ID
2+
OIDC_CLIENT_SECRET=YOUR_CLIENT_SECRET

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.vs/
2+
data/mysql/*
3+
.env

docker-compose.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: '3.2'
2+
3+
services:
4+
5+
mysql:
6+
container_name: 'local-wordpress-db'
7+
image: 'mysql:5.7'
8+
volumes:
9+
- './data/mysql:/var/lib/mysql'
10+
ports:
11+
- 18766:3306
12+
environment:
13+
MYSQL_ROOT_PASSWORD: wordpress_root_password
14+
MYSQL_DATABASE: wordpress_db
15+
MYSQL_USER: wordpress_user
16+
MYSQL_PASSWORD: wordpress_password
17+
networks:
18+
- wp
19+
restart: unless-stopped
20+
21+
wordpress:
22+
container_name: 'local-wordpress'
23+
depends_on:
24+
- mysql
25+
image: 'wordpress:latest'
26+
ports:
27+
- 80:80
28+
- 443:443
29+
env_file:
30+
- ./.env #Create this file locally, using .env-example as a guide
31+
environment:
32+
WORDPRESS_DB_HOST: 'mysql:3306'
33+
WORDPRESS_DB_USER: wordpress_user
34+
WORDPRESS_DB_PASSWORD: wordpress_password
35+
WORDPRESS_DB_NAME: wordpress_db
36+
WORDPRESS_DEBUG: 1
37+
OIDC_CLIENT_ID: ${OIDC_CLIENT_ID}
38+
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET}
39+
volumes:
40+
- "./plugins/bcc-login:/var/www/html/wp-content/plugins/bcc-login"
41+
networks:
42+
- wp
43+
restart: unless-stopped
44+
45+
phpmyadmin:
46+
container_name: 'local-wordpress-phpmyadmin'
47+
image: phpmyadmin/phpmyadmin
48+
environment:
49+
PMA_HOST: mysql
50+
MYSQL_ROOT_PASSWORD: wordpress_root_password
51+
depends_on:
52+
- mysql
53+
ports:
54+
- 8080:80
55+
networks:
56+
- wp
57+
restart: unless-stopped
58+
59+
networks:
60+
wp:
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
Plugin Name: BCC Login Plugin
5+
Description: Integration to BCC's Login System.
6+
Version: $_PluginVersion_$
7+
Author: BCC IT
8+
License: GPL2
9+
*/
10+
11+
require_once('includes/class-auth-settings.php');
12+
require_once('includes/class-auth-client.php');
13+
14+
class BCC_Login_Plugin {
15+
16+
/**
17+
* Initialize plugin
18+
*/
19+
static function init_plugin(){
20+
$plugin = new self();
21+
register_activation_hook( __FILE__, array( 'OpenID_Connect_Generic', 'activation' ) );
22+
register_deactivation_hook( __FILE__, array( 'OpenID_Connect_Generic', 'deactivation' ) );
23+
}
24+
25+
/**
26+
* Activate plugin hook
27+
* Called when plugin is activated
28+
*/
29+
static function activate_plugin() {
30+
31+
}
32+
33+
/**
34+
* Deactivate plugin hook
35+
* Called when plugin is deactivated
36+
*/
37+
static function deactivate_plugin() {
38+
39+
}
40+
41+
private Auth_Settings $_settings;
42+
private Auth_Client $_client;
43+
44+
function __construct() {
45+
$settings_provider = new Auth_Settings_Provider();
46+
$this->_settings = $settings_provider->get_settings();
47+
$this->_client = new Auth_Client($this->_settings);
48+
49+
// Add init handler
50+
add_action( 'init', array( $this, 'on_init' ) );
51+
52+
// Add privacy handlers
53+
add_action( 'template_redirect', array( $this, 'on_template_redirect' ), 0 );
54+
add_filter( 'the_content_feed', array( $this, 'filter_the_content_feed' ), 999 );
55+
add_filter( 'the_excerpt_rss', array( $this, 'filter_the_excerpt_rss' ), 999 );
56+
add_filter( 'comment_text_rss', array( $this, 'filter_comment_text_rss' ), 999 );
57+
58+
}
59+
60+
function on_init(){
61+
62+
}
63+
64+
function on_template_redirect(){
65+
$this->_client->ensure_authenticated();
66+
}
67+
68+
function filter_the_content_feed( $content ){
69+
return $content;
70+
}
71+
72+
function filter_the_excerpt_rss( $content ) {
73+
return $content;
74+
}
75+
76+
function filter_comment_text_rss( $content ) {
77+
return $content;
78+
}
79+
}
80+
81+
// Initialize plugin
82+
BCC_Login_Plugin::init_plugin();

0 commit comments

Comments
 (0)