Merge branch 'v3.0.x' into tr-integ
[freeradius.git] / raddb / policy.d / abfab-tr
1 #
2 #  ABFAB Trust router policies.
3 #
4 #       $Id$
5 #
6
7
8 #
9 # Verify rp parameters
10 #
11 psk_authorize {
12         if (TLS-PSK-Identity) {
13                 # TODO: may need to check trust-router-apc as well
14                 if ("%{psksql:select distinct keyid from authorizations_keys where keyid = '%{tls-psk-identity}' and '%{trust-router-coi}' like coi and '%{gss-acceptor-realm-name}' like acceptor_realm and '%{gss-acceptor-host-name}' like hostname;}") {
15                         # do things here
16                 }
17                 else {
18                         reject
19                 }
20         }
21 }
22
23 abfab_pre_proxy {
24         # check that the acceptor host name is correct
25         if ("%{client:gss_acceptor_host_name}" && "%{gss-acceptor-host-name}") {
26                 if ("%{client:gss_acceptor_host_name}" != "%{gss-acceptor-host-name}") {
27                         reject
28                 }
29         }
30
31         # set trust-router-coi attribute from the client configuration
32         if ("%{client:trust_router_coi}") {
33                 update proxy-request {
34                         Trust-Router-COI := "%{client:trust_router_coi}"
35                 }
36         }
37
38         # set gss-acceptor-realm-name attribute from the client configuration
39         if ("%{client:gss_acceptor_realm_name}") {
40                 update proxy-request {
41                         GSS-Acceptor-Realm-Name := "%{client:gss_acceptor_realm_name}"
42                 }
43         }
44 }
45
46 #  A policy which is used to validate channel-bindings.
47 #
48 abfab_channel_bindings {
49         if (GSS-Acceptor-Service-Name && (outer.request:GSS-Acceptor-Service-Name != GSS-Acceptor-Service-Name)) {
50                 reject
51         }
52
53         if (GSS-Acceptor-Host-Name && outer.request:GSS-Acceptor-Host-Name != GSS-Acceptor-Host-Name ) {
54                 reject
55         }
56
57         if (GSS-Acceptor-Realm-Name && outer.request:GSS-Acceptor-Realm-Name != GSS-Acceptor-Realm-Name ) {
58                 reject
59         }
60
61         if (GSS-Acceptor-Service-Name || GSS-Acceptor-Realm-Name || GSS-Acceptor-Host-Name) {
62                 update control {
63                         Chbind-Response-Code := success
64                 }
65
66                 #
67                 #  ACK the attributes in the request.
68                 #
69                 #  If any one of these attributes don't exist in the request,
70                 #  then they won't be copied to the reply.
71                 #
72                 update reply {
73                         GSS-Acceptor-Service-Name = &GSS-Acceptor-Service-Name
74                         GSS-Acceptor-Host-Name = &GSS-Acceptor-Host-Name
75                         GSS-Acceptor-Realm-Name = &GSS-Acceptor-Realm-Name
76                 }
77         }
78
79         #
80         #  Return "handled" so that the "authenticate" section isn't used.
81         #
82         handled
83 }