annotate doc/src/site/markdown/auth.md @ 1655:7310735dd5b5

Refactoring of the configuration docs
author Frank Sachsenheim <funkyfuture@riseup.net>
date Thu, 17 Aug 2017 16:20:23 +0200
parents 70e1225fe08c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
1 # Access control
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
2
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
3 If all your images are free and available to everybody or if your server is not
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
4 reachable from the internet then congratulations, you can run digilib without
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
5 authorization: Leave the [digilib-config](digilib-config.html) setting
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
6
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
7 use-authorization=false
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
8
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
9 and ignore the rest of this chapter.
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
10
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
11 But if you have some images that are freely available and others
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
12 that should be only visible to some users then you need to set
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
13
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
14 use-authorization=true
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
15
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
16 and configure digilib's authentication and authorization mechanism.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
17
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
18 ## Authentication and authorization
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
19
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
20 digilib has different mechanisms for the tasks of *authentication* - establishing
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
21 the identity of the user requesting the image (more accurately the roles associated to
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
22 this identity) - and *authorization* - establishing the rules for accessing specific
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
23 images (the roles required to access the image).
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
24
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
25 The authe<b>n</b>tication mechanism is implemented by the digilib.auth.Auth<b>n</b>Ops interface
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
26 implemented through the class configured in the `digilib-config` parameter
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
27 `authnops-class` while the authori<b>z</b>ation mechanism is implemented by the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
28 digilib.auth.Auth<b>z</b>Ops interface implemented through the class configured in
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
29 `authzops-class`.
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
30
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
31 All authentication and authorization classes are configured through different elements
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
32 in the XML config file
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
33
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
34 digilib-auth.xml
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
35
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
36 in the `WEB-INF` directory (the file name can be configured with the `digilib-config`
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
37 parameter `auth-file`).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
38
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
39 In short: you need to set both `authnops-class` and `authzops-class` in `digilib-config` with
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
40 two of the classes described below (or implement your own) and create a `digilib-auth.xml` file
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
41 with the configuration for the chosen implementations.
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
42
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
43 ### Authentication: IpAuthnOps
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
44
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
45 `digilib.auth.IpAuthnOps` assigns roles based on the IP address of the user requesting the
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
46 image. This works well for situations where all users of the local network are allowed to
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
47 access resources. The class reads the tag `digilib-adresses` from `digilib-auth.xml`:
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
48
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
49 <digilib-addresses>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
50 <address ip="130.92.68" role="eastwood-coll,ptolemaios-geo" />
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
51 <address ip="130.92.151" role="wtwg" />
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
52 <address ip="0:0:0:0:0:0:0:1" role="local" />
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
53 </digilib-addresses>
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
54
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
55 A computer with an ip address that matches `ip` is automatically granted all roles under `role`.
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
56 The ip address is matched from the left (in full quads). Roles under "role" must be separated by comma only (no spaces).
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
57
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
58 Caution: If you run your Servlet Container (Tomcat) behind Apache or another reverse proxy
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
59 then Tomcat only sees the IP address of the proxy server for all connections. You need to
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
60 configure Tomcat to honor the `X-Forwarded-For` and `X-Forwarded-Proto` headers.
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
61
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
62 ### Authentication: IpServletAuthnOps
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
63
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
64 `digilib.auth.IpServletAuthnOps` assigns roles based on the IP address of the user requesting
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
65 the image (see `IpAuthnOps` above) and uses the `ServletRequest.isUserInRole()` function of
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
66 the Servlet Container if the roles provided by the IP address are not sufficient.
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
67
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
68 Using authentication information from the Servlet Container requires that the Servlet Container
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
69 is configured for authentication. For information about this please refer to the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
70 documentation of your Servlet Container.
1528
08d64f3d1f76 beginning of auth documentation.
robcast
parents:
diff changeset
71
1530
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
72 For Tomcat 8 there is documentation at
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
73 (https://tomcat.apache.org/tomcat-8.0-doc/realm-howto.html)[https://tomcat.apache.org/tomcat-8.0-doc/realm-howto.html]
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
74 Note that you need to configure a `<security-constraint>` in `web.xml` to force the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
75 server to ask for a password (there is an old example in `web-additional.xml`).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
76
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
77 ### Authentication: OpenIdAuthnOps
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
78
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
79 `digilib.auth.OpenIdAuthnOps` assigns roles based on an [OpenId-Connect](http://openid.net/) token
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
80 passed with the request. The token can be passed either in the URL parameter `id_token` or as a cookie
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
81 with the name `id_token` (the name of the cookie can be configured with the `digilib-config`
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
82 parameter `authn-token-cookie`).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
83
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
84 The class reads the tag `digilib-oauth` from `digilib-auth.xml`:
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
85
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
86 <digilib-oauth>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
87 <openid issuer="https://id.some.where" clientid="myclient" roles="openid-users" keytype="jwk">
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
88 {"kty":"RSA","e":"AQAB","kid":"rsa1","alg":"RS256","n":"qt6yOiI_wCoCVlGO0MySsez...Lf9by7TGw"}
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
89 </openid>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
90 </digilib-oauth>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
91
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
92 The `openid` tag defines roles (in `role`, separated by comma only, no spaces)
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
93 that will be granted to the user that provides a valid token from the given server.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
94 The server is identified by the url in `issuer`, the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
95 client id in `clientid` and the public key of the server in JWK format as content
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
96 of the tag. There can be multiple `openid` tags.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
97
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
98 To set up a connection with an OpenId-Connect identity server you usually have to enter the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
99 URL of your digilib instance as a redirect URL and the client id that you chose
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
100 and make sure that the server answers requests with `response_type=id_token`. The public
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
101 key of the server in JWK format can often be requested from the server by adding `/jwk` to
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
102 the URL.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
103
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
104 To automatically authenticate with OpenId in the digilib Javascript frontend you can use the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
105 digilib plugin `jquery.digilib.oauth.js` and configure it with the URL of the ID server as
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
106 `authServerUrl` and the client id as `authClientId`. This will give you an extra login button
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
107 that authenticates the user by redirecting her to the ID server. You can additionally set
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
108 `authOnErrorMode` to true to automatically authenticate the user whenever the image from
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
109 the digilib server doesn't load which is usually caused by missing authentication
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
110 (there is an example in `jquery/digilib-auth.html`).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
111
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
112 ### Authentication: IpOpenIdAuthnOps
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
113
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
114 `digilib.auth.IpOpenIdAuthnOps` assigns roles based on the IP address of the user requesting
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
115 the image (see `IpAuthnOps` above) and uses an OpenId-Connect token passed with the request
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
116 (see `OpenIdAuthnOps` above) if the roles provided by the IP address are not sufficient.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
117
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
118 ### Authorization: PathAuthzOps
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
119
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
120 `digilib.auth.PathAuthzOps` requests roles based on the directory path of the requested image.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
121 All images in the given directory and all its subdirectories can be accessed only if the user
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
122 can provide one of the requested roles.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
123
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
124 The class reads the tag `digilib-paths` from `digilib-auth.xml`:
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
125
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
126 <digilib-paths>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
127 <path name="histast/eastwood-collection" role="eastwood-coll"/>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
128 <path name="documents/nonpublic" role="openid-user,eastwood-coll"/>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
129 </digilib-paths>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
130
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
131 A user must supply one of the roles in `role` to access the directory in `name`.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
132 Roles in `role` must be separated by comma only (no spaces).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
133
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
134 ### Authorization: MetaAccessAuthzOps
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
135
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
136 `digilib.auth.MetaAccessAuthzOps` requests roles using "access" information in the file metadata.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
137
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
138 This requires a `FileMeta` implementation (configured in the `filemeta-class` parameter of
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
139 `digilib-config`) that provides an `access` key in the metadata returned by `DocuDirent.getMeta().getFileMeta()`
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
140 like `digilib.meta.IndexMetaFileMeta`.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
141
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
142 The class reads the tag `digilib-access` from `digilib-auth.xml`:
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
143
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
144 <digilib-access>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
145 <access type="group:mpiwg" role="mpiwg-user"/>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
146 <access type="default" role=""/>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
147 </digilib-access>
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
148
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
149 A user must supply one of the roles in `role` to access any object with a metadata access value
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
150 matching `type`.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
151 Roles in `role` must be separated by comma only (no spaces).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
152
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
153 The access type `default` is special, it applies to all objects without metadata access information.
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
154
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
155 `digilib.meta.IndexMetaFileMeta` reads XML files conforming to the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
156 ["index.meta" specification](http://intern.mpiwg-berlin.mpg.de/digitalhumanities/mpiwg-metadata-documentation/formate/indexmeta-standard)
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
157 and extracts image information from the `meta/img` tag and access information from the
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
158 `meta/access-conditions` tag (see also class `digilib.meta.IndexMetaAuthLoader`).
70e1225fe08c added auth* documentation.
robcast
parents: 1528
diff changeset
159