Skip to content

Commit 98dee73

Browse files
authored
Merge pull request #10 from alan-turing-institute/9-fix-architecture-builds
Fix architecture builds
2 parents d6370a2 + 0d7734e commit 98dee73

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

.github/workflows/build-release.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,35 @@ jobs:
1212
releases-matrix:
1313
name: Create release-artifacts
1414
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
# build and publish in parallel
18-
goos: [linux]
19-
goarch: ["386", "amd64", "arm", "arm64"]
2015
steps:
2116
- name: Check out the repository
2217
uses: actions/checkout@v2
2318

24-
- name: Setup golang version
19+
- name: Setup Go build tools
2520
uses: actions/setup-go@v2
2621
with:
2722
go-version: '^1.18'
2823

29-
- name: Install dependencies
30-
run: sudo apt-get install -y libpam-dev
24+
- name: Update package repositories
25+
run: sudo apt update
26+
27+
- name: Setup C++ build tools
28+
run: sudo apt install -y gcc make
29+
30+
- name: Install build dependencies
31+
run: sudo apt install -y libcurl4-openssl-dev libjansson-dev libpam-dev unzip
3132

3233
- name: Generate the artifacts
3334
run: |
35+
# Build pam_aad_oidc.so
36+
make
37+
38+
# Build libnss
39+
wget https://github.com/hmeiland/linuxaad/archive/refs/tags/v0.3.1.zip
40+
unzip v0.3.1.zip
41+
cd linuxaad-0.3.1/libnss_aad/
3442
make
35-
mv pam_aad_oidc.so pam_aad_oidc.${{ matrix.goarch }}.so
43+
mv .libs/libnss_aad.so.2.0 ../../libnss_aad.so
3644
3745
- name: Upload the artifacts
3846
uses: skx/github-action-publish-binaries@master

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ This code is based on code from [`pam-keycloak-oidc`](https://github.com/zhaow-d
2828
- You must **record the value** of this secret at creation time, as it will not be visible later.
2929

3030
3. Under `API permissions`:
31-
- Ensure that `Microsoft Graph > User.Read` is enabled
31+
- Ensure that the following permissions are enabled
32+
- `Microsoft Graph > User.Read.All` (delegated)
33+
- `Microsoft Graph > GroupMember.Read.All` (delegated)
3234
- Select this and click the `Grant admin consent` button (otherwise manual consent is needed from each user)
3335

3436
## Configure local client
@@ -49,24 +51,41 @@ This code is based on code from [`pam-keycloak-oidc`](https://github.com/zhaow-d
4951
# The (time-limited) client secret generated for this application above
5052
client-secret="jbi58~72en43pqpdvwg6enb8r0ml3-hq-0ip2s9c"
5153

52-
# Microsoft.Graph scope to be requested. Unless there is a particular reason not to, use 'user.read'.
53-
scope="user.read"
54-
5554
# Name of AAD group that authenticated users must belong to
5655
group-name="Allowed PAM users"
5756

5857
# Default domain for AAD users. This will be appended to any users not in `username@domain` format.
5958
domain="mydomain.onmicrosoft.com"
6059
```
6160

62-
4. Add configuration lines to the relevant PAM module, referencing the `TOML` file you wrote above.
63-
For example, for testing purposes you can add the following to `/etc/pam.d/test`
61+
4. Create a PAM config file at `/usr/share/pam-configs/aad_oidc` referencing the `TOML` file you wrote above:
62+
```none
63+
Name: Allow AzureAD login
64+
Default: no
65+
Priority: 129
66+
Auth-Type: Primary
67+
Auth:
68+
[success=end default=ignore] pam_aad_oidc.so config=/etc/pam-aad-oidc.toml
69+
Auth-Initial:
70+
[success=end default=ignore] pam_aad_oidc.so config=/etc/pam-aad-oidc.toml
71+
```
72+
73+
4. Install the module with the following command
74+
75+
```bash
76+
> pam-auth-update --enable aad_oidc
77+
```
78+
79+
## Testing local client
80+
You can test the module with a dummy PAM entry point.
81+
82+
1. For testing purposes you can add the following to `/etc/pam.d/test`, referencing the `TOML` file you wrote above
6483

6584
```none
6685
auth required pam_aad_oidc.so config=/etc/pam-aad-oidc.toml
6786
```
6887

69-
5. Install `pamtester` in order to test the module.
88+
2. Install `pamtester` in order to test the module.
7089

7190
```shell
7291
# With the password for `myusername` in the file `password.secret`

azuread.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type Config struct {
1818
TenantID string `toml:"tenant-id"`
1919
ClientId string `toml:"client-id"`
2020
ClientSecret string `toml:"client-secret"`
21-
Scope string `toml:"scope"`
2221
GroupName string `toml:"group-name"`
2322
Domain string `toml:"domain"`
2423
}
@@ -67,7 +66,7 @@ func ValidateCredentials(configPath string, username string, password string) in
6766
TokenURL: "https://login.microsoftonline.com/" + config.TenantID + "/oauth2/v2.0/token",
6867
},
6968
RedirectURL: "urn:ietf:wg:oauth:2.0:oob", // this is the "no redirect" URL
70-
Scopes: []string{config.Scope},
69+
Scopes: []string{"https://graph.microsoft.com/.default"}, // use the default scopes registered with the application
7170
}
7271

7372
// If there is no suffix then use the default domain

pam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <security/pam_ext.h>
88

99
// Local includes
10-
#include <pam.h>
10+
#include "pam.h"
1111

1212

1313
// Retrieve a username from a PAM handle

pam.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
#cgo CFLAGS: -Wall
1010
#include <security/pam_appl.h>
1111
#include <stdlib.h>
12-
#include <pam.h>
12+
#include "pam.h"
1313
*/
1414
import "C"
1515

0 commit comments

Comments
 (0)