Project: MinIO (Runtime / Cloud Native Storage)
File: wso2.md

WSO2 is an Identity Server open source and is released under Apache Software License Version 2.0, this document covers configuring WSO2 to be used as an identity provider for MinIO server STS API. JAVA 1.8 and above installed already and JAVA_HOME points to JAVA 1.8 installation. Download WSO2 follow their . Once WSO2 is up and running, configure WSO2 to generate Self contained idtokens. In OAuth 2.0 specification there are primarily two ways to provide idtokens The id_token is an identifier that is hard to guess. For example, a randomly generated string of sufficient length, that the server handling the protected resource can use to lookup the associated authorization information. The id_token self-contains the authorization information in a manner that can be verified. For example, by encoding authorization information along with a signature into the token. WSO2 generates tokens in first style by default, but if to be used with MinIO we should configure WSO2 to provide JWT tokens instead. By default, a UUID is issued as an idtoken in WSO2 Identity Server, which is of the first type above. But, it also can be configured to issue a self-contained idtoken (JWT), which is of the second type above. Open the `<IS_HOME>/repository/conf/identity/identity.xml` file and uncomment the following entry under `<OAuth>` element. ``` <IdentityOAuthTokenGenerator>org.wso2.carbon.identity.oauth2.token.JWTTokenIssuer</IdentityOAuthTokenGenerator> ``` Restart the server. Configure an . Initiate an idtoken request to the WSO2 Identity Server, over a known . For example, the following cURL command illustrates the syntax of an idtoken request that can be initiated over the grant type. Navigate to service provider section, expand Inbound Authentication Configurations and expand OAuth/OpenID Connect Configuration. Copy the OAuth Client Key as the value for `<CLIENT_ID>`. Copy the OAuth Client Secret as the value for `<CLIENT_SECRET>`. By default, `<IS_HOST>` is localhost. However, if using a public IP, the respective IP address or domain needs to be specified. By default, `<ISHTTPSPORT>` has been set to 9443. However, if the port offset has been incremented by n, the default port value needs to be incremented by

Request ``` curl -u <CLIENTID>:<CLIENTSECRET> -k -d "granttype=clientcredentials" -H "Content-Type:application/x-www-form-urlencoded" https://<ISHOST>:<ISHTTPS_PORT>/oauth2/token ``` Example: ``` curl -u PoEgXP6uVO45IsENRngDXj5Au5Ya:eKsw6z8CtOJVBtrOWvhRWL4TUCga -k -d "granttype=clientcredentials" -H "Content-Type:application/x-www-form-urlencoded" https://localhost:9443/oauth2/token ``` In response, the self-contained JWT id_token will be returned as shown below. ``` { "idtoken": "eyJ4NXQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJraWQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiYXpwIjoiUG9FZ1hQNnVWTzQ1SXNFTlJuZ0RYajVBdTVZYSIsImlzcyI6Imh0dHBzOlwvXC9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImV4cCI6MTUzNDg5MTc3OCwiaWF0IjoxNTM0ODg4MTc4LCJqdGkiOiIxODQ0MzI5Yy1kNjVhLTQ4YTMtODIyOC05ZGY3M2ZlODNkNTYifQ.ELZ8ujk2Xp9xTGgMqnCa5ehuimaAPXWlSCW5QeBbTJIT4M5OB2XEVIV6p89kftjUdKu50oiYe4SbfrxmLm6NGSGd2qxkjzJK3SRKqsrmVWEn19juj8fz1neKtUdXVHuSZu6wsbMDy4f9hN2Jv9dFnkoyeNT54r4jSTJ4A2FzN2rkiURheVVsc8qlm8O7g64Az-5h4UGryyXU4zsnjDCBKYk9jdbEpcUskrFMYhuUlj1RWSASiGhHHHDU5dTRqHkVLIItfG48kfb-ehU60T7EFWH1JBdNjOxM9oNyb0hGwOjLUyCUJO_Y7xcd5F4dZzrBg8LffFmvJ09wzHNtQ", "token_type": "Bearer", "expires_in": 3600 } ``` The idtoken received is a signed JSON Web Token (JWT). Use a JWT decoder to decode the idtoken to access the payload of the token that includes following JWT claims: | Claim Name | Type | Claim Value | |:-:|:--:|::| | iss | string | The issuer of the JWT. The '> Identity Provider Entity Id ' value of the OAuth2/OpenID Connect Inbound Authentication configuration of the Resident Identity Provider is returned here. | | aud | string array | The token audience list. The client identifier of the OAuth clients that the JWT is intended for, is sent herewith. | | azp | string | The authorized party for which the token is issued to. The client identifier of the OAuth client that the token is issued for, is sent herewith. | | iat | integer | The token issue time. | | exp | integer | The token expiration time. | | jti | string | Unique identifier for the JWT token. | | policy | string | Canned policy name to be applied for STS credentials. (Recommended) | Using the above `id_token` we can perform an STS request to MinIO to get temporary credentials for MinIO API operations. MinIO STS API uses to validate if JWT is valid and is properly signed. We recommend setting `policy` as a custom claim for the JWT service provider follow and for relevant docs on how to configure claims for a service provider. MinIO server expects environment variable for OpenID configuration url as `MINIOIDENTITYOPENIDCONFIGURL`, this environment variable takes a single entry. ``` export MINIOIDENTITYOPENIDCONFIGURL=https://localhost:9443/oauth2/oidcdiscovery/.well-known/openid-configuration export MINIOIDENTITYOPENIDCLIENTID="843351d4-1080-11ea-aa20-271ecba3924a" minio server /mnt/data ``` Assuming that MinIO server is configured to support STS API by following the doc , execute the following command to temporary credentials from MinIO server. ``` go run client-grants.go -cid PoEgXP6uVO45IsENRngDXj5Au5Ya -csec eKsw6z8CtOJVBtrOWvhRWL4TUCga { "accessKey": "IRBLVDGN5QGMDCMO1X8V", "secretKey": "KzS3UZKE7xqNdtRbKyfcWgxBS6P1G4kwZn4DXKuY", "expiration": "2018-08-21T15:49:38-07:00", "sessionToken": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJJUkJMVkRHTjVRR01EQ01PMVg4ViIsImF1ZCI6IlBvRWdYUDZ1Vk80NUlzRU5SbmdEWGo1QXU1WWEiLCJhenAiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiZXhwIjoxNTM0ODkxNzc4LCJpYXQiOjE1MzQ4ODgxNzgsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvb2F1dGgyL3Rva2VuIiwianRpIjoiMTg0NDMyOWMtZDY1YS00OGEzLTgyMjgtOWRmNzNmZTgzZDU2In0.4rKsZ8VkZnIS_ALzfTJ9UbEKPFlQVvIyuHw6AWTJcDFDVgQA2ooQHmH9wUDnhXBi1M7o8yWJ47DXP-TLPhwCgQ" } ``` These credentials can now be used to perform MinIO API operations, these credentials automatically expire in 1hr. To understand more about credential expiry duration and client grants STS API read further .