This is a simple Go application that provides a web service for verifying user identity using Microsoft Single Sign-On (SSO). The application is designed to receive an authorization code from the Microsoft identity platform and exchange it for an access token. It then uses the access token to retrieve user profile information from Microsoft Graph.
Before running the application, make sure you have the following:
- Go installed on your system.
- A valid
config/config.jsonfile containing the required configuration parameters. - Environment variables
SSO_STATEandSSO_CLIENT_SECRETset for security.
Ensure that the config/config.json file is correctly configured with the following parameters:
client_id: Your Microsoft application client ID.redirect_uri: The redirect URI configured in your Microsoft application.grant_type: The grant type for authentication.scope: The scope of the access requested.medewerker_email: The email address pattern for authorized employees.medewerker_email2: An additional email address pattern for authorized employees.
-
Run the application:
go run main.go
-
Access the verification endpoint:
Open a web browser and navigate to
http://localhost/verify?code=<authorization_code>&state=<state_value>, replacing<authorization_code>and<state_value>with the actual values received from the Microsoft authentication process.
/verify: Endpoint for verifying Microsoft SSO. Expects query parameterscodeandstatefor the authorization code and state value, respectively.
Make sure to set the SSO_STATE and SSO_CLIENT_SECRET environment variables for enhanced security. These values should match the state value and client secret used during the Microsoft authentication process.
The application uses the following external libraries:
net/http: For handling HTTP requests.encoding/json: For JSON encoding and decoding.
This project is licensed under the MIT License - see the LICENSE file for details.