Skip to content

Instantly share code, notes, and snippets.

@munteanulc
Forked from dnozay/README.md
Created February 8, 2021 22:14
Show Gist options
  • Save munteanulc/0b4e129a0bcff2aa0e7f83bde50f95a4 to your computer and use it in GitHub Desktop.
Save munteanulc/0b4e129a0bcff2aa0e7f83bde50f95a4 to your computer and use it in GitHub Desktop.

Revisions

  1. @dnozay dnozay revised this gist May 14, 2015. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -39,8 +39,38 @@ appsettings.signin_enabled = true
    appsettings.save
    ```

    # Pre-populate users

    I have found that you can just post the info with your admin token:

    * https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md
    * http://doc.gitlab.com/ce/api/README.html



    ```python
    import requests
    headers = { 'PRIVATE-TOKEN' : 'insert-token-here' }
    data = {
    'email': email,
    'extern_uid': dn,
    "provider": "ldapmain",
    "name": name,
    "username": username,
    'password': '1234567890',
    "confirm": False,
    }
    requests.post('https://gitlab.example.com/api/v3/users/', data, headers=headers)
    ```

    I get the email, dn, name, username from ldap by using python-ldap; I use a filter to only match engineers.
    The password is required, but you can use a dummy value that matches the security parameters (min 8 characters ...etc)


    # Pre-confirm users

    In case you missed to add `confirm=false` when creating users.

    ```bash
    gitlab-rails console production
    ```
  2. @dnozay dnozay revised this gist May 14, 2015. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,20 @@ user.save
    appsettings = ApplicationSetting.find_by(signin_enabled: false)
    appsettings.signin_enabled = true
    appsettings.save
    ```

    # Pre-confirm users

    ```bash
    gitlab-rails console production
    ```

    then

    ```ruby
    for user in User.where(confirmed_at: nil) do
    user.confirmed_at = Time.now
    user.confirmation_token = nil
    user.save!
    end
    ```
  3. @dnozay dnozay revised this gist Mar 5, 2015. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # Reset root/admin password

    Lost the root/admin password? You can reset it using the command-line.
    @@ -30,3 +29,12 @@ user.password_confirmation = 'secret_pass'
    user.save
    ```

    # Re-enable standard login

    ```ruby
    # locate application settings
    # ApplicationSetting.find_each
    appsettings = ApplicationSetting.find_by(signin_enabled: false)
    appsettings.signin_enabled = true
    appsettings.save
    ```
  4. @dnozay dnozay created this gist Mar 5, 2015.
    32 changes: 32 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@

    # Reset root/admin password

    Lost the root/admin password? You can reset it using the command-line.
    Recipe adapted from [gitlab issue #308](https://gitlab.com/gitlab-org/omnibus-gitlab/issues/308).


    ```bash
    # start the console
    sudo gitlab-rails console
    ```

    Then in the ruby interpreter:


    ```ruby
    # find the user:
    # user = User.find_by(email: "[email protected]")
    # user = User.find_by(username: "root")
    # user = User.find_by(name: "Administrator")
    # user = User.find_by(admin: true)
    user = User.find_by(username: "root")

    # change the password
    # or use the ask function from 'highline/import'
    user.password = 'secret_pass'
    user.password_confirmation = 'secret_pass'

    # and save
    user.save
    ```