Debian Codegraph @

doc/antora/modules/tutorials/pages/sql_user.adoc

raw
1 = Configuring a user in an SQL database
2
3 *Goal:* To configure the server to have a new user in an SQL database,
4 to send test packets as that user, and to receive a reply.
5
6 *Time:* 25-40 minutes.
7
8 *File:*
9
10 - `etc/raddb/mods-available/sql`
11 - `etc/raddb/mods-config/sql/main/*`
12
13 Now that we have verified in the previous exercise,
14 xref:sql.adoc[SQL] that the server can communicate with
15 an SQL server, we proceed to adding user configuration entries into the
16 SQL database.
17
18 Before adding any user configuration to an SQL database, we first need
19 to create the schema used to store that information. In the source
20 archive, the file `RADIUS-SQL.schema` in the documentatin directory,
21 describes where the schemas are located, and how to install them. In
22 general, you will need to be familiar with the tools for the SQL
23 database your are using, as they are too complicated and variable to
24 describe here.
25
26 Once the schema has been created, use an SQL client utility to execute
27 the following SQL commands:
28
29 [source, sql]
30 ---------------------------------------------------------
31 INSERT INTO radcheck (UserName, Attribute, op, Value)
32 values("bob", "Password.Cleartext", ":=", "hello");
33 INSERT INTO radreply (UserName, Attribute, op, Value)
34 values("bob", "Reply-Message", ":=", "Hello from SQL");
35 ---------------------------------------------------------
36
37 These commands may need to be modified slightly, depending on the syntax
38 required by your SQL database.
39
40 These commands mirror the "check" and "reply" entries listed in the
41 file for the user "bob". Use the SQL client to verify that the entries
42 are now in the database.
43
44 As the previous exercise in xref:sql.adoc[SQL]
45 did not tell the server to query the database, but only to connect to it,
46 we must now configure FreeRADIUS to query the database. This may be done
47 by editing `etc/raddb/sites-available/default`, and listing the `sql`
48 module in the "authorize" section.
49
50 There should already be a commented-out entry for `sql` in the
51 "authorize" section or there will be `-sql` entry.
52 If the entry is commented it should be un-commented, to make it live.
53 If the entry has a '-' prefix, it may be left as is, the '-' prefix is used
54 to mark modules as optional, so that the server can start even if they
55 are not enabled.
56
57 The file should now be edited to delete the existing entry or entries
58 for user "bob". This may be done by commenting out the entries, rather
59 than deleting them. Add a `#` character to the start of every line
60 for the relevant entries, and save the updated file.
61
62 The server should now be started. Send a test packet for user "bob",
63 and verify that an authentication accept packet is received. Observe the
64 debugging output of the server, and verify that the `sql` module is
65 called, and that it successfully returns data for user "bob".
66
67 If the server rejects the access request, then there are a number of
68 steps to take, to correct the problem. Verify that FreeRADIUS is
69 connecting to the SQL server, and that FreeRADIUS is "Ready to process
70 requests." Verify that the file entry for "bob" has not matched the
71 request. Verify that the SQL module returns "ok", rather than
72 "notfound".
73
74 If necessary, edit the `etc/raddb/mods-enabled/sql` file, and enable
75 additional debugging of SQL statements via the `sqltrace` and `sqltracefile`
76 configuration options. If the SQL queries are performed by the server and
77 logged to the file, but the request for user "bob" is still rejected, then
78 perform those queries by hand, using an SQL test client. Once you have
79 verified that the SQL test client returns the correct information for
80 the queries, then send the access request again.
81
82 == Questions
83
84 1. Why do we not use an SQL database to "authenticate" users?
85 2. How do we have a DEFAULT entry in an SQL database?
86 3. Why is there no "Fall-Through" entry in an SQL database?
87 4. Does that DEFAULT entry differ from its use in the file? If so, why,
88 and how? If not, why not?
89 5. What other configuration entries in `etc/raddb/sites-available/default`
90 exist for the `sql` module, and why?
91
92 // Copyright (C) 2021 Network RADIUS SAS. Licenced under CC-by-NC 4.0.
93 // This documentation was developed by Network RADIUS SAS.