Oauth

From 3forge Documentation
Jump to navigation Jump to search

1 | Introduction

OAuth is one of the multiple ways you can authenticate users to 3forge AMI. The 3forge AMI OAuth Plugin makes it easy to integrate AMI with any OAuth based identity manager. It provides a simple standard authentication mechanism and allows you to build access control into your 3forge AMI Layouts.


Go to Section 2 OAuth Quickstart to quickly get started with using the OAuthPlugin.

2 | OAuth Quickstart

2.1 | Quickstart Instructions

Prerequisites:

  1. Find out your identity provider and ensure it allows for OAuth 2.0 Authentication. You will need to know the identity provider url.
  2. Register a new Web App with your identity provider.
    1. Provide a Sign In Redirect Url, we recommend https://<your-server>:33332/oauthRedirectUrl
      1. This will be used in the oauth.redirect.url property
    2. Provide a Sign Out Redirect Url (Optional but recommended)


How to setup the OAuth Plugin

  1. Navigate to your 3forge AMI config directory, it's typically located in ami\amione\config
  2. Create a file called local.properties if one is not already present
  3. Add the properties from Section 2.2 Minimal Configuration to the file local.properties
  4. Update the values of the properties to match your identity provider.
  5. Restart 3forge AMI

2.2 | Minimal Configuration

Note: Please refer to Section 3 OAuth Full Properties List for a detailed understanding of each property


sso.plugin.class=com.f1.ami.web.AmiWebOAuthPluginImpl


# Provide the url to your OAuth 2.0 identity provider

oauth.server.domain=https://oauthprovider.com


# Provide the redirect url that you configured for the app with your identity provider

oauth.redirect.uri=http://localhost:33332/oauthRedirectUrl


# Provide the endpoints for authorization, token and refresh token

oauth.authorization.endpoint=/authorizeEndpoint

oauth.token.endpoint=/tokenEndpoint

oauth.refresh.token.endpoint=/refreshTokenEndpoint


# Provide the client id and secret that will be used for the OAuth authentication

oauth.client.id=clientid

oauth.client.secret=secret


# Replace this with the default scope that is used for Web Based Applications in your firm

oauth.scope=openid profile email offline_access


# Replace this with unique identifier that identifies the user

oauth.username.field=email


# Recommended to replace this with an attribute that identifies the group a user belongs to

oauth.ami.isdev.field=email

oauth.ami.isdev.values=<comma_delimited_list_of_emails>


# Logout Page AMI will display when logged out

web.logged.out.url=/loggedout.htm


# This is enabled for development, disable this after OAuth has been setup

oauth.debug=true


3 | OAuth Full Properties List


Description Property and Default Value
REQUIRED
Specify class to use Oauth SSO
sso.plugin.class=com.f1.ami.web.AmiWebOAuthPluginImpl
REQUIRED
The domain of the auth server account
oauth.server.domain=https://oauthprovider.com
REQUIRED
Set AMI logged out page
web.logged.out.url=/loggedout.htm
REQUIRED
3forge AMI Url for Oauth server to redirect after login
oauth.redirect.uri=http://localhost:33332/oauthRedirectUrl/
REQUIRED
Client ID
oauth.client.id=clientid
REQUIRED
Client secret
oauth.client.secret=secret
REQUIRED
Authorization endpoint
oauth.authorization.endpoint=/authorizeEndpoint
REQUIRED
Token endpoint
oauth.token.endpoint=/tokenEndpoint
REQUIRED
Oauth scope
oauth.scope=openid profile email offline_access
REQUIRED
User Email
oauth.username.field=email
OPTIONAL
The endpoint to get the refresh token
oauth.refresh.token.endpoint=/refreshTokenEndpoint
OPTIONAL
Dev User Email
oauth.ami.isdev.field=email
OPTIONAL
List of dev user emails
oauth.ami.isdev.values=<comma_delimited_list_of_emails>
OPTIONAL
Key that contains the time the access token expires in
oauth.access.token.expires.in=expires_in
OPTIONAL
Code challenge method
oauth.code.challenge.method=S256
OPTIONAL
Java hashing algorithm
oauth.digest.algo=SHA-256
OPTIONAL
Seconds to check refresh token expiration
oauth.session.check.period.seconds=60
OPTIONAL
The 3forge AMI endpoint that triggers the build auth request.
ami.web.index.html.file=index2.htm
OPTIONAL
Enables Debugging Mode
oauth.debug=true


4 | Creating your own AMI OAuth Plugin

The AMI OAuth plugin handles authorization code and access token requests that are needed for Authenticating to AMI. By extending the 3forge AMI OAuth plugin, you can create your own Ami OAuth Plugin if you have custom requirements for access control or entitlements.


There are three main components to the 3forge AMI OAuth Plugin: buildAuthRequest, processResponse, and createAmiUserSSOSession.

4.1 | Main Components of the 3forge AMI OAuth Plugin

The buildAuthRequest method is responsible for creating the url for the Authorization Code request.


The processResponse method is responsible for processing the response from the Authorization Code request, then building an Access Token request. Once it obtains an access token, it needs to return an AmiAuthUser.


The createAmiUserSSOSession is responsible for creating the AmiAuthUser and OAuthSSO Session. The AmiAuthUser can be used to set user session variables or restrict access to layouts. The OAuth Session is accessible in AMIScript by session.getSsoSession().


4.3 | Example Configuration

sso.plugin.class=com.company.3forge.AmiWebOAuthPluginSample


# Include the same properties you need for the Quick Start Guide


# ...


# Enabling debug for development to help with diagnosing


oauth.debug=true