Log out

Bearer tokens are valid for a limited period of time. User bearer tokens will expire after 24 hours of inactivity, and application bearer tokens will expire after 10 minutes of inactivity. An application may terminate its session to immediately invalidate its bearer token.

TIP
It is a good idea to do this before an application exits to limit the possibility of a stolen bearer token being used to access the Fortanix DSM server.

C++

CK_RV logout(CK_FUNCTION_LIST_PTR p11, CK_SESSION_HANDLE hSession) {
	return p11->C_Logout(hSession);
}

C#

AuthenticationApi authenticationApi = new AuthenticationApi();
AuthResponse response = authenticationApi.Terminate();

Go

client := sdkms.Client{
Endpoint: "<Endpoint URL>",
HTTPClient: http.DefaultClient,
}
ctx := context.Background()
_, err := client. AuthenticateWithAPIKey(ctx, <API Key>)
client.TerminateSession(ctx)

Java

AuthenticationApi authenticationApi = new AuthenticationApi(apiClient);
authenticationApi.terminate();

Python

api_instance = sdkms.v1.AuthenticationApi(api_client=client)
api_instance.terminate()

PHP

public function logout() {
    $authenticationApi = new Swagger\Client\Api\AuthenticationApi($client);
    $authInstance->terminate();
}

Javascript

var logoutCallback = function(error, data, response) {
    if (error) {
        console.error("Error: " + JSON.stringify(response));
    } else {
        console.log('logout successfully');
    }
};

var authenticationApi = new FortanixSdkmsRestApi.AuthenticationApi()
authenticationApi.terminate(logoutCallback);

 

REST API using curl

curl <Endpoint URL>/sys/v1/session/terminate -H 'Authorization: Bearer YhXwwa- 6C...L9kRxswmPZkEFQ2ig5g'
Was this article helpful?
0 out of 0 found this helpful