Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git hook fails with branch tracking and LDAP authentication #132

Open
ohrn opened this issue Apr 27, 2018 · 2 comments
Open

Git hook fails with branch tracking and LDAP authentication #132

ohrn opened this issue Apr 27, 2018 · 2 comments

Comments

@ohrn
Copy link
Contributor

ohrn commented Apr 27, 2018

Whenever the branch tracker tries to update a branch the error below happens in the git hook.

The missing key fields_from_user does not exist in the auth.py template nor can I find any other reference or docs on how it should be filled out.

Pushing branches manually to the critic server works fine.

Critic encountered an unexpected error.  If you know a series of steps that can
reproduce this error it would be very useful if you submitted a bug report
including the steps plus the information below (see bug reporting URL at the
bottom of this e-mail).

2018-04-27 09:53:52,762 - ERROR - KeyError: 'fields_from_user'

Request:
{
  "repository_name": "ibe", 
  "refs": [
    {
      "new_sha1": "10e55190572c9fc7a7565f2427fcbc5660ebc0f3", 
      "name": "refs/heads/master", 
      "old_sha1": "0000000000000000000000000000000000000000"
    }
  ], 
  "user_name": "critic", 
  "flags": "trackedbranch_id=3"
}

Traceback (most recent call last):
  File "/usr/share/critic/background/githook.py", line 81, in slave
    authentication_labels = auth.DATABASE.getAuthenticationLabels(user)
  File "/usr/share/critic/auth/databases/accesstokensdb.py", line 33, in getAuthenticationLabels
    return self.authdb.getAuthenticationLabels(user)
  File "/usr/share/critic/auth/databases/ldapdb.py", line 200, in getAuthenticationLabels
    fields = self.configuration["fields_from_user"](user)
KeyError: 'fields_from_user'


Critic version: 28ed20bb8032d7cc5aa23de98da51e619fd84164
Critic bug reports can be filed here: https://github.com/jensl/critic/issues/new
@jensl
Copy link
Owner

jensl commented May 22, 2018

The fields_from_user configuration option should apparently be a function that takes a single argument, a dbutils.User object, and returns a dictionary matching the fields configuration option, typically with all fields except the password. With the default fields option

  "fields": [
    (False, "username", "Username:"),
    (True, "password", "Password:"),
  ],

a matching fields_from_user option would be

  "fields_from_user": lambda user: { "username": user.name },

Authentication labels were a fairly recent addition, and has seen no testing (from my part) outside of Opera's production Critic system. Testing LDAP in isolation requires a bit of work, I guess. Also, given how nice I think interfacing with LDAP systems is, I somewhat suspect I won't like setting one up...

(Sorry for late reply.)

@ohrn
Copy link
Contributor Author

ohrn commented May 22, 2018

Thanks for the explanation. The template could definitely use and update and explanation here but I don't feel confident enough to submit a patch myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants