SSO Login into Bitbucket using Drupal as OAuth / OpenID Connect Provider
Overview
The Drupal OAuth/OIDC Server module enables Single Sign-On i.e. SSO between the Drupal site and any Client application that supports the OAuth or OpenID Connect protocol. Here, we go through the steps to connect the module with the Bitbucket. In this Integration of Drupal and Bitbucket, Drupal acts as an Identity Provider i.e. users will be logging into Bitbucket using their Drupal credentials.
Configuration Steps
Set up Bitbucket as an OAuth Client:
- Log into the Bitbucket server.
- Click on the Settings icon in the top right corner.
- Scroll down to the Add-ons section and click on the Find new apps link.
- Search for mO OAuth under the search bar and install it.
- Once the app is installed, click on the Overview -> miniOrange OAuth client from the left navigation menu.
- Copy the Callback URL and keep it handy.
- From the Select Application dropdown, select Custom OAuth App.
- Enter the Application Name in the App Name text field.
Create SSO Application in Drupal:
- Navigate to the Drupal site and go to the Configuration -> miniOrange OAuth server configuration -> OAuth Client tab.
- Click on the Add Client button to add a new application.
- Enter the name of your application under the Application Name text field.
- Paste the copied Callback URL into the Callback/Redirect URL text field. You can add multiple Callback URLs by clicking on the Add More button next to the Callback/Redirect URL text field.
- Click on the Save button.
Integrating Bitbucket with Drupal:
- Go to the OAuth Client tab of the Drupal OAuth Server module, Navigate to the Configure Applications section, and copy the Client ID.
- Paste the copied Client ID into the Client ID text field of the app in the Bitbucket dashboard.
- Navigate back to the Drupal site and copy the Client Secret.
- Paste the copied Client Secret into the Client Secret text field of the app in the Bitbucket dashboard.
- Add the Scope and Endpoints as specified in the table below (You can also get the same from the Scope & Endpoints section of the Drupal site → Configuration → miniOrange OAuth server configuration → OAuth Client):
Scope | profile openid email |
---|---|
Authorization Endpoint | {base_url_of_the_drupal_site}/mo/oauth2/authorize |
Token Endpoint | {base_url_of_the_drupal_site}/mo/oauth2/token |
Get User Information Endpoint | {base_url_of_the_drupal_site}/mo/oauth2/userinfo |
- Click on the Save button to save your configurations.
- Navigate to the Sign In Settings tab.
- Enable the Enable or disable SSO for your Bitbucket server radio button.
- Under the Login Button Text, enter the text that you wish to show on the SSO Login button. Click on the Save button to save your changes.
Test Connection between Bitbucket and Drupal:
- Click on the Test Configuration button in the app at the Bitbucket dashboard. to test the connection between the Drupal site and Bitbucket Application.
You have successfully configured Bitbucket as an OAuth Client and Drupal as an OAuth Server.
Let’s see how this works:
- Open a new window/private browser and navigate to the login page of the bitbucket website.
- Click on the Login with Drupal button.
- Clicking on that button will automatically redirected to the Drupal site login page. Enter the Drupal credentials and click on the Log in button.
- After successful authentication, browser will be redirected back with successful login into the Bitbucket site.
You have successfully performed the SSO between Bitbucket and Drupal!
Need Assistance?
If you face any issues during the configuration or if you want some additional features, please contact us at drupalsupport@xecurify.com.
Additional Features:
- Add multiple Callback/Redirect URL
- Add custom user attributes to be sent in response
- Use enable asymmetric signing algorithm
- Enable single logout