拒否リストへのユーザー属性の追加

プライバシー上の理由により Auth0 データベースに保存すべきでないユーザーフィールドがある場合は、それらを拒否リストに追加できます。拒否リストに属性を追加するには、Management APIの更新接続エンドポイントに対してPATCH呼び出しを行います。

  1. /patch_connections_by_idエンドポイントにアクセスするための有効なアクセストークンを取得します。トークンには、update:connectionsスコープが含まれている必要があります。詳細については、[Management API Access Tokens(Management APIのアクセストークン)]を参照してください。

  2. アクセストークンと拒否する属性のリストを使用して、API を呼び出します。以下は、ethnicityとgenderの2つの属性を拒否するHTTP要求の例です。1つまたは2つの値のみを更新する場合は「マージ」が行われないため、optionsオブジェクトを取得してPATCH要求でオブジェクト全体を送信する必要があることに注意してください。

    
    
    curl --request PATCH \
      --url 'https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID' \
      --header 'authorization: Bearer YOUR_TOKEN' \
      --header 'content-type: application/json' \
      --data '{"options": {"non_persistent_attrs": ["ethnicity", "gender"]}}'

    Was this helpful?

    /
    var client = new RestClient("https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID");
    var request = new RestRequest(Method.PATCH);
    request.AddHeader("authorization", "Bearer YOUR_TOKEN");
    request.AddHeader("content-type", "application/json");
    request.AddParameter("application/json", "{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);

    Was this helpful?

    /
    package main
    
    import (
    	"fmt"
    	"strings"
    	"net/http"
    	"io/ioutil"
    )
    
    func main() {
    
    	url := "https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID"
    
    	payload := strings.NewReader("{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}")
    
    	req, _ := http.NewRequest("PATCH", url, payload)
    
    	req.Header.Add("authorization", "Bearer YOUR_TOKEN")
    	req.Header.Add("content-type", "application/json")
    
    	res, _ := http.DefaultClient.Do(req)
    
    	defer res.Body.Close()
    	body, _ := ioutil.ReadAll(res.Body)
    
    	fmt.Println(res)
    	fmt.Println(string(body))
    
    }

    Was this helpful?

    /
    HttpResponse<String> response = Unirest.patch("https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID")
      .header("authorization", "Bearer YOUR_TOKEN")
      .header("content-type", "application/json")
      .body("{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}")
      .asString();

    Was this helpful?

    /
    var axios = require("axios").default;
    
    var options = {
      method: 'PATCH',
      url: 'https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID',
      headers: {authorization: 'Bearer YOUR_TOKEN', 'content-type': 'application/json'},
      data: {options: {non_persistent_attrs: ['ethnicity', 'gender']}}
    };
    
    axios.request(options).then(function (response) {
      console.log(response.data);
    }).catch(function (error) {
      console.error(error);
    });

    Was this helpful?

    /
    #import <Foundation/Foundation.h>
    
    NSDictionary *headers = @{ @"authorization": @"Bearer YOUR_TOKEN",
                               @"content-type": @"application/json" };
    NSDictionary *parameters = @{ @"options": @{ @"non_persistent_attrs": @[ @"ethnicity", @"gender" ] } };
    
    NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID"]
                                                           cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"PATCH"];
    [request setAllHTTPHeaderFields:headers];
    [request setHTTPBody:postData];
    
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                                completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                    if (error) {
                                                        NSLog(@"%@", error);
                                                    } else {
                                                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                        NSLog(@"%@", httpResponse);
                                                    }
                                                }];
    [dataTask resume];

    Was this helpful?

    /
    $curl = curl_init();
    
    curl_setopt_array($curl, [
      CURLOPT_URL => "https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PATCH",
      CURLOPT_POSTFIELDS => "{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}",
      CURLOPT_HTTPHEADER => [
        "authorization: Bearer YOUR_TOKEN",
        "content-type: application/json"
      ],
    ]);
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }

    Was this helpful?

    /
    import http.client
    
    conn = http.client.HTTPSConnection("")
    
    payload = "{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}"
    
    headers = {
        'authorization': "Bearer YOUR_TOKEN",
        'content-type': "application/json"
        }
    
    conn.request("PATCH", "/{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID", payload, headers)
    
    res = conn.getresponse()
    data = res.read()
    
    print(data.decode("utf-8"))

    Was this helpful?

    /
    require 'uri'
    require 'net/http'
    require 'openssl'
    
    url = URI("https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID")
    
    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    
    request = Net::HTTP::Patch.new(url)
    request["authorization"] = 'Bearer YOUR_TOKEN'
    request["content-type"] = 'application/json'
    request.body = "{\"options\": {\"non_persistent_attrs\": [\"ethnicity\", \"gender\"]}}"
    
    response = http.request(request)
    puts response.read_body

    Was this helpful?

    /
    import Foundation
    
    let headers = [
      "authorization": "Bearer YOUR_TOKEN",
      "content-type": "application/json"
    ]
    let parameters = ["options": ["non_persistent_attrs": ["ethnicity", "gender"]]] as [String : Any]
    
    let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
    
    let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/connections/YOUR_CONNECTION_ID")! as URL,
                                            cachePolicy: .useProtocolCachePolicy,
                                        timeoutInterval: 10.0)
    request.httpMethod = "PATCH"
    request.allHTTPHeaderFields = headers
    request.httpBody = postData as Data
    
    let session = URLSession.shared
    let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
      if (error != nil) {
        print(error)
      } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
      }
    })
    
    dataTask.resume()

    Was this helpful?

    /
    ここでは、

    1. {yourConnectionId} は、これらの属性が拒否される接続 IDです。

    2. {yourToken}は、前の手順で受け取ったアクセストークンです。

    3. options.non_persistent_attrsオブジェクトは、拒否される属性の配列を保持します。拒否するクレームがアップストリームのIDプロバイダー(IdP)によって送信されている場合は、アップストリームのIdPによって送信されたとおりにクレームを設定する必要があります。たとえば、https://acme.com/temporary_idtokenとして受信されたクレームの場合、上記のサンプルのnon_persistent_attrsオブジェクトオブジェクトが読み取ります。

      {"non_persistent_attrs": ["ethnicity", "gender", "https://acme.com/temporary_idtoken"]}

      Was this helpful?

      /

制限事項

  • 拒否できるのは、ルート フィールドuser.nameuser.phone_number など)のみです。

    • user.nameまたはuser.nicknameが拒否された場合、それらはトークンに含まれません。

    • user.emailが拒否された場合、その値はカスタムクレームにマッピングできません。たとえば、ルールでは、context.idトークン[namespace + 'work_email'] = user.emailは機能しません。

  • 属性を拒否しても、ルールと送信トークンを介して使用できます。ただし、次のいずれかに該当する場合、拒否リスト属性はトークンに含まれません:

    • 多要素認証(MFA)を有効にしています

    • ルールを介してリダイレクトを実行しています

    • アプリで委任を使用しています(かつ、scope = passthrough を設定していない)

    • アプリはなりすましを使用しています

    • [Use Auth0 instead of the IdP to do Single Sign-On(IdPの代わりにAuth0を使用してシングルサインオン)]の設定を有効にしています(レガシーテナントのみ)

  • SAMLP接続の場合、デバッグモードを有効にすると、ログに拒否リスト属性に関する情報が含まれます

これらの制限のいずれかが受け入れられない場合は、データを暗号化するルールを記述し、データをuser.app_metadataオブジェクトに保持することができます。

もっと詳しく