SSO और OAuth प्रमाणीकरण
सुरक्षित प्रोडक्शन प्रमाणीकरण के लिए Google OAuth, GitHub OAuth और जेनेरिक OIDC कॉन्फ़िगर करें।
SSO और OAuth प्रमाणीकरण
v2.3.0 में नया
डिफ़ॉल्ट रूप से, Potato एक सरल उपयोगकर्तानाम-आधारित लॉगिन का उपयोग करता है जहां एनोटेटर साइन इन करने के लिए कोई भी उपयोगकर्तानाम टाइप करते हैं। यह स्थानीय विकास और छोटे प्रोजेक्टों के लिए सुविधाजनक है, लेकिन प्रोडक्शन तैनाती को अनधिकृत पहुंच रोकने, एनोटेटर पहचान सुनिश्चित करने और संस्थागत आवश्यकताओं का अनुपालन करने के लिए उचित प्रमाणीकरण की आवश्यकता है।
Potato 2.3 तीन प्रमाणीकरण विधियों के लिए समर्थन जोड़ता है:
- Google OAuth -- Google खातों से साइन इन, वैकल्पिक डोमेन प्रतिबंध के साथ
- GitHub OAuth -- GitHub खातों से साइन इन, वैकल्पिक संगठन प्रतिबंध के साथ
- जेनेरिक OIDC -- किसी भी OpenID Connect प्रदाता से कनेक्ट (Okta, Azure AD, Auth0, Keycloak, आदि)
सभी विधियों को मिश्रित-मोड सेटअप के लिए Potato के मौजूदा उपयोगकर्तानाम लॉगिन के साथ जोड़ा जा सकता है।
Google OAuth
पूर्व-आवश्यकताएं
- Google Cloud Console में एक प्रोजेक्ट बनाएं
- "Google Identity" API सक्षम करें
- OAuth 2.0 क्रेडेंशियल बनाएं (Web application प्रकार)
- "Authorized redirect URIs" में अपना Potato सर्वर URL जोड़ें:
https://your-server.com/auth/google/callback
कॉन्फ़िगरेशन
authentication:
method: google_oauth
google_oauth:
client_id: ${GOOGLE_CLIENT_ID}
client_secret: ${GOOGLE_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/google/callback"
# Optional: restrict to specific domain(s)
allowed_domains:
- "umich.edu"
- "research-lab.org"
# Optional: auto-register new users on first login
auto_register: true
# Optional: map Google profile fields to Potato user fields
field_mapping:
username: email # use email as Potato username
display_name: name # show Google display nameडोमेन प्रतिबंध
जब allowed_domains सेट होता है, तो केवल उन डोमेन से ईमेल पते वाले उपयोगकर्ता साइन इन कर सकते हैं। अन्य उपयोगकर्ताओं को त्रुटि संदेश दिखता है:
authentication:
method: google_oauth
google_oauth:
client_id: ${GOOGLE_CLIENT_ID}
client_secret: ${GOOGLE_CLIENT_SECRET}
allowed_domains:
- "umich.edu"
domain_error_message: "This annotation task is restricted to University of Michigan accounts."GitHub OAuth
पूर्व-आवश्यकताएं
- GitHub Settings > Developer settings > OAuth Apps > New OAuth App पर जाएं
- "Authorization callback URL" को
https://your-server.com/auth/github/callbackपर सेट करें - अपना Client ID नोट करें और एक Client Secret जनरेट करें
कॉन्फ़िगरेशन
authentication:
method: github_oauth
github_oauth:
client_id: ${GITHUB_CLIENT_ID}
client_secret: ${GITHUB_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/github/callback"
# Optional: restrict to members of specific GitHub organizations
allowed_organizations:
- "my-research-lab"
- "university-nlp-group"
# Optional: restrict to specific teams within an organization
allowed_teams:
- "my-research-lab/annotators"
# Scopes to request
scopes:
- "read:user"
- "read:org" # needed for organization restriction
auto_register: true
field_mapping:
username: login # GitHub username
display_name: nameसंगठन प्रतिबंध
GitHub OAuth विशिष्ट संगठनों के सदस्यों तक पहुंच प्रतिबंधित कर सकता है। इसके लिए read:org स्कोप की आवश्यकता है:
authentication:
method: github_oauth
github_oauth:
client_id: ${GITHUB_CLIENT_ID}
client_secret: ${GITHUB_CLIENT_SECRET}
allowed_organizations:
- "my-research-lab"
scopes:
- "read:user"
- "read:org"
org_error_message: "You must be a member of the my-research-lab GitHub organization."जेनेरिक OIDC
एंटरप्राइज़ SSO प्रदाताओं (Okta, Azure AD, Auth0, Keycloak, आदि) के लिए, जेनेरिक OpenID Connect एकीकरण का उपयोग करें।
कॉन्फ़िगरेशन
authentication:
method: oidc
oidc:
# Discovery URL (provider's .well-known endpoint)
discovery_url: "https://accounts.example.com/.well-known/openid-configuration"
# Or specify endpoints manually
# authorization_endpoint: "https://accounts.example.com/authorize"
# token_endpoint: "https://accounts.example.com/token"
# userinfo_endpoint: "https://accounts.example.com/userinfo"
# jwks_uri: "https://accounts.example.com/.well-known/jwks.json"
client_id: ${OIDC_CLIENT_ID}
client_secret: ${OIDC_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/oidc/callback"
scopes:
- "openid"
- "profile"
- "email"
auto_register: true
field_mapping:
username: preferred_username
display_name: name
email: emailAzure AD उदाहरण
authentication:
method: oidc
oidc:
discovery_url: "https://login.microsoftonline.com/${AZURE_TENANT_ID}/v2.0/.well-known/openid-configuration"
client_id: ${AZURE_CLIENT_ID}
client_secret: ${AZURE_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/oidc/callback"
scopes:
- "openid"
- "profile"
- "email"
auto_register: true
field_mapping:
username: preferred_username
display_name: nameOkta उदाहरण
authentication:
method: oidc
oidc:
discovery_url: "https://your-org.okta.com/.well-known/openid-configuration"
client_id: ${OKTA_CLIENT_ID}
client_secret: ${OKTA_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/oidc/callback"
scopes:
- "openid"
- "profile"
- "email"
- "groups" # request group membership
auto_register: true
# Restrict to specific groups
allowed_groups:
- "annotation-team"
field_mapping:
username: preferred_username
display_name: name
groups: groupsKeycloak उदाहरण
authentication:
method: oidc
oidc:
discovery_url: "https://keycloak.example.com/realms/annotation/.well-known/openid-configuration"
client_id: ${KEYCLOAK_CLIENT_ID}
client_secret: ${KEYCLOAK_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/oidc/callback"
scopes:
- "openid"
- "profile"
- "email"
auto_register: true
field_mapping:
username: preferred_username
display_name: nameडोमेन प्रतिबंध
सभी OAuth विधियां ईमेल पतों के आधार पर डोमेन प्रतिबंध का समर्थन करती हैं। यह तब उपयोगी है जब आप किसी विशिष्ट संस्था के किसी भी खाते को अनुमति देना चाहते हैं:
authentication:
method: google_oauth # or github_oauth, oidc
domain_restriction:
enabled: true
allowed_domains:
- "umich.edu"
- "stanford.edu"
error_message: "Access is restricted to university accounts."उन OIDC प्रदाताओं के लिए जो email क्लेम शामिल करते हैं, डोमेन प्रतिबंध स्वचालित रूप से काम करता है। जो प्रदाता ईमेल शामिल नहीं करते, उनके लिए आपको स्पष्ट रूप से email स्कोप अनुरोध करना पड़ सकता है।
ऑटो-पंजीकरण
डिफ़ॉल्ट रूप से, उपयोगकर्ताओं को एनोटेट करने से पहले Potato में पूर्व-पंजीकृत होना चाहिए। auto_register: true के साथ, जो भी उपयोगकर्ता सफलतापूर्वक प्रमाणीकृत होता है वह अपने पहले लॉगिन पर Potato में स्वचालित रूप से बनाया जाता है।
authentication:
auto_register: true
auto_register_role: annotator # annotator or adminविशिष्ट उपयोगकर्ताओं को पूर्व-अनुमोदित करने के लिए जबकि अन्य को ब्लॉक करने के लिए:
authentication:
auto_register: false
allowed_users:
- "researcher@umich.edu"
- "student1@umich.edu"
- "student2@umich.edu"
user_not_found_message: "Your account has not been approved. Contact the project administrator."मिश्रित मोड
आप एक साथ एकाधिक प्रमाणीकरण विधियां सक्षम कर सकते हैं। लॉगिन पृष्ठ प्रत्येक सक्षम विधि के लिए बटन और एक वैकल्पिक उपयोगकर्तानाम फ़ील्ड दिखाता है।
authentication:
methods:
- google_oauth
- github_oauth
- username # keep simple username login as fallback
google_oauth:
client_id: ${GOOGLE_CLIENT_ID}
client_secret: ${GOOGLE_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/google/callback"
github_oauth:
client_id: ${GITHUB_CLIENT_ID}
client_secret: ${GITHUB_CLIENT_SECRET}
redirect_uri: "https://your-server.com/auth/github/callback"
# Username login settings
username:
enabled: true
require_password: true # require a password for username login
password_file: "auth/passwords.yaml"माइग्रेशन के दौरान मिश्रित मोड उपयोगी है: उपयोगकर्तानाम लॉगिन के साथ OAuth सक्षम करें, फिर उपयोगकर्तानाम लॉगिन अक्षम करें जब सभी एनोटेटर ने अपने OAuth खाते लिंक कर लिए हों।
सत्र प्रबंधन
प्रमाणीकृत उपयोगकर्ताओं के लिए सत्र व्यवहार कॉन्फ़िगर करें:
authentication:
session:
lifetime_hours: 24 # session duration
refresh: true # refresh session on activity
cookie_secure: true # require HTTPS for cookies
cookie_samesite: "Lax" # SameSite cookie attributeएडमिन प्रमाणीकरण
एडमिन खाते उसी OAuth प्रवाह या एक अलग प्रमाणीकरण विधि का उपयोग कर सकते हैं:
authentication:
method: google_oauth
google_oauth:
client_id: ${GOOGLE_CLIENT_ID}
client_secret: ${GOOGLE_CLIENT_SECRET}
admin:
# Admins must match these emails
admin_emails:
- "pi@umich.edu"
- "lead-ra@umich.edu"
# Or use a separate API key for admin access
api_key: ${ADMIN_API_KEY}HTTPS आवश्यकताएं
OAuth प्रदाताओं को प्रोडक्शन में redirect URIs के लिए HTTPS की आवश्यकता होती है। स्थानीय विकास के लिए, आप localhost के साथ HTTP का उपयोग कर सकते हैं:
# Development (HTTP allowed)
authentication:
google_oauth:
redirect_uri: "http://localhost:8000/auth/google/callback"
# Production (HTTPS required)
authentication:
google_oauth:
redirect_uri: "https://annotation.example.com/auth/google/callback"रिवर्स प्रॉक्सी (nginx, Caddy) के पीछे प्रोडक्शन तैनाती के लिए, सुनिश्चित करें कि प्रॉक्सी सही X-Forwarded-Proto हेडर फॉरवर्ड करता है:
# nginx example
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}पूर्ण उदाहरण
Google OAuth, डोमेन प्रतिबंध और एडमिन API key के साथ पूर्ण प्रोडक्शन प्रमाणीकरण सेटअप:
task_name: "Annotation Project"
task_dir: "."
authentication:
method: google_oauth
google_oauth:
client_id: ${GOOGLE_CLIENT_ID}
client_secret: ${GOOGLE_CLIENT_SECRET}
redirect_uri: "https://annotation.umich.edu/auth/google/callback"
allowed_domains:
- "umich.edu"
auto_register: true
field_mapping:
username: email
display_name: name
session:
lifetime_hours: 48
cookie_secure: true
admin:
admin_emails:
- "pi@umich.edu"
api_key: ${ADMIN_API_KEY}
data_files:
- "data/instances.jsonl"
annotation_schemes:
- annotation_type: radio
name: sentiment
labels: [Positive, Neutral, Negative]
output_annotation_dir: "output/"
output_annotation_format: "jsonl"आगे पढ़ें
- Passwordless Login -- ईमेल-आधारित मैजिक लिंक प्रमाणीकरण
- MTurk Integration -- क्राउडसोर्सिंग प्लेटफॉर्म प्रमाणीकरण
- Admin Dashboard -- उपयोगकर्ताओं और अनुमतियों का प्रबंधन
- Quality Control -- प्रमाणीकृत उपयोगकर्ताओं के साथ एनोटेटर गुणवत्ता सुनिश्चित करना
कार्यान्वयन विवरण के लिए, स्रोत दस्तावेज़ीकरण देखें।