Skip to content

Commit ae62aed

Browse files
committed
Revert "[SYNPY-893] Add multiple profile support (#1194)"
This reverts commit 5b0d7fe.
1 parent 5b0d7fe commit ae62aed

15 files changed

+355
-993
lines changed

docs/tutorials/authentication.md

Lines changed: 13 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[](){ #tutorial-authentication }
22
# Authentication
33

4-
There are multiple ways one can login to Synapse. We recommend users choose the method that fits their workflow best.
4+
There are multiple ways one can login to Synapse. We recommend users to choose the method that fits their workflow.
55

66
## Prerequisites
77

8-
* Create a [Personal Access Token](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens) (**aka: Synapse Auth Token**) obtained
8+
* Create a [Personal Access Token](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens) (**aka: Synapse Auth Token**) token obtained
99
from synapse.org under your Settings.
1010
* Note that a token must minimally have the **view** scope to be used with the Synapse Python Client.
1111
* Include **Download** and **Modify** permissions if you are using the Synapse Python Client to follow any subsequent tutorials.
@@ -20,7 +20,6 @@ Use the [synapseclient.login][synapseclient.Synapse.login] function
2020
```python
2121
import synapseclient
2222
syn = synapseclient.login(authToken="authtoken")
23-
#returns Welcome, First Last!
2423
```
2524

2625
### Command Line Client
@@ -39,133 +38,43 @@ Logged in as: username (1234567)
3938

4039
For writing code using the Synapse Python client that is easy to share with others, please do not include your credentials in the code. Instead, please use the `~/.synapseConfig` file to manage your credentials.
4140

42-
The Synapse Python Client supports multiple profiles within the `~/.synapseConfig` file, enabling users to manage credentials for multiple accounts. Each profile is defined in its own `[profile <profile_name>]` section. A default profile can still be defined using `[default]`.
43-
4441
When installing the Synapse Python client, the `~/.synapseConfig` is added to your home directory.
4542

4643
### Automatically modifying the `~/.synapseConfig` file with the Command line Client
4744
You may modify the `~/.synapseConfig` file by utilizing the [command line client command and following the interactive prompts](./command_line_client.md#config):
4845

49-
#### Modifying the synapse config for multiple profiles
50-
5146
<!-- termynal -->
5247
```
5348
> synapse config
54-
55-
Synapse username (Optional): $MY_USERNAME
56-
57-
Auth token: $MY_SYNAPSE_TOKEN
58-
59-
Configuration profile name (Optional, 'default' used if not specified): $MY_CONFIG_PROFILE
60-
```
61-
62-
#### Adding or updating a specific profile passed in as a command line argument
63-
<!-- termynal -->
64-
```
65-
> synapse --profile $MY_PROFILE_NAME config
66-
67-
Synapse username (Optional): $MY_USERNAME
49+
Synapse username (Optional):
6850
6951
Auth token: $MY_SYNAPSE_TOKEN
7052
```
7153

72-
Note: If you encounter a PermissionError
73-
(e.g., `[Errno 13] Permission denied: '/Users/username/.synapseConfig'`), it is likely that the user does not have write permissions to the `~/.synapseConfig` file.
74-
To resolve this, ensure that you have the necessary permissions to modify this file.
75-
You can change the permissions using the following command:
76-
77-
`chmod u+w ~/.synapseConfig`
78-
79-
8054
### Manually modifying the `~/.synapseConfig` file
8155
The following describes how to add your credentials to the `~/.synapseConfig` file without the use of the `synapse config` command.
8256

83-
Open the `~/.synapseConfig` file using your preferred text editing tool and find/insert the following section(s):
57+
Open the `~/.synapseConfig` file and find the following section:
8458

8559
```
86-
[default]
87-
username = default_user
88-
authtoken = default_auth_token
89-
90-
[profile user1]
91-
username = user1
92-
authtoken = user1_auth_token
93-
94-
[profile user2]
95-
username = user2
96-
authtoken = user2_auth_token
97-
98-
# This section is deprecated. It will be used if a `default` profile or a specific profile is not present in the config file
9960
#[authentication]
100-
#username = default_user
101-
#authtoken = default_auth_token
61+
#username = <username>
62+
#authtoken = <authtoken>
10263
```
10364

104-
`username` is optional when using `authtoken`, but if provided, an additional check to verify the `authtoken` matches the `username` is performed.
105-
106-
The `authoken` is also know as a personal access token. It is generated from your [synapse.org Settings](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)..
107-
108-
### Transitioning from One Profile to Multiple
109-
110-
If you're currently using a single profile (under the `[default]` or `[authentication]` section) and wish to start using multiple profiles,
111-
simply add new sections for each profile with a unique profile name. For example, you can add a profile for user1 and user2 as shown below.
112-
The Synapse Python client will allow you to choose which profile to use at login.
113-
65+
To enable this section, uncomment it. You don't need to specify your username when using authtoken as a pair, but if you do, it will be used to verify your identity. A personal access token generated from your synapse.org Settings can be used as your .synapseConfig authtoken.
11466
```
115-
[default]
116-
username = default_user
117-
authtoken = default_auth_token
118-
119-
[profile user1]
120-
username = user1
121-
authtoken = user1_auth_token
122-
123-
[profile user2]
124-
username = user2
125-
authtoken = user2_auth_token
67+
[authentication]
68+
authtoken = <authtoken>
12669
```
12770

128-
## Logging in with your ~/.synapseConfig file
129-
130-
**Note:** If no profile is specified the `default` section will be used. Additionally, to support backwards compatibility, `authentication` will continue to function. `authentication` will be used if no profile is used and `default` is not present in the configuration file.
131-
132-
### Logging in via python code
71+
Now, you can login without specifying any arguments:
13372

13473
```python
13574
import synapseclient
13675
syn = synapseclient.login()
13776
```
13877

139-
If you want to log in with a specific profile, simply pass the profile name as an argument to `login()`:
140-
141-
```python
142-
import synapseclient
143-
syn = synapseclient.login(profile="user1")
144-
```
145-
146-
### Logging in via the command line
147-
148-
Logs in with the `default` profile, or the profile set in the `SYNAPSE_PROFILE` environment variable:
149-
150-
<!-- termynal -->
151-
```
152-
#For default login
153-
> synapse login
154-
155-
returns Welcome, last first!
156-
```
157-
158-
Logging in with the `profile_name` given:
159-
160-
<!-- termynal -->
161-
```
162-
#For profile login
163-
164-
> synapse --profile profile_name login
165-
166-
Welcome, last first! You are using the 'profile_name' profile.
167-
```
168-
16978
## Use Environment Variable
17079

17180
Setting the `SYNAPSE_AUTH_TOKEN` environment variable will allow you to login to Synapse with a [Personal Access Token](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)
@@ -178,26 +87,21 @@ In your shell, you can pass an environment variable to Python inline by defining
17887
SYNAPSE_AUTH_TOKEN='<my_personal_access_token>' python3
17988
```
18089

181-
Alternatively you may export it first, then start Python:
90+
Alternatively you may export it first, then start: Python
18291

18392
```bash
18493
export SYNAPSE_AUTH_TOKEN='<my_personal_access_token>'
18594
python3
18695
```
18796

188-
Setting the `SYNAPSE_PROFILE` environment variable will allow you to log into Synapse using a specific authentication profile present in your `.synapseConfig` file. This allows you to have multiple profiles present in a single configuration file that you may swap between. Alternatively, you may use the `profile` parameter in Python, or the `--profile` command line flag for all commands like `synapse --profile <profile_name> COMMAND`.
189-
190-
Once you are inside Python, you may simply login without passing any arguments, or pass a profile argument to access a specific profile:
97+
Once you are inside Python, you may simply login without passing any arguments:
19198

19299
```python
193100
import synapseclient
194101
syn = synapseclient.login()
195-
196-
import synapseclient
197-
syn = synapseclient.login(profile="user1")
198102
```
199103

200-
To use the environment variable with the command line client, simply substitute `python` for the `synapse` command:
104+
To use the environment variable with the command line client, simply substitute `python` for the `synapse` command
201105

202106
```bash
203107
SYNAPSE_AUTH_TOKEN='<my_personal_access_token>' synapse get syn123

0 commit comments

Comments
 (0)