Skip to content

Integrity constraint violation: 1062 Duplicate entry for key 'authtoken_token_index' with environment variable and mod_auth_cas #115

@ArnY

Description

@ArnY

I'm trying to set up a CAS login with nextcloud12, user_saml 1.3.2, apache 2.4 and mod_auth_cas 1.0.9.1 on a debian jessie linux server.

user_saml is set up with "use an environment variable" and the variable HTTP_CAS_USER is set.

my apache 2.4 configuration is like this:

        CASVersion 2
        CASLoginURL https://cas.server.com/login
        CASValidateURL https://cas.server.com/serviceValidate

        CASValidateServer Off
        CASAllowWildcardCert On
        CASTimeout 3600
        CASIdleTimeout 3600

       <Location "/index.php/login">
                AuthType CAS
                require valid-user 
       </Location>

     <Location "/index.php/apps/user_saml/saml/login">
                AuthType CAS
                require valid-user
        </Location>

The first Location block is required to avoid "Access forbidden / CSRF check failed" error. The 2nd block is mandatory for the user_saml controller to get the envvar.

If I disconnect and then log back in after enabling the plugin, i am indeed redirected to my CAS portal but after the authentication's success, when I'm sent back to https://myserver.com/index.php/apps/files/ I get an internal error:

An exception occurred while executing 'INSERT INTO `oc_authtoken`(`uid`,`login_name`,`name`,`token`,`type`,`remember`,`last_activity`) VALUES(?,?,?,?,?,?,?)' with params [\\\"doe-j\\\", \\\"doe-j\\\", \\\"Mozilla\\\\\\\/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko\\\\\\\/20100101 Firefox\\\\\\\/47.0\\\", \\\"c59e890fc0d255dd09f0b09e1f9eb4ad3472e0f455fb340acc4332d7c2eb6b8e2a51e892b1ae50c84addd2d04561afab1af3ea7ca795237856a93c3d6241731c\\\", 0, 0, 1495729879]:\\n\\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'c59e890fc0d255dd09f0b09e1f9eb4ad3472e0f455fb340acc4332d7c2eb6b8e' for key 'authtoken_token_index'\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/nextcloud12\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/var\\\/www\\\/nextcloud12\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(177): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'INSERT INTO `oc...', Array)\\n#2 \\\/var\\\/www\\\/nextcloud12\\\/lib\\\/public\\\/AppFramework\\\/Db\\\/Mapper.php(247): Doctrine\\\\DBAL\\\\Statement->execute()\\n#3 \\\/var\\\/www\\\/nextcloud12\\\/lib\\\/public\\\/AppFramework\\\/Db\\\/Mapper.php(125): OCP\\\\AppFramework\\\\Db\\\\Mapper->execute('INSERT INTO `*P...', Array)\\n#4 \\\/var\\\/www\\\/nextcloud12\\\/lib\\\/private\\\/Authentication\\\/Token\\\/DefaultTokenProvider.php(97): OCP\\\\AppFramework\\\\Db\\\\Mapper->insert(Object(OC\\\\Authentication\\\\Token\\\\DefaultToken))\\n#5 \\\/var\\\/www\\\/nextcloud12\\\/lib\\\/private\\\/User\\\/Session.php(610): OC\\\\Authentication\\\\Token\\\\DefaultTokenProvider->generateToken(*** sensitive parameters replaced ***)\\n#6 \\\/var\\\/www\\\/nextcloud12\\\/lib\\\/private\\\/legacy\\\/user.php(205): OC\\\\User\\\\Session->createSessionToken(Object(OC\\\\AppFramework\\\\Http\\\\Request), 'doe-j', 'doe-j')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions