Giter VIP home page Giter VIP logo

actix-redis's Introduction

Actix redis Build Status codecov crates.io

Redis integration for actix framework.

NOTICE: This repository has been archived. Please visit https://github.com/actix/actix-extras instead.

Documentation

Redis session backend

Use redis as session storage.

You need to pass an address of the redis server and random value to the constructor of RedisSessionBackend. This is private key for cookie session, When this value is changed, all session data is lost.

Note that whatever you write into your session is visible by the user (but not modifiable).

Constructor panics if key length is less than 32 bytes.

use actix_web::{App, HttpServer, web, middleware};
use actix_web::middleware::session::SessionStorage;
use actix_redis::RedisSessionBackend;

#[actix_rt::main]
async fn main() -> std::io::Result {
    HttpServer::new(|| App::new()
        // enable logger
        .middleware(middleware::Logger::default())
        // cookie session middleware
        .middleware(SessionStorage::new(
            RedisSessionBackend::new("127.0.0.1:6379", &[0; 32])
        ))
        // register simple route, handle all methods
        .service(web::resource("/").to(index))
    )
    .bind("0.0.0.0:8080")?
    .start()
    .await
}

License

This project is licensed under either of

at your option.

Code of Conduct

Contribution to the actix-redis crate is organized under the terms of the Contributor Covenant, the maintainer of actix-redis, @fafhrd91, promises to intervene to uphold that code of conduct.

actix-redis's People

Contributors

ava57r avatar dowwie avatar fafhrd91 avatar johntitor avatar pandaman64 avatar ryanmcgrath avatar turbo87 avatar yinyanlv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actix-redis's Issues

Docs say the users can see the session content but they can only see session key

The documentation of RedisSessionBackend says: whatever you write into your session is visible by the user (but not modifiable). The user only sees the session key and not the content as far as I can tell. Is this an error in the documentation or am I reading it wrong?

Here is the line in question:

/// Note that whatever you write into your session is visible by the user (but

Connect to password protected redis

Maybe it is just me, but I can not find a place to config password for Redis backend in actix-redis, so I guess I will have to manually send AUTH password every time?

Thanks.

Reconnect to redis

RedisActor needs to be able to reconnect to redis server. This requires changes in actix

support for actix_web 1.0.2

hiii,

please resolved depedency library for actix web v 1.0.2

this is log error fro cargo build

failed to select a version for ring.
... required by package actix-http v0.2.4
... which is depended on by actix-web v1.0.2
... which is depended on by payslip v0.1.0 (/Users/maulana/rust/payslip)
versions that meet the requirements ^0.14.6 are: 0.14.6

the package ring links to the native library ring-asm, but it conflicts with a previous package which links to ring-asm as well:
package ring v0.13.5
... which is depended on by cookie v0.11.0
... which is depended on by actix-redis v0.5.1
... which is depended on by payslip v0.1.0 (/Users/maulana/rust/payslip)

thanks brother,

copy/paste error

I have copy/paste example code examples/basic.rs + git pull actix + actix-web + actix-redis

and i have

error[E0277]: the trait bound `actix_redis::RedisSessionBackend: actix_web::middleware::SessionBackend<_>` is not satisfied
  --> src/main.rs:40:25
   |
40 |             .middleware(middleware::SessionStorage::new(
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `actix_web::middleware::SessionBackend<_>` is not implemented for `actix_redis::RedisSessionBackend`
   |
   = note: required by `<actix_web::middleware::SessionStorage<T, S>>::new`

error[E0277]: the trait bound `actix_redis::RedisSessionBackend: actix_web::middleware::SessionBackend<()>` is not satisfied
  --> src/main.rs:40:14
   |
40 |             .middleware(middleware::SessionStorage::new(
   |              ^^^^^^^^^^ the trait `actix_web::middleware::SessionBackend<()>` is not implemented for `actix_redis::RedisSessionBackend`
   |
   = note: required because of the requirements on the impl of `actix_web::middleware::Middleware<()>` for `actix_web::middleware::SessionStorage<actix_redis::RedisSessionBackend, ()>`

error: aborting due to 2 previous errors

error

i have alway error in another projet

git clone https://github.com/ami44/tmp-actix-web-redis.git + cargo run display

 --> src/main.rs:40:25
   |
40 |             .middleware(middleware::SessionStorage::new(
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `actix_web::middleware::SessionBackend<_>` is not implemented for `actix_redis::RedisSessionBackend`
   |
   = note: required by `<actix_web::middleware::SessionStorage<T, S>>::new`

error[E0277]: the trait bound `actix_redis::RedisSessionBackend: actix_web::middleware::SessionBackend<()>` is not satisfied
  --> src/main.rs:40:14
   |
40 |             .middleware(middleware::SessionStorage::new(
   |              ^^^^^^^^^^ the trait `actix_web::middleware::SessionBackend<()>` is not implemented for `actix_redis::RedisSessionBackend`
   |
   = note: required because of the requirements on the impl of `actix_web::middleware::Middleware<()>` for `actix_web::middleware::SessionStorage<actix_redis::RedisSessionBackend, ()>`

failed to build with version 0.6.0

It depends on actix_utils and when I try to build it.
use actix_utils::cloneable::CloneableService;.and could not find cloneable in actix_utils.It seems that you had removed it from actix_utils

Supporting transactions: appropriate?

redis_async leaves redis transactions as an open question.

I think this crate would be more well suited to handle transactions than redis_async since we have helpers like AsyncContext::wait which could delay all requests on a channel until a transaction is fully complete.

Do you think that that would be within the scope of this repository? If support for transactions were PRd, would it be accepted?

Not recieving any cookie on client side

Hey, I am trying to use this crate to implement a cookie based auth system in my actix web server. However, using the example in the README, I am not recieving any cookie headers on the client side. Is it the intended behaviour or am i missing something?

Conflicts with `actix-web v1.0.0-beta.1`

actix-redis v0.5.1 conflicts with actix-web v1.0.0-beta.1.

The log is here:
error: failed to select a version for `ring`.
    ... required by package `actix-http v0.1.1`
    ... which is depended on by `actix-web v1.0.0-beta.1`
    ... which is depended on by `foo v0.1.0`
versions that meet the requirements `^0.14.6` are: 0.14.6

the package `ring` links to the native library `ring-asm`, but it conflicts with a previous package which links to `ring-asm` as well:
package `ring v0.13.5`
    ... which is depended on by `cookie v0.11.0`
    ... which is depended on by `actix-redis v0.5.1`
    ... which is depended on by `foo v0.1.0`

But it seems that master branch fixes this, so could I know when next release comes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.