GeneXus Access Manager に
OAuth 2.0 認証が導入されてから、より多くのプロバイダーを認証できるようになりました。この記事では GAM バックエンドで Office 365 を認証する方法を説明します。Azure の設定に関する詳細情報については、
Azure Active Directory へのアプリケーションの登録に関する説明を参照してください。
新しい OAuth 2.0 認証タイプを
GAM Web Backoffice に追加し、次に示す関連する基本的なパラメーターを設定します:
- Name (この名前は後でログイン用のコードで使用します)
- Function (認証のみがサポートされます)
- Enabled (Yes|No)
- Description: 分かりやすい説明
- Small image name
- Big image name
- Impersonate
次のタブに詳細な情報を入力する必要があります:
- General: OAuth 2.0 アプリケーションを識別するための情報です。
- Authorization: オーソライズの要求と応答に関連付けられたヘッダー。
- Token: トークン情報を処理するサービスの URL。
- User Information: ユーザーデータを処理するサービスの URL。
Cliend Id、クライアントシークレット、リダイレクト URL を入力します。URL はアプリケーションのベース URL にします。
- Client Id
- Tag: client_id、Value: <ここに値を入力>
- Client Secret
- Tag: client_secret、Value: <ここに値を入力>
- Redirect URL
- Tag: redirect_uri、Value: <ここにアプリケーションの URL を入力>。例: http://<サーバー>/<仮想ディレクトリー>
次のパラメーターを設定します:
- URL: https://login.windows.net/common/oauth2/authorize
- ResponseType: enabled
- Tag: response_type、Value: code
- Scope: enabled
- Tag: scope、Value: https://graph.microsoft.com/user.read
- State: enabled
- Include Client Id: enabled
- Include Redirect URL: enabled
- Access Code Tag: code
- Error Descriprion Tag: error_description
- URL: https://login.windows.net/common/oauth2/token
- Token Method: POST
- Header
- Tag: Content-type、Value: application/x-www-form-urlencoded
- Grant Type: enabled
- Tag: grant_type、Value: authorization_code
- Include Access Code: enabled
- Include Client Id: enabled
- Include Client Secret: enabled
- Include Redirect URL: enabled
- Additional Parameters: resource=https://graph.microsoft.com
- Access Token Tag: access_token
- Token Type Tag: token_type
- Expires In Tag: expires_in
- Scope Tag: scope
- Error Descriprion Tag: error
- URL: https://graph.microsoft.com/v1.0/me
- User Info Method: GET
- Header
- Tag: Content-type、Value: application/json;charset=utf-8
- Include Access Token: disabled
- Include Client Id: disabled
- Include Client Secret: disabled
- User Email Tag: mail
- User External Id Tag: id
- User Name Tag: userPrincipalName
- User First Name
- Tag: givenName、Generate automatic Last Name: False
- User Last Name
- User Language Tag: preferredLanguage
- Error Description Tag: error_description
GAMRepository 外部オブジェクトから LoginOauth20 メソッドを使用して、OAuth 2.0 の設定名を指定します。たとえば、以前の設定に「Office365」を設定した場合、次のようにします:
Event 'Login'
GAMRepository.LoginOauth20(!"Office365") // 認証タイプの名前がバックエンドの定義と一致する必要がある
EndEvent
ID プロバイダーから強制的にログアウトさせる場合は、目的のコールバック URL を指定して次の URL を呼び出す必要があります。
https://login.windows.net/common/oauth2/logout?post_logout_redirect_uri=<my_callback_URL>
エラーが発生した場合は、
GAM トレースを有効にして詳細情報を取得します。
AADSTS90002: Tenant organizations not found.This may happen if there are no active subscriptions for the tenant.Check with your subscription administrator.
GAM で設定されている URL が正しくないと思われるため、Azure サーバー側の設定を確認します。
AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: 'GUID'.
エンドポイントの URL が正しく設定されていることを確認し、GAM アプリケーションの保存先と一致させます。Azure ポータル \ Azure Active Directory アプリケーションに移動し、アプリケーションを選択して、関連付けられているエンドポイントを確認します。
AADSTS70001: Application 'GUID' is disabled.
Azure アプリケーションが正しく設定されていることを確認します。
AADSTS70002: Error validating credentials.AADSTS50012: Invalid client secret is provided
Azure アプリケーションの設定サイトでパスワード設定を確認し、GAM 設定を更新します。
Message: AADSTS50020: We are unable to issue tokens from this api version for a Microsoft account.Please contact the application vendor as they need to use version 2.0 of the protocol to support this.
Azure に登録した次のアプリケーションエンドポイントと、GAM での関連する設定を確認します。
- OAuth 2.0 トークンエンドポイント
- OAuth 2.0 オーソライズエンドポイント
OAuth 2.0 認証は、
GeneXus 15 Upgrade 11 以降の
GeneXus Access Manager で利用できます。
Azure Active Directory へのアプリケーションの登録
Authenticate to Azure Active Directory using GAM