|
| 1 | +# MAGE Authentication and Identity Providers |
| 2 | + |
| 3 | +To configure authentication settings and identity providers |
| 4 | +1. Click the gear icon in the upper right of the MAGE web app to load the _Admin_ page. |
| 5 | +1. Click, the _Settings_ tab in the tab strip on the left of the page. |
| 6 | +1. Click the _Authentication_ tab near the top of the main content pane. This tab should be selected by default. |
| 7 | +1. Click any of the accordion headings to expand the section for the authentication you want to configure, or |
| 8 | + click the _New Authentication_ button to add a new authentication identity provider. |
| 9 | + |
| 10 | +## Local |
| 11 | + |
| 12 | +## OAuth 2.0 |
| 13 | + |
| 14 | +Here is an example of using Google's OAuth 2.0 [endpoints](https://developers.google.com/identity/gsi/web/guides/overview) to authenticate MAGE |
| 15 | +users. This setup is very similar to Google OpenID Connect authentication. |
| 16 | + |
| 17 | +Obtain your _Client Identifier_ and _Client Secret_ from Google's [API Console](https://console.cloud.google.com/apis/credentials/oauthclient). |
| 18 | +Additionally on that page, ensure you register the correct callback URL, e.g., `https://mage.example.com/auth/oauth/callback` |
| 19 | + |
| 20 | +On the MAGE Admin page, click the _Settings_ tab. |
| 21 | + |
| 22 | +_Authorization URL_ - `https://accounts.google.com/o/oauth2/v2/auth` |
| 23 | +_Token URL_ - `https://oauth2.googleapis.com/token` |
| 24 | +_User Profile URL_ - `https://www.googleapis.com/oauth2/v3/userinfo` |
| 25 | +_Scopes_ - `profile,email,openid` |
| 26 | + |
| 27 | +Click the _Advanced_ section header to expand the advanced settings panel. |
| 28 | +_Profile ID Property_ - `sub` |
| 29 | +_Display Name Property_ - `name` |
| 30 | + |
| 31 | +## LDAP |
| 32 | + |
| 33 | +You can setup MAGE to authenticate users with an LDAP server. For development |
| 34 | +testing, the [`auth-idp`](../docker/auth-idp/docker-compose.yml) Compose file |
| 35 | +uses the [osixia/openldap](https://github.com/osixia/docker-openldap) and |
| 36 | +[osixia/phpLDAPAdmin](https://github.com/osixia/docker-phpLDAPAdmin) images |
| 37 | +for LDAP services. Start the `mage-idp-ldap` and `mage-idp-ldap-ui` LDAP |
| 38 | +services with the following commands. |
| 39 | +```bash |
| 40 | +cd docker/auth-idp |
| 41 | +docker compose up -d mage-idp-ldap mage-idp-ldap-ui |
| 42 | +``` |
| 43 | +You can interact with the LDAP admin UI by browsing to https://localhost:6443. |
| 44 | +You'll need to by-pass your browser's warning about a self-signed certificate. |
| 45 | +Click the _Login_ link on the left pane. The root user name and password for |
| 46 | +the LDAP server are `cn=admin,dc=wgd,dc=com` and `i found something`, |
| 47 | +respectively. |
| 48 | + |
| 49 | +You can then use the phpLDAPAdmin UI to setup a simple group structure. |
| 50 | +1. Click the _dc=wgd,dc=com_ root node in the tree view on the left of the page. |
| 51 | +1. In the main pane, click _Create a child entry_. |
| 52 | +1. Select the _Generic: Posix Group_ template. |
| 53 | +1. Enter a name for the group in the _Group_ field, e.g., `Field Agents`. |
| 54 | +1. Click the _Create Object_ button, then click the _Commit_ button on the next page. |
| 55 | +1. Click the root node again in the tree view. |
| 56 | +1. Click _Create a child entry_ in the main pane. |
| 57 | +1. Select the _Generic: Organizational Unit_ template. |
| 58 | +1. Enter a name in the _Organizational Unit_ field, e.g., `Field Agents`. |
| 59 | +1. Click the _Create Object_ button, then click the _Commit_ button on the next page. |
| 60 | +1. The main pane should now display the organization unit you just created. |
| 61 | +1. Click _Create a child entry_ in the main pane. |
| 62 | +1. Select the _Generic: User Account_ template. |
| 63 | +1. Fill the form fields, e.g., |
| 64 | + |
| 65 | + | | | |
| 66 | + | ---: | --- | |
| 67 | + | _First Name_ | `Bruce`| |
| 68 | + | _Last Name_ | `Wayne` | |
| 69 | + | _Common Name_ | `Batman` | |
| 70 | + | _User ID_ | `batman` | |
| 71 | + | _Password_ | `i heart alfred` | |
| 72 | + | _GID Number_ | `Field Agents` | |
| 73 | + |
| 74 | +1. Click the _Create Object_ button, then click the _Commit_ button on the next page. |
| 75 | +You now have a simple group structure and user account in your LDAP database. |
| 76 | + |
| 77 | +Now that you have an LDAP database with a user account, you can configure LDAP |
| 78 | +authentication in MAGE. This assumes you're running a MAGE server on |
| 79 | +http://localhost:4242. |
| 80 | +1. Open the MAGE web app in your browser. |
| 81 | +1. Click the gear icon in the top right to load the _Admin_ page. |
| 82 | +1. Click the _Settings_ tab in the vertical tab strip on the left. |
| 83 | +1. The _Authentication_ tab in the main pane should already be active. Click |
| 84 | + the tab if not. |
| 85 | +1. Click the _New Authentication_ button. |
| 86 | +1. Enter a title for the authentication IDP, e.g. `Test LDAP`. |
| 87 | +1. Click the _Next_ button. |
| 88 | +1. Select `LDAP` from the _Choose a type_ drop-down. |
| 89 | +1. Click the _Next_ button. |
| 90 | +1. Fill the fields on the _Settings_ step as follows. |
| 91 | + | | | |
| 92 | + | ---: | ---| |
| 93 | + | **_Server_** | |
| 94 | + | _URL_ | `ldap://localhost:389` | |
| 95 | + | **_Authentication_** | |
| 96 | + | _Bind DN_ | `cn=admin,dc=wgd,dc=com` | |
| 97 | + | _Bind Credentials_ | `i found something` | |
| 98 | + | **_User Search_** | |
| 99 | + | _Search Base_ | `ou=Field Agents,dc=wgd,dc=com` | |
| 100 | + | _Search Filter_ | `(uid={{username}})` | |
| 101 | + | _Search Scope_ | `one` | |
| 102 | + | **_Advanced_** | |
| 103 | + | _Profile ID Property_ | `uid | |
| 104 | + | _Display Name Property_ | `cn` | |
| 105 | +1. Click the _Next_ button. |
| 106 | +1. Adjust the color settings to your preference. |
| 107 | +1. Click the _Next_ button. |
| 108 | +1. Review the settings and click the _Save_ button. |
| 109 | +1. Open a new private browser tab or window and load your MAGE server web app. |
| 110 | +1. The sign-in page should display a button labeled _SIGN IN WITH LOCAL LDAP_ |
| 111 | + under two text fields. |
| 112 | +1. In the _Local LDAP Username_ text field, enter `batman`. |
| 113 | +1. In the _Local LDAP Password_ text field, enter `i heart alfred`. |
| 114 | +1. Click the _SIGN IN WITH LOCAL LDAP_ button. |
| 115 | +1. The page will most likely display a dialog that states the account needs |
| 116 | + admin approval. |
| 117 | +1. In the browser tab with your MAGE admin page, click the _Users_ tab in the |
| 118 | + tab strip on the left. |
| 119 | +1. Click the _Inactive_ search facet near the top left of the main pane. The |
| 120 | + user list should contain the _Batman_ user with a green _Activate_ button. |
| 121 | +1. Click the _Activate_ button next to the _Batman_ user. |
| 122 | +1. Return to the private browser tab where you initially signed in with the |
| 123 | + LDAP account. |
| 124 | +1. Ensure the LDAP username and password fields are still filled, then click |
| 125 | + the _SIGN IN WITH LOCAL LDAP_ button. |
| 126 | +1. The app may prompt for a device UID if your settings dictate. Enter the |
| 127 | + device UID. |
| 128 | +1. You are now authenticated with your LDAP account. |
0 commit comments