Create an OAuth service provider

This task assumes that the OAuth 2.0 feature is enabled. Before using WebSphere Application Server as an OAuth service provider, create one or more OAuth providers. The OAuth service provider includes the authorization server and the resource server.

Steps

  1. Create an OAuth provider configuration file. Ensure the value of filterparameter in file matches the URL of the protected resource.

    • Create the OAuth provider using wsadmin.sh.

      1. Start the WebSphere Application Server.

      2. Start the wsadmin command-line utility

          wsadmin -lang jython
          cd app_server_root/bin

      3. At the wsadmin prompt, enter the following command:

          AdminTask.createOAuthProvider('[-providerName OAuthProviderName -fileName /path/to/ProviderConfigFile]')

        where OAuthProviderName is the OAuth provider name, and ProviderConfigFile is the full path name of the OAuth provider configuration file. For example:

          AdminTask.createOAuthProvider('[-providerName OAuthConfigSample -fileName c:/temp/OAuthConfigSample.xml]')

        The command will copy the provider configuration file to...

          profile_root/config/cells/cell/oauth20

      4. Save the configuration then exit pdadmin:

          AdminConfig.save()
          quit

      5. Restart the WebSphere Application Server.

    • Create the OAuth provider using the administrative console.

      1. Copy the provider configuration file to:

          profile_home/config/cells/cell/oauth20

      2. Log on to the WebSphere Application Server administrative console and click:

          Security > Global security > Web and SIP security > Trust association > Interceptors > com.ibm.ws.security.oauth20.tai.OAuthTAI

      3. Under Custom properties, add the following properties:

          Name Value Desc
          provider_1.name <OauthProviderName> The provider name must be the same as the provider configuration file name, without the file extension. For example, if the provider configuration file has OauthConfigSample.xml, specify OauthConfigSample as the provider name.
          provider_1.filter <filter_condition> Filter condition for the protected resource. For example:

            request-url%=snoop;applicationNames==OAuthApplication

      4. Click OK.

      5. Restart the WebSphere Application Server.

  2. Register OAuth clients.

    Before OAuth clients can access any resources protected by the OAuth trust association interceptor (TAI), the clients must be registered with the OAuth service provider. We can register clients using one of the following two methods.

    • Register clients using an XML file.

      The OauthConfigSample.xml template provider configuration file provides a com.ibm.ws.security.oauth20.plugins.BaseClientProvider class that stores the registered clients in the file base.clients.xml. The base.clients.xml file must exist in the same directory as the provider configuration file under:

        profile_home/config/cells/cell/oauth20

      To use the BaseClientProvider class for registering clients using an XML file, add one or more OAuth clients to the file base.clients.xml. We can use the file base.clients.xml under <app_server_root>/properties as a template for adding registered clients.

    • Register clients using a JDBC database store.

      The OauthConfigSample.xml template provider configuration file contains example parameters for configuring a JDBC database store for registering OAuth clients.

Results

Your WebSphere Application Server is now configured as a service provider for OAuth 2.0. For additional configuration options for your service provider, see:

Related