最近のアクセス:
GAM を使用した Office 365 の認証

GeneXus Access ManagerOAuth 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。

General

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://<サーバー>/<仮想ディレクトリー>

Authorization

次のパラメーターを設定します:
  • 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
    • Tag: state
  • Include Client Id: enabled
  • Include Redirect URL: enabled

Response

  • Access Code Tag: code
  • Error Descriprion Tag: error_description

Token

  • 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

Response

  • Access Token Tag: access_token
  • Token Type Tag: token_type
  • Expires In Tag: expires_in
  • Scope Tag: scope
  • Error Descriprion Tag: error

User Information

  • 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
    • Tag: access_token
  • Include Client Id: disabled
    • Tag: client_id
  • Include Client Secret: disabled
    • Tag: client_secret

Response

  • 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
    • Tag: surname
  • 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

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

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 アプリケーションに移動し、アプリケーションを選択して、関連付けられているエンドポイントを確認します。
イメージ:42057.png

AADSTS70001

AADSTS70001: Application 'GUID' is disabled.
Azure アプリケーションが正しく設定されていることを確認します。

AADSTS70002

AADSTS70002: Error validating credentials.AADSTS50012: Invalid client secret is provided
Azure アプリケーションの設定サイトでパスワード設定を確認し、GAM 設定を更新します。

AADSTS50020

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



サブページ
Created: 18/10/29 01:07 by Admin Last update: 22/04/05 18:18 by Admin
カテゴリ
Powered by GXwiki 3.0