more &
[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                 update reply {
19                         Reply-Message = "RP not authorized for this ABFAB request"
20                         }
21                         reject
22                 }
23         }
24 }
25
26 abfab_client_check {
27         # check that the acceptor host name is correct
28         if ("%{client:gss_acceptor_host_name}" && &gss-acceptor-host-name) {
29                 if ("%{client:gss_acceptor_host_name}" != "%{gss-acceptor-host-name}") {
30                         update reply {
31                                 Reply-Message = "GSS-Acceptor-Host-Name incorrect"
32                                 }
33                         reject
34                 }
35         }
36
37         # set trust-router-coi attribute from the client configuration
38         if ("%{client:trust_router_coi}") {
39                 update request {
40                         Trust-Router-COI := "%{client:trust_router_coi}"
41                 }
42         }
43
44         # set gss-acceptor-realm-name attribute from the client configuration
45         if ("%{client:gss_acceptor_realm_name}") {
46                 update request {
47                         GSS-Acceptor-Realm-Name := "%{client:gss_acceptor_realm_name}"
48                 }
49         }
50 }
51
52 #  A policy which is used to validate channel-bindings.
53 #
54 abfab_channel_bindings {
55         if (&GSS-Acceptor-Service-Name && (&outer.request:GSS-Acceptor-Service-Name != &GSS-Acceptor-Service-Name)) {
56                 reject
57         }
58
59         if (&GSS-Acceptor-Host-Name && &outer.request:GSS-Acceptor-Host-Name != &GSS-Acceptor-Host-Name ) {
60                 reject
61         }
62
63         if (&GSS-Acceptor-Realm-Name && &outer.request:GSS-Acceptor-Realm-Name != &GSS-Acceptor-Realm-Name ) {
64                 reject
65         }
66
67         if (&GSS-Acceptor-Service-Name || &GSS-Acceptor-Realm-Name || &GSS-Acceptor-Host-Name) {
68                 update control {
69                         &Chbind-Response-Code := success
70                 }
71
72                 #
73                 #  ACK the attributes in the request.
74                 #
75                 #  If any one of these attributes don't exist in the request,
76                 #  then they won't be copied to the reply.
77                 #
78                 update reply {
79                         &GSS-Acceptor-Service-Name = &GSS-Acceptor-Service-Name
80                         &GSS-Acceptor-Host-Name = &GSS-Acceptor-Host-Name
81                         &GSS-Acceptor-Realm-Name = &GSS-Acceptor-Realm-Name
82                 }
83         }
84
85         #
86         #  Return "handled" so that the "authenticate" section isn't used.
87         #
88         handled
89 }