Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
briksoftware committed Aug 5, 2015
1 parent c2c0ebe commit 27d79b3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ Currently two authentication methods are supported: HTTP Basic and Token-based.

### HTTP Basic Example
```elixir
PlugAuth.Authentication.Basic.add_credentials("Admin", "SecretPass", %{role: :admin})
creds = PlugAuth.Authentication.Basic.encode_credentials("Admin", "SecretPass")
PlugAuth.CredentialStore.Agent.put_credentials(creds, %{role: :admin})
```

### Token Example
```elixir
token = PlugAuth.Authentication.Token.generate_token
PlugAuth.Authentication.Token.add_credentials(token, %{role: :admin})
PlugAuth.CredentialStore.Agent.put_credentials(token, %{role: :admin})
```

The last argument in both cases can be any term, except nil. On succesful authentication it will be stored by the authentication plug in the assign map of the connection with the :authenticated_user atom as key. You can retrieve it using
The last argument in both cases can be any term, except nil. On succesful authentication it will be stored by the authentication plug in the assign map of the connection with the :authenticated_user atom as key. You can retrieve it using

```elixir
PlugAuth.Authentication.Utils.get_authenticated_user(conn)
Expand Down

0 comments on commit 27d79b3

Please sign in to comment.