New build path variable
[freeradius.git] / raddb / policy.conf
1 # -*- text -*-
2 ##
3 ## policy.conf  -- FreeRADIUS server configuration file.
4 ##
5 ##      http://www.freeradius.org/
6 ##      $Id$
7 ##
8
9 #
10 #  Policies are virtual modules, similar to those defined in the
11 #  "instantate" section of radiusd.conf.
12 #
13 #  Defining a policy here means that it can be referenced in multiple
14 #  places as a *name*, rather than as a series of conditions to match,
15 #  and actions to take.
16 #
17 #  Policies are something like subroutines in a normal language, but
18 #  they cannot be called recursively.  They MUST be defined in order.
19 #  If policy A calls policy B, then B MUST be defined before A.
20 #
21 policy {
22         #
23         #       Forbid all EAP types.
24         #
25         forbid_eap {
26                 if (EAP-Message) {
27                         reject
28                 }
29         }
30
31         #
32         #       Forbid all non-EAP types outside of an EAP tunnel.
33         #
34         permit_only_eap {
35                 if (!EAP-Message) {
36                         #  We MAY be inside of a TTLS tunnel.
37                         #  PEAP and EAP-FAST require EAP inside of
38                         #  the tunnel, so this check is OK.
39                         #  If so, then there MUST be an outer EAP message.
40                         if (!"%{outer.request:EAP-Message}") {
41                                 reject
42                         }
43                 }
44         }
45
46         #
47         #       Forbid all attempts to login via realms.
48         #
49         deny_realms {
50                 if (User-Name =~ /@|\\/) {
51                         reject
52                 }
53         }
54
55         #
56         #       If you want the server to pretend that it is dead,
57         #       then use the "do_not_respond" policy.
58         #
59         do_not_respond {
60                 update control {
61                         Response-Packet-Type := Do-Not-Respond
62                 }
63
64                 handled
65         }
66
67         #       
68         #  The following policies are for the Chargeable-User-Identity
69         #  (CUI) configuration.
70         #
71
72         #
73         #  The client indicates it can do CUI by sending a CUI attribute        
74         #  containing one zero byte
75         #
76         cui_authorize {
77                 update request {
78                         Chargeable-User-Identity:='\\000'
79                 }
80         }
81
82         #
83         #  Add a CUI attribute based on the User-Name, and a secret key
84         #  known only to this server.
85         #
86         cui_postauth {
87                 if (FreeRadius-Proxied-To == 127.0.0.1) {
88                         if (outer.request:Chargeable-User-Identity) {
89                                 update outer.reply {
90                                         Chargeable-User-Identity:="%{md5:%{config:cui_hash_key}%{User-Name}}"
91                                 }
92                         }
93                 }
94                 else {
95                         if (Chargeable-User-Identity) {
96                                 update reply {
97                                         Chargeable-User-Identity="%{md5:%{config:cui_hash_key}%{User-Name}}"
98                                 }
99                         }
100                 }
101         }
102
103         #
104         #  If there is a CUI attribute in the reply, add it to the DB.
105         #
106         cui_updatedb {
107                 if (reply:Chargeable-User-Identity) {
108                         cui
109                 }
110         }
111
112         #
113         #  If we had stored a CUI for the User, add it to the request.
114         #
115         cui_accounting {
116                 #
117                 #  If the CUI isn't in the packet, see if we can find it
118                 #  in the DB.
119                 #
120                 if (!Chargeable-User-Identity) {
121                         update control {
122                                 Chargable-User-Identity := "%{cui: SELECT cui FROM cui WHERE clientipaddress = '%{Client-IP-Address}' AND callingstationid = '%{Calling-Station-Id}' AND username = '%{User-Name}'}"
123                         }
124                 }
125
126                 #
127                 #  If it exists now, then write out when we last saw
128                 #  this CUI.
129                 #
130                 if (Chargeable-User-Identity && (Chargeable-User-Identity != "")) {
131                         cui
132                 }
133         }
134 }