kno 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +95 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92c0ded3e6196ac6326c495ea335bbf925328429a5b7a2e832b324284ae7263
|
4
|
+
data.tar.gz: b5b6ce36987741f3dbe2ac65e45b07909ed05dfe595b5bd08d09ed3ba9db58c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef7e5e0646c7d3c0496b9790600aa66f264b8df0a9357dcd7d077b202d88b6e37b567256b7184c1726d983699a44a148be97c5b28ef979a58524c297bcb5797
|
7
|
+
data.tar.gz: 98be753efd3f1569c3aa0c1bb780e07375d3b8a60e35e2301fe3a4ab011ce0ec1d273d499929cf1a9f8ada7a17cbce562e8f79c1bc9be1b43c5f8901f05c562f
|
data/README.md
CHANGED
@@ -11,8 +11,8 @@ It also allows users to set up device based authentication so they don't have to
|
|
11
11
|
|
12
12
|
Add `kno` as a dependency in your `Gemfile`:
|
13
13
|
|
14
|
-
```
|
15
|
-
gem
|
14
|
+
```ruby
|
15
|
+
gem 'kno'
|
16
16
|
```
|
17
17
|
|
18
18
|
Install it using bundler, run:
|
@@ -21,6 +21,98 @@ Install it using bundler, run:
|
|
21
21
|
$ bundle install
|
22
22
|
```
|
23
23
|
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
This library integrates Kno into any Rack based application, including Rails, Hanami and Sinatra.
|
27
|
+
|
28
|
+
<!-- - [Rails](#rails-integration)
|
29
|
+
- [Sinatra](#sinatra-integration) -->
|
30
|
+
|
31
|
+
### Rails integration
|
32
|
+
|
33
|
+
<!-- See [MyRailsApp](examples/my_rails_app) -->
|
34
|
+
|
35
|
+
#### Configure middleware
|
36
|
+
|
37
|
+
Add `Kno::Session` to the middleware stack, by configuring it in `/my_app/config/application.rb`
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
module MyApp
|
41
|
+
class Application < Rails::Application
|
42
|
+
# ...
|
43
|
+
config.load_defaults 6.0
|
44
|
+
|
45
|
+
config.middleware.use Kno::Session, sign_in_redirect: "/"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
_Make sure to add `Kno::Session` after the default middleware as it requires the session middleware to be applied._
|
51
|
+
|
52
|
+
#### Add sign in/out button
|
53
|
+
|
54
|
+
Use the helpers that Kno added to the request to show the correct sign in, or sign out, button.
|
55
|
+
|
56
|
+
```erb
|
57
|
+
<%= request.env['kno'].session_button().html_safe %>
|
24
58
|
```
|
25
|
-
|
59
|
+
|
60
|
+
#### Check the user is authenticated
|
61
|
+
|
62
|
+
Controllers can check if a users is authenticated by looking up there `persona_id`.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
persona_id = request.env['kno'].persona_id
|
26
66
|
```
|
67
|
+
|
68
|
+
With Kno users are uniquely identified by their `persona_id`.
|
69
|
+
If the request is unauthenticated then the value will be nil.
|
70
|
+
|
71
|
+
#### Local development
|
72
|
+
|
73
|
+
Authentication is now setup for local development.
|
74
|
+
Run locally and click the sign in button and you should see a sign in modal.
|
75
|
+
|
76
|
+

|
77
|
+
|
78
|
+
Enter your **real** email address. Kno runs a service for local development that sends a limited number of emails.
|
79
|
+
|
80
|
+
### Get production keys
|
81
|
+
|
82
|
+
To use Kno in production you will need site and API tokens for your application.
|
83
|
+
|
84
|
+
Create an account at [trykno.com](https://trykno.com) and follow the guidance to create your first space.
|
85
|
+
This will direct you to create a `site_token` and `api_token`.
|
86
|
+
Add these to your environment and edit the middleware configuration.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
config.middleware.use Kno::Session,
|
90
|
+
sign_in_redirect: "/"
|
91
|
+
site_token: ENV["KNO_SITE_TOKEN"],
|
92
|
+
api_token: ENV["KNO_API_TOKEN"]
|
93
|
+
```
|
94
|
+
|
95
|
+
**NOTE: The tokens do not have to be stored in the environment.
|
96
|
+
However the api token MUST be kept secure and should not be committed to your applications source code.**
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Contributions are very welcome. Please do open an issue or pull request or reach out to us at [team@trykno.com](mailto:team@trykno.com)
|
101
|
+
|
102
|
+
#### Docker
|
103
|
+
|
104
|
+
If you do not have node installed you can run locally in Docker with the following command.
|
105
|
+
|
106
|
+
```bash
|
107
|
+
docker run \
|
108
|
+
-it \
|
109
|
+
--rm \
|
110
|
+
-w="/opt/app" \
|
111
|
+
-v="$(pwd):/opt/app" \
|
112
|
+
--env="PORT=3000" \
|
113
|
+
-p="3000:3000" \
|
114
|
+
--network="host" \
|
115
|
+
ruby:2.7.0 bash
|
116
|
+
```
|
117
|
+
|
118
|
+
**NOTE**: You will need to bundle install every time you start a container with this command
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Saxton
|
@@ -33,7 +33,7 @@ files:
|
|
33
33
|
- LICENSE
|
34
34
|
- README.md
|
35
35
|
- lib/kno.rb
|
36
|
-
homepage: https://
|
36
|
+
homepage: https://github.com/trykno/kno-ruby
|
37
37
|
licenses:
|
38
38
|
- Apache-2.0
|
39
39
|
metadata: {}
|