You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now you can specify the username and password to your API in the Swagger "API key" field by concatenating the values like this:
57
+
58
+
username:password
59
+
60
+
The javascript that loads on the Swagger page automatically encodes the username and password and adds the authorization header to your API request.
61
+
See the official Swagger documentation about [Custom Header Parameters](https://github.com/wordnik/swagger-ui#custom-header-parameters---for-basic-auth-etc)
62
+
63
+
### Swagger UI Authorization
64
+
65
+
You may want to authenticate users before displaying the Swagger UI, particularly when the API is protected by Basic Authentication.
66
+
Use the `authenticate_with` option to inspect the request to the Swagger UI:
67
+
68
+
```ruby
69
+
GrapeSwaggerRails.options.authenticate_with do |request|
70
+
# 1. Inspect the `request` or access the Swagger UI controller via `self`
71
+
# 2. Check `current_user` or `can? :access, :api`, etc....
72
+
# 3. return a boolean value
73
+
end
74
+
```
75
+
76
+
The block above is stored in the `authentication_proc` option:
77
+
78
+
```ruby
79
+
GrapeSwaggerRails.options.authentication_proc:Proc.new{|request| # return a boolean value}
80
+
```
28
81
29
82
## Known problems
30
83
31
84
To avoid problems with the validation parameters in `POST` request using this gem,
0 commit comments