README.md 2.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# dariahsp

This library contains a wrapper for Spring Security SAML, along with extensions useful particularly for the context of DARIAH-DE. Fundamentally, this library distinguishes two authentication methods: the *local* method is intended primarily for developer and test setups, the *saml* method is targeted towards production environments.

## Authentication methods

### Local

To support local authentication, configure this library as in the *security-local-context.xml* template. To complete the setup for this method, applications might want to implement the *UserService* interface (base implementation *BaseUserService*) to provide access to persisted user information.

The implementation needs to be provided to the *LocalAuthenticationProvider*.

In cases that do not require user detail persistence, no implementation of the *UserDetails* should be provided to the *LocalAuthenticationProvider*.  

15
16
17
18
19
To create sha256 hashes on linux shells, you can use the following command (replace foo with the desired password):
```
$ echo -n foo | openssl dgst -binary -sha1 | openssl base64
```

20
21
22
23
24
25
26
27
28
### SAML

## Further info

### Java keystore

Based on a X.509 keypair and certificate chains, the required Java keystore can easily be consolidated with `openssl` and the `keytool` (comes with Java installation). The followings steps show the commands for the example of the keystore for dfa.de.dariah.eu and the appropriate input. Please modify accordingly:

**Convert pem/pem keypair to p12 for easier input:**
29
For the -name argument make sure to chose the later alias of the keypair in the keystore -- specified in the following step with the -alias argument.
30
31

```
32
$ openssl pkcs12 -export -name dfa.de.dariah.eu -in dfa-de-dariah-eu-signed.pem -inkey dfa-de-dariah-eu-privatekey.pem > dfa-de-dariah-eu.p12
33
34
35
36
37
```

**Import p12 keypair and create Java keystore**

```
38
$ keytool -importkeystore -alias dfa.de.dariah.eu -srckeystore dfa-de-dariah-eu.p12 -destkeystore dfa-de-dariah-eu.jks -srcstoretype pkcs12
39
40
41
42
43
44
45
46
```

**Import required trusted ca certificates (in our case the chain of our keypair and the trusted SAML metadata provider keychains)**

```
$ keytool -import -trustcacerts -alias gwdg_certificate_chain_g2 -file gwdg_certificate_chain_g2.pem -keystore dfa-de-dariah-eu.jks 
$ keytool -import -trustcacerts -alias dfn-aai -file dfn-aai.pem -keystore dfa-de-dariah-eu.jks
$ keytool -import -trustcacerts -alias dfn-aai-g2 -file dfn-aai.g2.pem -keystore dfa-de-dariah-eu.jks
47
48
```

49
50
51
52
53
54
55
56
57
A more or less convenient option to view and edit Java keystore can be found in the [KeyStore Explorer](http://keystore-explorer.org/) 

**Specify configuration parameters**
```
saml.keystore.path = /path/to/dfa-de-dariah-eu.jks
saml.keystore.pass = password 		# as entered in step 2 (keytool -importkeystore)
saml.keystore.alias = dfa.de.dariah.eu
saml.keystore.aliaspass = password	# as entered in step 1 (openssl pkcs12 -export) 
```