Edge for Private Cloud גרסה 4.17.05
מיפוי תפקידים חיצוני מאפשר לכם למפות את הקבוצות או התפקידים שלכם לתפקידים ולקבוצות של בקרת גישה מבוססת-תפקידים (RBAC) שנוצרו ב-Apigee Edge.
דרישות מוקדמות
- כדי לבצע את ההגדרה הזו, אתם צריכים להיות אדמינים של מערכת Apigee ענן פרטי עם פרטי כניסה של אדמין מערכת גלובלי.
- אתם צריכים לדעת מהי תיקיית השורש של ההתקנה של Apigee Edge Private Cloud. תיקיית השורש שמוגדרת כברירת מחדל היא /opt. אם בחרתם תיקיית שורש אחרת במהלך ההתקנה של Apigee Edge Private Cloud, השתמשו בה במקום ב- /opt כשאתם פועלים לפי ההוראות האלה.
- משיגים את קובצי ה-JAR הנדרשים מ-Apigee.
מוודאים שהמשתמשים רשומים ב-Edge ובשירות הספריות שלכם
כשמשתמשים במיפוי תפקידים, כל המשתמשים שניגשים ל-Edge חייבים להיות קיימים גם בשירות הספריות החיצוני וגם במאגר המשתמשים של Edge. כלומר, כשמוסיפים משתמש לשירות הספריות החיצוני, צריך להוסיף את אותו משתמש גם למאגר המשתמשים של Apigee.
לדוגמה, המשתמש a01@company.com קיים בקבוצה apiadmin בספרייה החיצונית. לאחר מכן, אתם רוצים למפות את המשתמש a01@company.com לתפקיד orgadmin ב-Edge. לכן, קודם צריך להוסיף את המשתמש a01@company.com לקבוצה orgadmin ב-Edge.
במאמר יצירת משתמשים גלובליים מוסבר איך יוצרים משתמשי Edge ומקצים להם תפקידים.
הגדרות ברירת מחדל
מיפוי תפקידים חיצוניים מושבת כברירת מחדל.
הפעלת מיפוי תפקידים חיצוניים
- לפני שתוכלו להשלים את ההגדרה הבאה, אתם צריכים ליצור מחלקת Java שמטמיעה את הממשק ExternalRoleMapperService. לפרטים על ההטמעה הזו, אפשר לעיין בדוגמה להטמעה שבהמשך.
- מתחברים לשרת הניהול של Apigee Edge ואז עוצרים את שרת הניהול:
> /opt/apigee/apigee-service/bin/apigee-service edge-management-server stop - בודקים את הסטטוס של השרתים. מוודאים ששרת הניהול הופסק או לא פועל:
> /opt/apigee/apigee-service/bin/apigee-all status - פותחים את הקובץ /opt/apigee/customer/application/management-server.properties בכלי לעריכת טקסט.
- עורכים את הקובץ management-server.properties עם ההגדרות הבאות:
conf_security_authentication.user.store=externalized.authentication
conf_security_externalized.authentication.role.mapper.enabled=true
conf_security_externalized.authentication.role.mapper.implementation.class=com.customer.authorization.impl.ExternalRoleMapperImpl
חשוב: מחלקת ההטמעה ושם החבילה שצוינו למעלה, ExternalRoleMapperImpl, הם רק דוגמה – זו מחלקה שצריך להטמיע, ואפשר לתת למחלקה ולחבילה כל שם שרוצים. לפרטים על הטמעת המחלקה הזו, אפשר לעיין בדוגמה להטמעה שבהמשך. - שומרים את הקובץ management-server.properties.
- מפעילים את שרת הניהול:
> /opt/apigee/apigee-service/bin/apigee-service edge-management-server start - מוודאים שהשרת פועל:
> /opt/apigee/apigee-service/bin/apigee-all status
השבתת ההרשאה החיצונית
כדי להשבית את ההרשאה החיצונית:
- פותחים את הקובץ /opt/apigee/customer/application/management-server.properties בכלי לעריכת טקסט.
- משנים את מאגר המשתמשים לאימות ל-ldap:
conf_security_authentication.user.store=ldap - מגדירים את המאפיין הבא כ-false:
conf_security_externalized.authentication.role.mapper.enabled=false - מפעילים מחדש את שרת הניהול:
> /opt/apigee/apigee-service/bin/apigee-service edge-management-server restart
מידע על הטמעת הדוגמה של ExternalRoleMapperImpl
בקובץ התצורה management-server.properties שמתואר למעלה, שימו לב לשורה הזו:
conf_security_externalized.authentication.role.mapper.implementation.class=com.customer.authorization.impl.ExternalRoleMapperImpl
המחלקה הזו מטמיעה את הממשק ExternalRoleMapperService, והיא נדרשת. אתם צריכים ליצור הטמעה משלכם של המחלקה הזו, שמשקפת את הקבוצות שלכם. כשמסיימים, ממקמים את המחלקה המקומפלת ב-JAR וממקמים את ה-JAR ב-/<install_dir>/apigee/edge-gateway/lib/infra/libraries.
אתם יכולים לתת למחלקה ולחבילה כל שם שתרצו, כל עוד הם מטמיעים את ExternalRoleMapperService, נגישים ב-classpath שלכם, ויש אליהם הפניה נכונה בקובץ התצורה management-server.properties.
בהמשך מוצגת דוגמה להטמעה של מחלקת ExternalRoleMapperImpl עם הערות מפורטות. כדי לקמפל את המחלקה הזו, צריך להפנות לקובץ ה-JAR הבא שכלול ב-Edge:
/<install_dir>/apigee/edge-gateway/lib/infra/libraries/authentication-1.0.0.jar
package com.apigee.authenticate; import com.apigee.authentication.ConfigBean; import com.apigee.authentication.ConnectionException; import com.apigee.authentication.ExternalRoleMapperService; import com.apigee.authentication.NameSpace; import com.apigee.authentication.NameSpacedRole; import com.apigee.authorization.namespace.OrganizationNamespace; import com.apigee.authorization.namespace.SystemNamespace; import java.util.Collection; import java.util.HashSet; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; /** * * Sample Implementation constructed with dummy roles with required namespaces. * * Created by GopiAlagar on 6/12/15. */ public class ExternalRoleMapperImpl implements ExternalRoleMapperService { InitialDirContext dirContext = null; @Override public void stop() throws Exception { } /** * * This method would be implemented by the customer, Below is the basic * example. * * If User has sysadmin role then it's expected to set SystemNameSpace * along with the * res\quested NameSpace. Otherwise role's requestedNameSpace to be set * for the NameSpacedRole. * * Co<llectionNameSp>acedRole results = new< HashSetNameSp>acedRole(); * * NameSpacedRole sysNameSpace = new NameSpacedRole("sysadmin", * SystemNamespace.get()); * * String orgName = * ((OrganizationNamespace)requestedNameSpace).getOrganization(); * * NameSpacedRole orgNameSpace = new NameSpacedRole ("orgadmin", * requestedNameSpace); * * results.add(sysNameSpace); * * results.add(orgNameSpace<); */ pub>lic CollectionNameSpacedRole getUserRoles(String userName, String password, NameSpace requestedNameSpace) { /* * There are 3 actions performed in the below implementation * 1. Authenticate Given User against ADS * 2. Fetch the internal groups from the ADS * 3. Map the internal group into the apigee-edge roles */ /*************************************************************/ /******************* Authenticate Given User *******************/ /*************************************************************/ // Customer Specific Implementation will override this method // implementation. // Obtain dnName for given username or email address. String dnName = ImplementDnameLookupLogic(); if (dnName == null) { System.out.println("Error "); } DirCont<ext dirContext> = null; Collecti<onNameSpacedRo>le results = new HashSetNameSpacedRole(); try { // Verify the credentials for a given username or dnName // and password in order to create a directory context. dirContext = ImplementDirectoryContextCreationLogic(); /****************************************************/ /********** Fetch internal groups *******************/ /****************************************************/ String groupDN = "OU=Groups,DC=corp,DC=wacapps,DC=net"; SearchControls controls = new SearchControls(); controls.setSearchScope(SearchCon<trols.ONELEV>EL_SCOPE); NamingEnumerationSearchResult groups = dirContext.search(groupDN,"(objectClass=*)", new Object[] { "", "" }, controls); if (groups.hasMoreElements()) { while (groups.hasMoreElements()) { SearchResult searchResult = groups.nextElement(); Attributes attributes = searchResult.getAttributes(); String groupName = attributes.get("name").get().toString(); /**************************************/ /** Map the internal group into the ***/ /** apigee-edge roles ***/ /**************************************/ if (groupName.equals("BusDev")) { results.add(new NameSpacedRole("businessAdmin",SystemNamespace.get())); } else if (groupName.equals("DevSupport")) { results.add(new NameSpacedRole("devOpsAdmin",SystemNamespace.get())); } else if (groupName.equals("Engineering")) { if (requestedNameSpace instanceof OrganizationNamespace) { String orgName = ((OrganizationNamespace) requestedNameSpace).getOrganization(); results.add(new NameSpacedRole("orgadmin", new OrganizationNamespace(orgName))); } } else if (groupName.equals("Operations") || groupName.equals("IT")) { results.add(new NameSpacedRole("sysadmin",SystemNamespace.get())); } else if (groupName.equals("Marketing")) { results.add(new NameSpacedRole("marketAdmin",SystemNamespace.get())); } else { results.add(new NameSpacedRole("readOnly",SystemNamespace.get())); } } } else { /** * In case of no group found or exception found we throw empty * roles. */ System.out.println(" !!!!! NO GROUPS FOUND !!!!!"); } } catch (Exception ex) { ex.printStackTrace(); System.out.println("Error in authenticating User: {}" + new Object[] { userName }); } finally { // Customer implementation to close // ActiveDirectory/LDAP context. } return results; } @Override public void start(ConfigBean arg0) throws ConnectionException { try { // Create InitialDirContext. // Create a directory context based on the // system admin user credentials. dirContext = ImplementDirContextCreationLogicForSysAdmin(); } catch (NamingException e) { // TODO Auto-generated catch block throw new ConnectionException(e); } } }