Use OAuth 2.0 for TeamForge User Authentication
This topic discusses TeamForge OAuth architecture, scopes, supported authorization grant types, Federated Identity Management in TeamForge, and so on. This topic also discusses step by step how to add a client application that wants to access TeamForge's services.
TeamForge OAuth Nomenclature
It is assumed that you are familiar with the OAuth 2.0 and OpenID Connect frameworks, terms and concepts. It's recommended that you read The OAuth 2.0 Authorization Framework RFC 6749 and get familiar with OAuth Roles, Protocol Flow, Access Tokens, Grant Types, Client Types and so on before you proceed.
Here's a list of links and references for further reading.
TeamForge OAuth Overview
In the traditional client-server authentication model, client applications must have access to the Resource Owner's credentials in order to request and access protected resources on the Resource Server. Sharing Resource Owner's credentials such as user names and passwords to third party applications poses several problems, security being one of the major ones.
Frameworks such as the OAuth 2.0 and OpenID Connect help in mitigating such security risks and hence TeamForge's authentication model has been rebuilt on top of OpenID Connect and OAuth 2.0 Authorization frameworks.
TeamForge OAuth Roles
TeamForge OAuth authorization process involves interaction between four entities (roles) such as the user, IdP, SP and client application. The following table lists the roles that an entity can assume in the TeamForge OAuth setup.
Entity/Role | OAuth Term | OIDC Term | SAML Term | Description |
---|---|---|---|---|
User | Resource Owner | End-User | User | Human or machine that intends to access a resource of an SP. Users are, in general, humans. If a machine acts as a user, it is called Agent . |
Service Provider (SP) | Resource Server | Relying Party | Service Provider, Relying Party | Entity that demands authentication to grant access to some resource. The SP trusts the IdP to perform the authentication on its behalf. |
Client | Client | - | Browser | Application interacting with SP and IdP on the user’s behalf. |
Identity Provider (IdP) | Authorization Server | Provider | Identity Provider, Asserting Party | Entity that proves, identifies and authenticates a user. |
OAuth 2.0 Abstract Protocol Flow
The following illustration shows the OAuth 2.0 protocol flow.
- (A) The client application requests authorization from the Resource Owner.
- (B) The Resource Owner responds to the client with a credential called
Authorization Grant
. - (C) The client then redeems the
Authorization Grant
with the Authorization Server for a validAccess Token
(D). - (E) The client then reaches out to the Resource Server with the Access Token and gains access to the protected resource.
For more information about the OAuth 2.0 protocol flow, see OAuth 2.0 Protocol Flow.
TeamForge can act both as an IdP and Service Provider and at times as a client too. The TeamForge Web Application is one of the system defined clients that use TeamForge IdP's OAuth services. For more information about system defined clients, see System Defined Clients.
TeamForge API Authentication and Access Tokens
Both TeamForge REST and SOAP APIs use OAuth 2.0 access tokens for authentication. Clients can obtain access tokens from the token endpoint which is located at /oauth/auth/token
.
Access Tokens
The tokens used by the TeamForge API are Bearer Tokens as specified in RFC 6750. This means that it is possible and allowed to share tokens with multiple clients or to have clients pass tokens to intermediate services, which then delegate tokens to TeamForge. TeamForge tokens use the JSON Web Token (JWT) standard. However, clients should consider access tokens to be opaque in order to guarantee compatibility with future TeamForge versions. It is the client's responsibility to protect the access token against theft. This means that access tokens should only be transmitted over SSL-secured connections and should not be persisted.
TeamForge OAuth Scopes
Scopes can be used to restrict which services a token can be used for. Limiting the number of scopes decreases the potential damage that could occur in case an access token is stolen, so it is advisable to restrict the number of scopes to a minimum.
TeamForge currently supports the following list of scopes.
Scope | Description |
---|---|
urn:ctf:services:ctf | Digital.ai TeamForge application services. Use this scope to call the TeamForge REST API. |
urn:ctf:services:svn | Subversion services. Use this to call the Subversion REST API. |
urn:ctf:services:gerrit | Git/Gerrit services. Use this to call the Git REST API. |
urn:ctf:services:soap60 | SOAP60 services. Use this to call the TeamForge SOAP API. |
Client ID and Client Secret
In order to use TeamForge's OAuth services, a client application must be registered with TeamForge. Upon registration, the client gets its client credentials: Client ID
and Client Secret
. For more information about how to get the Client ID and Client Secret, see Add Clients.
| Client ID | The Client ID is a unique identifier used by TeamForge to identify the client application and is used in building the Authorization URLs. | | Client Secret | The Client Secret is a unique identifier used to authenticate the client application’s identity. |
TeamForge OAuth Grant Types
When a client requests access token from an Authorization Server, it uses the Authorization Grant, which is a credential that represents the Resource Owner's authorization to access protected resources. Of the four standard grant types defined in The OAuth 2.0 Authorization Framework RFC 6749, TeamForge supports the following three grant types:
- Authorization Code (
authorization_code
) - Resource Owner Password Credentials (
password
) - Client Credentials (
client_credentials
)
In addition, TeamForge supports the following custom grant type:
- Anonymous (
rn:ctf:grant_type:anonymous
)