• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[50% gelöst] ModAuthMySQL: Gruppen in zweiter Tabelle+Beding

A

Anonymous

Gast
Halo,
nachdem das Basic-Setup mit ModMySQLAuth funktioniert möchte ich das ganze erweitern:

Bisher waren Benutzer, Passwort und Gruppe in einer Tabelle. Ich möchte das allerdings aufsplitten:
* Benutzer und Passwort in die eine Tabelle (user-Tabelle)
* Gruppe und weitere Dinge die ich in nem anderen Script brauche in einer anderen (group-Tabelle)

Die Tabellenstruktur für die Variante mit nur einer Tabelle sieht so aus:

[user]
user_name --> primary key
user_password
user_group

Bisher sah meine Config so aus:

Code:
        AuthMYSQL on
        AuthMySQL_Authoritative on
        AuthMySQL_Host localhost
        AuthMySQL_User <user>
        AuthMySQL_Password <pass>
        AuthMySQL_DB svn_access

        AuthMySQL_Password_Table user
        AuthMySQL_Group_Table user

        AuthMySQL_Empty_Passwords off
        AuthMySQL_Encrypted_Passwords On
        AuthMySQL_Encryption_Types Plaintext Crypt_DES PHP_MD5

        AuthMySQL_Username_Field user.user_name
        AuthMySQL_Password_Field user.user_passwd
        AuthMySQL_Group_Field user.user_group
        AuthMySQL_Group_User_Field user.user_name

        AuthName "SVN"
        AuthType Basic
        Require group testgruppe

Hier hat auch alles "fast" korrekt funktionert. Versucht man sich mit einem Benutzernamen einzuloggen den es in der Tabelle "user" gibt, dessen Passwort korrekt ist und dessen Gruppe "testgruppe" lautet klappt das Prima ohne Fehlermeldung.
Wenn ich jetzt Testweise diesen Benutzer in der DB in eine andere Gruppe stecke und ich den Login nochmal versuche dann kommt folgendes:

configuration error: couldn't check access. No groups file?: /svn/

Normalerweise würde ich so einen Fehler hier erwarten:

access to /svn/ failed, reason: user achristi not allowed access

Im Netz habe ich folgenden Link gefunden:
http://rc.vintela.com/topics/apache/mod_pam/#nogroups
Dort wird beschrieben es würde helfen wenn man mod-auth-pam und mod-auth-sys-group installieren und einschalten würde... Hilft aber nix.
Im ersten Moment scheint das nicht tragisch zu sein. Aber 1.) stört mich so ein Fehler. Denn so wie ich das verstehe versucht Apache den Benutzer noch gegen eine Gruppen-File zu authentifizieren was Apache aber gar nicht tun soll und 2) sehe ih so nicht wer sich da versucht hat Zugang zu verschaffen....

Wenn ich jetzt weiter zu meinem Vorhaben gehe, Benutzer und Gruppen in zwei Tabellen abzuhandeln dann würde meine Config so aussehen:

Code:
        AuthMYSQL on
        AuthMySQL_Authoritative on
        AuthMySQL_Host localhost
        AuthMySQL_User <user>
        AuthMySQL_Password <pass>
        AuthMySQL_DB svn_access

        AuthMySQL_Password_Table user
        AuthMySQL_Group_Table group

        AuthMySQL_Empty_Passwords off
        AuthMySQL_Encrypted_Passwords On
        AuthMySQL_Encryption_Types Plaintext Crypt_DES PHP_MD5

        AuthMySQL_Username_Field user.user_name
        AuthMySQL_Password_Field user.user_passwd
        AuthMySQL_Group_Field group.user_group
        AuthMySQL_Group_User_Field group.user_name

        AuthName "SVN"
        AuthType Basic
        Require group testgruppe

Aber egal wie ich es drehe und wende: So funktioniert gar nichts.
Als Fehlermeldung bekomme ich lediglich:

[crit] Group query failed!

Das bringt mich jedoch kein Stückchen weiter. Ich habe glaub alle Kombinationen ausprobiert die es gibt. Aber es will einfach nicht.

Meine Tabellen für diese Config sehen so aus:

[user]
user_name --> primary key
user_password

[group]
user_name
user_group --> primary key

Hat sowas schonmal jemand realisiert und kann mir da ein paar Tipps geben? Bin gestern abend sicher 2 1/2h im Netz unterwegs gewesen und hab nach einer Lösung gesucht und bin nicht fündig geworden...

Wenn das funktionieren würde könnte ich euch mit meinem vermutlich nächsten Problem (Auth_MySQL_Group_Clause) nerven... Aber vielleicht funktioniert mein Ansatz da ja wenn es mal mit den Gruppen in einer zweiten Tabelle funktioniert ...

Gruß
Alex
 
OP
A

Anonymous

Gast
Nach langem probieren und auch Quellcode des Moduls anschauen bin ich etwas weiter:

Der "Query failed" Fehler ist jetzt weg. Schuld war die Gruppen-Tabelle. Wenn man so wie ich nur ab und zu mit MySQL zu tun hat vergisst man schnell dass "GROUP" ein reserviertes Wort ist.
Kaum hatte ich die Tabelle "group" in "groups" geändert gings :)

Hier jetzt meine neue Config:

Code:
LogFormat "%B" traff

<VirtualHost <meineIP>:80>

    ServerAdmin     <meineMailAdresse>
    DocumentRoot    /var/www/svn

    ServerName      <meineSubDomain>
    ServerAlias     <meineSubDomain>

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        # Das hier war mir sehr hilfreich beim aufspüren des Fehlers ...
        LogLevel debug

    ErrorLog        /var/log/apache2/svn/<meineSubDomain>-error.log
    TransferLog     /var/log/apache2/svn/<meineSubDomain>-access.log

    CustomLog       /var/log/apache2/svn/<meineSubDomain>-traf.log traff
    CustomLog       /var/log/apache2/svn/<meineSubDomain>-combined.log combined


    <Location /svn>

        # Uncomment this to enable the repository,
        DAV svn

        # Set this to the path to your repository
        SVNPath /var/lib/svn/repo1

        AuthMYSQL on
        AuthMySQL_Authoritative on
        AuthMySQL_Host localhost
        AuthMySQL_User <user>
        AuthMySQL_Password <pass>
        AuthMySQL_DB svn_access

        AuthMySQL_Password_Table user
        AuthMySQL_Group_Table "groups, project"

        AuthMySQL_Empty_Passwords off
        AuthMySQL_Encrypted_Passwords On
        AuthMySQL_Encryption_Types Plaintext
        # Crypt_DES PHP_MD5

        AuthMySQL_Username_Field username
        AuthMySQL_Password_Field passwd
        AuthMySQL_Group_Field groups
        AuthMySQL_Group_User_Field username

        Auth_MySQL_Group_Clause " AND groups.groups=project.project_name AND project.project_status=1"

        AuthName "repo1 SVN"
        AuthType Basic
        Require group repo1

Vielleicht kann ja der eine oder andere was damit anfangen.
Was ichallerdings noch nicht lösen konnte ist das Problem mit dem "falschen" Error in der Logfile wenn die Benutzergruppe nicht stimmt.

Hat da jemand nen Tipp für mich ?

- Alex

[UPDATE 1]
Ich hab was gefunden:

Why does my authentication give me a server error?

Under normal circumstances, the Apache access control modules will pass unrecognized user IDs on to the next access control module in line. Only if the user ID is recognized and the password is validated (or not) will it give the usual success or "authentication failed" messages.

However, if the last access module in line 'declines' the validation request (because it has never heard of the user ID or because it is not configured), the http_request handler will give one of the following, confusing, errors:

* check access
* check user. No user file?
* check access. No groups file?

This does not mean that you have to add an 'AuthUserFile /dev/null' line as some magazines suggest!

The solution is to ensure that at least the last module is authoritative and CONFIGURED. By default, mod_auth is authoritative and will give an OK/Denied, but only if it is configured with the proper AuthUserFile. Likewise, if a valid group is required. (Remember that the modules are processed in the reverse order from that in which they appear in your compile-time Configuration file.)

A typical situation for this error is when you are using the mod_auth_dbm, mod_auth_msql, mod_auth_mysql, mod_auth_anon or mod_auth_cookie modules on their own. These are by default not authoritative, and this will pass the buck on to the (non-existent) next authentication module when the user ID is not in their respective database. Just add the appropriate 'XXXAuthoritative yes' line to the configuration.

In general it is a good idea (though not terribly efficient) to have the file-based mod_auth a module of last resort. This allows you to access the web server with a few special passwords even if the databases are down or corrupted. This does cost a file open/seek/close for each request in a protected area.
Gefunden auf: http://httpd.apache.org/docs/1.3/misc/FAQ.html

Nur leider birngt mich das nicht weiter. Das mit dem 'XXXAuthoritative yes' hab ich ja schon (siehe oben in der Config).
Bin ich der einzigste der sich mit dem problem rumschlägt?

- Alex
 
Oben