7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitlabでGoogle Apps認証

Posted at

===========================

Installation

Google Developers Consoleから

  • Contacts API
  • Google+ API

を有効にする。

API & auth -> Credentialsより「Create new Client ID」 -> Web Applicationを選び必要項目を入力。
REDIRECT URISは

http://gitlab.example.com/users/auth/google_oauth2/callback

のように入力。

Gitlabのconfig/gitlab.ymlにて

# 
signup_enabled: false

omniauth:
    enabled: true
    allow_single_sign_on: true
    block_auto_created_users: false
    providers:
      - {"name":"google_oauth2","app_id":"32183193207-piqbogilllsi7u21ujjqk7bpuh325fnk.apps.googleusercontent.com","app_secret":"N92-4QlPgKu2X9akEnUwpteE","args":{"access_type":"offline","approval_prompt":"force","hd":"example.com"}}

ログインを許可するドメインを制限したい場合はパラメータにhdをドメイン名として渡す。
allow_single_sign_on: trueでGitlabデータベース内にユーザが存在しない場合でもユーザを作成、 block_auto_created_users: falseで管理者の許可を得なくてもユーザを作成出来るようにする。

また既にGitlabに登録済みのアカウントをGoogle Appsアカウントと紐付けたい場合、omniauthを有効にすると「Profile」->「Account」ページ下部にGoogle Appsアイコンが出現するのでクリックし認証することで紐付け出来る。

Trouble Shooting

  • マルチバイト文字のユーザ名がDBエラーになる

usersテーブル等のcharacter-setをutf8に修正する
参照: Encoding error in Gitlab 5.2 · Issue #4120 · gitlabhq/gitlabhq

ALTER TABLE broadcast_messages CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE deploy_keys_projects CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE emails CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE events CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE forked_project_links CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE issues CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE keys CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE merge_request_diffs CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE merge_requests CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE milestones CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE namespaces CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE notes CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE projects CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE protected_branches CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE schema_migrations CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE services CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE snippets CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE taggings CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tags CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE users CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE users_groups CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE users_projects CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE web_hooks CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?