Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Commit bd71c8a

Browse files
committed
doc fixes
1 parent 97bb339 commit bd71c8a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Content-Length: 6
8080
value1
8181
```
8282

83-
[Here's an example](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/java/session/data_types/CustomTypeSession) with a `CustomType` data type session:
83+
[Here's an example](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/java/session/data_types/CustomTypeSession.java) with a `CustomType` data type session:
8484
```
8585
$ curl -i --data "my_login,42" http://localhost:8080/api/do_login
8686
@@ -205,7 +205,7 @@ ok
205205
```
206206
The timestamp attached to the session is `1505470200180` and translates to `Fri Sep 15 2017 10:10:00` which is 5 minutes ahead of the time, when the request was sent `Fri, 15 Sep 2017 10:05:00 GMT`.
207207

208-
## Session Continuity #{refreshable}
208+
## <a name="refreshable"> Session Continuity
209209
### What type of sessions are available
210210
There is the `OneOff` session which when expired is of no use anymore.
211211
An alternative is the `Refreshable` session.
@@ -342,7 +342,8 @@ This can be either `OneOff` or `Refreshable`.
342342
Yes.
343343

344344
### <a name="secure-cookie"></a>How can I use Cookies in a secure way?
345-
1. Use the `invalidateSession` directive when a user logs out or doesn't need that session any longer.
345+
1. Use the `invalidateSession` directive when a user logs out or doesn't need that session any longer
346+
346347
This is demonstrated by the `do_logout` route in the [CookieTransport example](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/java/session/transport/CookieTransport.java).
347348
Its purpose is to send an empty `_sessiondata` Cookie to the client (typically a browser).
348349
In consequence, the browser should erase that Cookie to prevent an attacker to read the cookie later on.
@@ -362,6 +363,7 @@ The Cookie does no longer contain any session data.
362363
It's still possible, that although the browser erased the Cookie, the attacker got it. Therefore:
363364

364365
2. Use a sensible `max-age` value which defaults to 7 days
366+
365367
For use cases where it make sense, set the `max-age` property to a low value, for example `5 minutes`.
366368
This is especially true, when your application allows to access sensitive data, like bank accounts, emails, etc.
367369
The `max-age` property is set in `application.conf`, like in [this example](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/resources/application.conf).
@@ -380,6 +382,7 @@ The supplied authentication is not authorized to access this resource
380382
3. Secure your transfer protocol - use HTTPS.
381383

382384
4. Enable the `Secure` option for Cookies
385+
383386
The `Secure` attribute is explained in [RFC 6265](https://tools.ietf.org/html/rfc6265#section-4.1.2.5) in more detail.
384387
This does not prevent the server from sending the Cookie to the client.
385388
It's just a flag for the client.
@@ -456,7 +459,7 @@ In such a use-case however, [Refresh Tokens](#refreshable) which are valid for 1
456459

457460
### Is it possible to modify the session data on the client side?
458461
No. The session is signed by the server and changes to the session's content are picked up and rejected.
459-
In other words, it is not possible to login with valid credentials and then havong a valid token pretend to be a different user, like in this example:
462+
In other words, it is not possible to login with valid credentials and then having a valid token pretend to be a different user, like in this example:
460463

461464
```
462465
$ curl -i -H "Authorization: EAA15F51D825EFBCC1A2A0D43C65CFCA505F2497-1505383157632-xmy_login" http://localhost:8080/api/current_login
@@ -520,7 +523,7 @@ You may not want to share it for various reasons, like when it is a sequential n
520523
Another example would be data that is expensive to fetch or require access to a paid API or a 3rd party call.
521524
If such data has to be put in context with a particular user, therefore sent as part of the session data, and the client should not be able to read it, then encryption is the way to go.
522525

523-
## Session Directives #{directives}
526+
## <a name="directives"></a> Session Directives
524527
### What are these session directives exactly for?
525528
Including `akka-http-session` directives into the route chain, you can require an endpoint to be accessible only, if a valid session is provided by the client.
526529
Also there's a directive to initiate or invalidate a session when accessing a particular endpoint.
@@ -531,7 +534,7 @@ Adding this directive to a route chain allows you to initialize a session.
531534
Depending on the transport type, either a `Set-Authorization` header or a `Set-Cookie` header are set with a new session.
532535
It is up to the client to read the appropriate Header and use the session in subsequent calls.
533536

534-
### What is the `session` directive good for? #{session-directive}
537+
### <a name="session-directive"></a> What is the `session` directive good for?
535538
This directive is responsible for extracting the session result to be used further on the server side.
536539
A session result can be `Decoded` (valid), `CreatedFromToken`, `Expired`, `Corrupt` or having no token present `TokenNotFound`
537540
The directive does not require the client to provide a session.
@@ -585,7 +588,7 @@ Take a look at [How can I use Cookies in a secure way?](#secure-cookie) and [Eve
585588
This one is very similar to the `session` directive.
586589
In this case however, we get access to the session details, which is an `Optional`.
587590
Based on that we can decide on the server side, how to proceed.
588-
In the [OptionalSession](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/java/session/directives/OptionalSession.java) example, we either reply with `no session` or with the session details, if present.
591+
In the [OptionalSession](https://github.com/softwaremill/akka-http-session-faq/tree/master/src/main/java/session/directives/OptionalSessionDirective.java) example, we either reply with `no session` or with the session details, if present.
589592

590593
### What is the `requiredSession` directive good for?
591594
This directive is used to secure endpoints.
@@ -683,7 +686,6 @@ Content-Length: 8
683686
684687
my_login
685688
```
686-
**Do not forget to include the Bearer prefix, otherwise the server will display a WARN message.**
687689

688690
## CSRF protection
689691
### What is it and (when) do I need it?
@@ -725,8 +727,6 @@ Welcome
725727
```
726728
Without that cookie we would be not able to access the `/api/do_login` endpoint:
727729
```
728-
$ curl -i --data "my_login" http://localhost:8080/api/do_login
729-
730730
$ curl -i --data "my_login" http://localhost:8080/api/do_login
731731
HTTP/1.1 403 Forbidden
732732
Server: akka-http/10.0.9

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ dependencies {
1818
compile "com.softwaremill.akka-http-session:core_2.11:$akkaHttpSessionV"
1919
compile "com.softwaremill.akka-http-session:jwt_2.11:$akkaHttpSessionV"
2020

21-
compile 'org.slf4j:slf4j-api:1.7.5'
21+
compile 'org.slf4j:slf4j-log4j12:1.7.5'
2222

2323
}

0 commit comments

Comments
 (0)