4

ストームパスをインストールし、Googleサインインを使用して登録してサインインします。これを使用して、ストームパスのGoogleディレクトリにグループを作成しようとしています

from stormpath.client import Client
stormpath_client = Client(id=STORMPATH_CLIENT_APIKEY_ID, secret=STORMPATH_CLIENT_APIKEY_SECRET)
directory = stormpath_client.applications[0].account_store_mappings[1].account_store
directory.groups.create({'name': 'admins'})

このチュートリアルに基づいて

取得してエラー

Cannot create nor edit accounts of externally managed directories.

ストームパス コンソールでグループを作成しようとすると、同じエラーが発生します。

ここに画像の説明を入力

ユーザーごとに異なるアクセス許可を与えるにはどうすればよいですか?

4

3 に答える 3

2

stormpathこの回避策のサンプル コードの Gist を作成しました。python Flask

environment.py https://gist.github.com/ohadperry/f77a26ce758efa2990cb

authentication_controller.py https://gist.github.com/ohadperry/338e7e689d8c64158c06

stormpath_helper.py https://gist.github.com/ohadperry/50951e68f2375f0b9002

基本的なロジックは次のとおりです。

  1. google ユーザーでログインします。
  2. クラウド ディレクトリで用途を検索または作成する
  3. フラスコログインを使用して新しいクラウドユーザーに切り替えます

    from flask.ext.stormpath import User as StormpathUser
    from flask.ext.login import login_user 
    new_user_account.__class__ = StormpathUser
    # switching the session
    login_user(new_user_account, remember=True)
    
于 2016-02-08T09:02:34.173 に答える
2

Stormpath では、ソーシャル ディレクトリ (Google ディレクトリなど) のグループを作成することはできません。

あなたがしなければならないことは、通常のストームパス ディレクトリ (ソーシャル ディレクトリではない) を作成し、そこにユーザーを作成することです。その後、グループの作成などを行うことができます。

私が(個人的に)やりたいことは、これです:

  • ユーザーが Google 経由でサインインしたら、メインの Stormpath ディレクトリにそのユーザー アカウントのコピーを作成します。
  • 次に、Stormpath ディレクトリにあるそのユーザーのコピーをそのユーザーの「メイン」アカウントとして使用し、そこにグループなどを作成します。
于 2016-01-26T16:58:04.330 に答える