-
Notifications
You must be signed in to change notification settings - Fork 422
OpenID Connect authentication configuration
OpenID Connect is an authentication layer on top of OAuth 2.0 framework. Major authentication providers like Google and Azure already have support for it.
For the following process, we are using Auth0 as an authentication provider. However, except for the registration process, everything else should be same for all providers.
- A provider which supports OpenID Connect Authorization Code Flow (Auth0 for example)
- Network connectivity with provider from the server (server will make some
GET
andPOST
requests to the provider) - Administrative account on FOSSology
- Signup with Auth0 and add a new application as "Regular Web App":
- Goto application "Settings" and fill out basic information.
- Add "Application Login URI" and "Allowed Callback URLs" to point to your FOSSology homepage.
- Add the server domain to "Allowed Web Origins" and "Allowed Origins (CORS)".
- Under application setting, goto bottom in Advance Settings and make sure "Authorization Code" Grant Type is checked.
- Under Applications, goto APIs and copy the "API Audience" URL.
- Paste this copied URL in your account settings as "Default Audience".
- Without this step, Auth0 generates a proprietary access token and break the application.
- Login to FOSSology and head over to "Admin > Customize".
- Find following fields and fill them.
- OIDC App Name: The name shown on login button.
- OIDC Client Id: "Client ID" from Auth0
- OIDC Secret: "Client Secret" from Auth0
- Redirect URL: This will be the callback URL (the URL where app is hosted).
- Make sure the redirect URL matches callback URL in Registering application section.
- OIDC Discovery URL: Available under "Advanced Settings > Endpoints" as "OpenID Configuration".
- Hit "Update" to save the changes. FOSSology will try to pull other URLs from the Discovery URL. Make sure all fields are filled.
- "Logout URL" is optional and is used to redirect user once they logout.
- If some of the fields are not populated from discovery url, make sure to fill them manually. All the fields (except Logout URL) are required for OIDC to work.
- The "OIDC Client Id Claim" is required for REST API authentication and is explained in Verify client id claim section bellow.
- Create a user in Auth0 under "User Management".
- Create user with the username as email entered in Auth0.
- The current authentication mechanism gets the email of user from auth provider and create a session for the user with same username.
- Logout if you are currently logged in and there should be additional button "Login with (OIDC App Name)" like bellow.
- Try to login with the new button. If there are any errors, they will be mentioned at the message space in UI.
Once OIDC login is setup on the instance, the password based login can be disabled.
- Open the
/etc/fossology/fossology.conf
or/usr/local/etc/fossology/fossology.conf
file. - Find the
[AUTHENTICATION]
section and modifyprovider
toexternal
.- Doing so, users will no longer be allowed to use their passwords for login.
- To revert, simply change the value of
provider
topassword
.
Currently FOSSology uses Bearer tokens for REST API authentication. But with OIDC integration, it can be replaced with OpenID Connect Machine-to-machine tokens.
Topic | OIDC | FOSSology |
---|---|---|
Standard | OAuth 2.0's Client Credentials Grant | Does not follow any standard |
Life span | Granularity in seconds | Upto 30 days (increment of 1 day) |
Verification | JWT verification (typically with certificates) | Secure key stored with FOSSology DB |
Authority | Trusted party | FOSSology server |
Generating new token | Client id and secret (can be changed anytime) | FOSSology username and password (mostly static) |
With all these benefits and OAuth 2.0 being a standard protocol, accessing FOSSology's REST API will be more easier and secure.
- From the auth provider, register a new "Machine to Machine Application". All providers should provide it under "Client Credentials" grant.
- Select your default API and give permission "read:clients" and Authorize. For other providers, this step is optional.
- Note the "Client ID", "Client Secret" and "OAuth Token URL" (under Settings > Advanced Settings > Endpoints). You will require this to generate tokens for your client.
Since "Client Credentials" does not provide information about the user, FOSSology can not authorize the request. To do so, we can make use of client id to setup the link between user and token as most auth provider inject the client id in the access token.
- Make sure OIDC tokens are allowed in
fossology.conf
.- Open the
/etc/fossology/fossology.conf
or/usr/local/etc/fossology/fossology.conf
file. - Find the
[AUTHENTICATION]
section and modifyresttoken
tooauth
orboth
.
- Open the
- As the intended user, login to FOSSology and navigate to "Admin > Users > Edit User Account".
- Find "Add new oauth client" and provide the client a name, paste the Client ID from auth provider and select a scope.
- Note: Do copy the client id exactly from MyID Connect portal without any modifications, otherwise verification will always fail.
-
Note: One client can have only one scope and can be registered only once. Do fill the scope with care.
- After clicking "Add new client", you should see following message. And clicking on "Reveal" button should display the client id as well.
- From Quick Start, select an implementation in your language and get the
access_token
.- It requires sending a post request to Token endpoint.
- The request body should contain
"grant_type": "client_credentials"
and respectiveclient_id
andclient_secret
.
- Response will contain the
access_token
which can be used while calling FOSSology API.
Different implementations of auth providers exposes client id as different claim. Check the claim used by your provider and modify the default value.
- Copy the access token provided by the auth provider as described in Generating token section.
- Paste it on a JWT analyzer tool like jwt.io and look for your client id in payload.
- As seen in the screenshot bellow, the claim is
azp
and same should be updated.
- As seen in the screenshot bellow, the claim is
- Update the "OIDC Client Id Claim" under "Admin > Customize".
- Use the provided access token as the Bearer token.
- Request the endpoint
/api/v1/users/self
. - If the request was successful and information about your user is returned, the integration was done successfully.
The REST API token type can be restricted based on fossology.conf
.
- Open the
/etc/fossology/fossology.conf
or/usr/local/etc/fossology/fossology.conf
file. - Find the
[AUTHENTICATION]
section and modifyresttoken
. The value can be:-
token
: Allow only old JWT tokens -
oauth
: Allow only new OIDC tokens -
both
: Allow both old and new tokens
-
Please open an issue/discussion in case any assistance is required.
- Nomos
- Monk
- MonkBulk
- ReSo-(REUSE.Software)
- Reuse clearing with reuser
- ScanCode agent
- Copyright
- ECC
- Package Agent
- Maintenance Agent
- Mimetype Agent
- Buckets
- Spasht Agent
- Email notification configuration
- Migration to UTF 8 DB
- External authentication configuration
- OpenID Connect authentication configuration
- Access Control