Skip to content

Commit

Permalink
Support anonymous access
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Nov 23, 2017
1 parent 7e699e2 commit c61ce6d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mantis.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,15 @@ function Use-MantisInstance {

function getCommonHeaders {
$headers = @{
"Authorization" = $instance.token
"User-Agent" = "MantisPowerShell"
}

# Anonymous access instances won't have a token, so check before
# attempting to add the header.
if( ($instance.PSobject.Properties.name -match "token") ) {
$headers["Authorization"] = $instance.token
}

return $headers
}

Expand Down
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,29 @@ Create API Token as per the following [article](https://support.mantishub.com/hc
Create `~/.mantis.companyname.json` with contents like the one below including the appropriate URL and logical
name for the instance.

Example for authenticated instance:
```json
{
"uri": "https://companyname.com/mantisbt/",
"token": "YjQlU7OI0D..........sWC1vGaAuq3Q"
}
```

Example for anonymous access
```json
{
"uri": "https://companyname.com/mantisbt/"
}
```

Select the instance for all future commands:

Use-MantisInstance companyname

Note that the selected instance will be persisted on disk, hence, it will persist across PowerShell
restarts. This is done by copying `.mantis.company.json` to `.mantis.json`. So if the configuration
is changed, re-run the command `Use-MantisInstance`.

## Get Logged In User Info

Get-MantisUser -me
Expand Down

0 comments on commit c61ce6d

Please sign in to comment.