Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFPKI intune support #6360

Merged
merged 38 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
41df77c
Updated code to use the new scep lib
fdurand Apr 21, 2021
ab6c514
Added profile
fdurand Apr 21, 2021
4f48183
Updated go.mod
fdurand Apr 21, 2021
a6fa354
Updated go.mod
fdurand Apr 22, 2021
079cfea
Updated go.mod
fdurand Apr 22, 2021
72dea8b
Make pki profile editeable
fdurand Apr 22, 2021
09dbb49
First draft of the admin gui (Cloud services)
fdurand Apr 23, 2021
85794fd
Added minimum Cloud config
fdurand Apr 23, 2021
351abdc
Fixed typo
fdurand Apr 23, 2021
85e8870
SImplify the form
fdurand Apr 26, 2021
aca586c
Renamed SSO to Service
fdurand Apr 26, 2021
7ab7819
Simplify the view.
fdurand Apr 26, 2021
5f45899
REdifined the form
fdurand Apr 26, 2021
bf58ecc
Clean form
fdurand Apr 27, 2021
5d6570d
Fixed form
fdurand Apr 27, 2021
a37d29c
Fixed cloud selection in pki profiles
fdurand Apr 27, 2021
8bc813c
Display only the name
fdurand Apr 28, 2021
76161f4
Regroup SCEP and Cloud
fdurand Apr 28, 2021
89d65a2
Added Cloud in pfconfigdriver struct
fdurand Apr 28, 2021
ec41ca5
Added draft of intune/pki api call
fdurand Apr 28, 2021
c9ced83
Draft of the middleware for scep check
fdurand Apr 28, 2021
4e826c3
Added cloud models
fdurand Apr 28, 2021
6c9d3c6
Update sql schema
fdurand Apr 28, 2021
a0fb6bf
Fixed update profile
fdurand Apr 29, 2021
967303e
Updated Intune api client
fdurand Apr 29, 2021
a246447
Updated intune code + added profiles values to signer
fdurand May 6, 2021
2ad84d5
Updated scep lib
fdurand May 6, 2021
2c068ab
Initialize the map
fdurand May 6, 2021
414e6bc
Added notifications
fdurand May 10, 2021
cf5c8fd
Fixed intune notifications
fdurand May 11, 2021
77715be
Added a path in scep api
fdurand May 11, 2021
0793311
Documentation draft
fdurand May 13, 2021
64cb794
Updated documentation
fdurand May 13, 2021
7d1546f
Use inverse-inc/scep lib
fdurand May 13, 2021
2f880f8
Hide Azure and Google from the admin gui
fdurand May 14, 2021
bf6ebc0
Removed reference to Azure and Google cloud
fdurand Jun 29, 2021
7491c50
Fixed db schema upgrade
fdurand Jul 5, 2021
24cfff4
Added cloud.conf in .gitignore
fdurand Jul 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ conf/haproxy-admin.conf
conf/keepalived.conf
conf/report.conf
conf/device_registration.conf
conf/cloud.conf
conf/httpd.conf.d/captive-portal-common.tt
conf/httpd.conf.d/httpd.aaa.tt
conf/httpd.conf.d/httpd.admin.tt
Expand Down
1 change: 1 addition & 0 deletions conf/cloud.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Copyright (C) Inverse inc.
2 changes: 2 additions & 0 deletions db/pf-schema-X.Y.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,8 @@ CREATE TABLE `pki_profiles` (
`scep_enabled` int(11) DEFAULT NULL,
`scep_challenge_password` varchar(255) DEFAULT NULL,
`scep_days_before_renewal` varchar(255) DEFAULT NULL,
`cloud_enabled` int(11) DEFAULT NULL,
`cloud_service` varchar(255) DEFAULT NULL,
UNIQUE KEY `name` (`name`),
KEY `idx_profiles_deleted_at` (`deleted_at`),
KEY `ca_id` (`ca_id`),
Expand Down
4 changes: 4 additions & 0 deletions db/upgrade-X.X-X.Y.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ DELIMITER ;
call ValidateVersion;
DROP PROCEDURE IF EXISTS ValidateVersion;

\! echo "altering pki_profiles"
ALTER TABLE pki_profiles
ADD COLUMN IF NOT EXISTS `cloud_enabled` int(11) DEFAULT NULL AFTER scep_days_before_renewal,
ADD COLUMN IF NOT EXISTS `cloud_service` varchar(255) DEFAULT NULL AFTER cloud_enabled;

\! echo "Incrementing PacketFence schema version...";
INSERT IGNORE INTO pf_version (id, version, created_at) VALUES (@VERSION_INT, CONCAT_WS('.', @MAJOR_VERSION, @MINOR_VERSION), NOW());
Expand Down
1 change: 1 addition & 0 deletions debian/packetfence.conffiles
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/usr/local/pf/conf/billing_tiers.conf
/usr/local/pf/conf/chi.conf
/usr/local/pf/conf/cluster.conf
/usr/local/pf/conf/cloud.conf
jrouzierinverse marked this conversation as resolved.
Show resolved Hide resolved
/usr/local/pf/conf/pfcron.conf
/usr/local/pf/conf/dhcp_filters.conf
/usr/local/pf/conf/dhcp_fingerprints.conf
Expand Down
Binary file added docs/images/Intune-1-App-Registration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-10-PacketFence-SCEP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-2-Register-Application.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-3-App-Detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-5-Add-Client-Secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-6-Copy-Client-Secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-7-API-Permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Intune-8-Grant-Admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/packetfence-pki-scep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions docs/installation/pki/packetfence.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,78 @@ Key usage serverAuth: If you want to install your certificate on a server.

image::packetfence-pki-template_password_email.png[scaledwidth="100%",alt="Template configuration"]

===== SCEP

You can choose to enable SCEP on this template.

image::packetfence-pki-scep.png[scaledwidth="100%",alt="SCEP configuration"]

====== SCEP Test

Let's do a scep request by hand.
Directly from the PacketFence server do that:

Create a private key and a csr file:

openssl req -newkey rsa:2048 -keyout PRIVATEKEY.key -out MYCSR.csr

Generating a 2048 bit RSA private key
.........................................................................................................................................................................+++
.........................+++
writing new private key to 'PRIVATEKEY.key'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CA
State or Province Name (full name) []:QC
Locality Name (eg, city) [Default City]:Montreal
Organization Name (eg, company) [Default Company Ltd]:Acme
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:acme.com
Email Address []:admin@acme.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:password
An optional company name []:

Get the CA certificate:

sscep getca -u http://ip_address/scep/template_name -c ./ca-prefix -i MyPKI -v -d

sscep: starting sscep, version 0.6.1
sscep: new transaction
sscep: transaction id: SSCEP transactionId
sscep: hostname: ip_address
sscep: directory: scep/template_name
sscep: port: 80
sscep: SCEP_OPERATION_GETCA
sscep: requesting CA certificate
sscep: scep msg: GET /scep/template_name?operation=GetCACert&message=MyPKI HTTP/1.0

sscep: server returned status code 200
sscep: MIME header: application/x-x509-ca-cert
sscep: valid response from server
sscep: MD5 fingerprint: 22:DE:09:17:8B:5F:94:1E:EB:0D:9C:12:EF:05:F0:C5
sscep: CA certificate written as ./ca-prefix

Remove the private key passphrase:

openssl rsa -in PRIVATEKEY.key -out private.key
Enter pass phrase for PRIVATEKEY.key:
writing RSA key

Send the CSR and retreive the certificate:

scep enroll -c ./ca-prefix -k ./private.key -r ./MYCSR.csr -u http://ip_address/scep/template_name -S sha1 -l ./cert.crt

==== Certificate creation

image::packetfence-pki-certificate_menu.png[scaledwidth="100%",alt="Certificate creation"]
Expand Down Expand Up @@ -98,3 +170,79 @@ image::packetfence-pki-pki-provider_menu.png[scaledwidth="100%",alt="PKI Provide
===== Create a certificate per user or per device mac address, this example will cover one certificate per device:

image::packetfence-pki-pki-provider_creation.png[scaledwidth="100%",alt="PKI Provider"]


==== Intune Integration

===== Azure configuration

You can hand out certificates when you use intune enrolment.

First you need to create an application on Azure that allow PacketFence to connect to the Intune API.

To do that first you have to go in Azure portal and App registration then click *New registration*

image::Intune-1-App-Registration.png[scaledwidth="100%",alt="App-Registration"]

Next set a Name and in "Supported account types" select "Accounts in this organizational directory only" then click *Register*

image::Intune-2-Register-Application.png[scaledwidth="100%",alt="Register-Application"]

On the next page you have to copy the "Application (Client) ID" and the "Directory (tenant) ID", thoses will be needed to configure PacketFence.

image::Intune-3-App-Detail.png[scaledwidth="100%",alt="Application-Detail"]

Then you need to generate a "Client secrets", to do that click on "Add a certificate or secret"

image::Intune-4-App-Certificates-Secrets.png[scaledwidth="100%",alt="App-Certificates-Secrets"]

image::Intune-5-Add-Client-Secret.png[scaledwidth="100%",alt="Add-Client-Secret"]

Copy the "Value" of the secret, this is the only time you should be able to see it.

image::Intune-6-Copy-Client-Secret.png[scaledwidth="100%",alt="Copy-Client-Secret"]

Next you have to add API permissions, click on "API permissions" -> "Add a Permissions" and search for Intune and select "scep_challenge_provider".

image::Intune-7-API-Permissions.png[scaledwidth="100%",alt="API-Permissions"]

Last step is to "Grant admin", just click on "Grant admin consent for ..." and click *Yes*

image::Intune-8-Grant-Admin.png[scaledwidth="100%",alt="Grant-Admin"]

===== PacketFence configuration

====== Intune definition

First of all you have to define the configuration parameters to reach the Intune API.
To do that go in Configuration -> Integration -> Cloud Services -> New Cloud -> Microsoft Intune

Next fill the field with the values taken from the Azure portal ("Application (Client) ID" , "Directory (tenant) ID" and "Client secrets") and *Create*.

image::Intune-9-PacketFence-Intune.png[scaledwidth="100%",alt="PacketFence-Intune"]

====== SCEP configuration

Now let's configure the PKI template to enable SCEP on it. (go to the previous section on how to configure a template in the PKI)

Go in Configuration -> Integration -> PKI -> Templates and edit the one you created previously.

You can see that there is a SCEP section. Enable SCEP and check Enable Cloud Integration and select the Cloud Service you created previously. (In the case the SCEP challenge password is not mandatory).

image::Intune-10-PacketFence-SCEP.png[scaledwidth="100%",alt="PacketFence-SCEP"]

Starting from now the scep server will be available on each ip where the portal is running (you need to enable the portal on the management interface if you want to be able to do SCEP on this interface).

The URL of the SCEP server will be available on http://ip_addresse/scep/template_name (https too) where template_name is the name of your template in the PKI.



===== Intune configuration

For this section you can follow the instruction on the Microsoft web site:

https://docs.microsoft.com/en-us/mem/intune/protect/certificates-profile-scep

From the PacketFence server you will need to extract the PKI Ca certificate associated to the template and put it in Intune as a "trusted certificate"

Then set the SCEP URL to http://ip_addresse/scep/template_name or https://ip_addresse/scep/template_name
10 changes: 10 additions & 0 deletions go/caddy/pfpki/certutils/certutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"encoding/asn1"
"encoding/pem"
"errors"
"fmt"
"io"
"io/ioutil"
"math/big"
Expand Down Expand Up @@ -356,3 +357,12 @@ func GetDNFromCert(namespace pkix.Name) map[string]string {
}
return attributeMap
}

func ThumbprintSHA1(cert *x509.Certificate) string {
sum := sha1.Sum(cert.Raw)
hex := make([]string, len(sum))
for i, b := range sum {
hex[i] = fmt.Sprintf("%02X", b)
}
return strings.Join(hex, ":")
jrouzierinverse marked this conversation as resolved.
Show resolved Hide resolved
}
30 changes: 30 additions & 0 deletions go/caddy/pfpki/cloud/cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cloud

import (
"context"
"crypto/x509"
"fmt"
)

type Cloud interface {
NewCloud(ctx context.Context, name string)
ValidateRequest(ctx context.Context, data []byte) error
SuccessReply(ctx context.Context, cert *x509.Certificate, data []byte, message string) error
FailureReply(ctx context.Context, cert *x509.Certificate, data []byte, message string) error
}

// Creater function
type Creater func(context.Context, string) (Cloud, error)

var cloudLookup = map[string]Creater{
"intune": NewIntuneCloud,
}

// Create function
func Create(ctx context.Context, cloudType string, name string) (Cloud, error) {
if creater, found := cloudLookup[cloudType]; found {
return creater(ctx, name)
}

return nil, fmt.Errorf("Cloud of %s not found", cloudType)
}
Loading